Meta (Pseudo) Device Plugin

Posted on
Thu Oct 18, 2012 7:14 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

mikeL wrote:
Where can I get version 0.9.9 that I understand is now available?

The latest version is always available from the Meta Device Announcements forum.

Posted on
Tue Oct 23, 2012 9:40 pm
jamus offline
Posts: 179
Joined: Dec 01, 2007

Re: Meta (Pseudo) Device Plugin

This plugin is a huge timesaver / complexity reducer in my setup, and I don't think this use case has been mentioned yet (edit: it was mentioned as a possible solution here).

I have a lot of multiway switches in my house.

What I did before was link all devices together using Insteon scenes. The problem I found is that if the main device is controlled from Indigo, the LEDs on the multiway switches would get out of sync, so I created a trigger that executed on device state change that would execute another scene to set the LEDs. Nine time out of ten this would generate unnecessary INSTEON traffic, sometimes causing collisions, to cover the one time that I would be controlling the device through Indigo.

Now, with this plugin, I simply add a meta device that controls a scene with the main device and the buttons on the multiway switches, and use that instead of the main device for remote display and control pages. I've created a couple triggers so that the meta device's state follows the main device's state.

My only feature request would have a additional option to mirror the state of another device.

Thanks for a great plugin!

Posted on
Fri Oct 26, 2012 1:29 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

jamus wrote:
This plugin is a huge timesaver / complexity reducer in my setup... ...My only feature request would have a additional option to mirror the state of another device.

The problem with implementing such a feature is the plugin would need to listen to every Indigo device event to pick out the ones that should generate a Meta Device state change. It certainly can be done, but I am not sure it is worth the additional processing load.

If there is other interest, I can certainly re-look at this issue However,in the meantime, you can do the same thing with triggers. You can create two triggers. One to watch your source device's state change to On and another for Off. Then change the Meta Device's state in the action. You could also do that in a single trigger that looked for any state change in the source device and used plugin scripting to get the source devices state and alter the Meta Device's accordingly. I am doing this for several Meta devices I have created that operate external relays.

EDIT: On re-reading your post, I realized this is what you are doing. But, you might try the plugin-scripting approach to save a trigger.

Posted on
Fri Oct 26, 2012 1:35 pm
terrydew offline
Posts: 258
Joined: Jun 10, 2011

Re: Meta (Pseudo) Device Plugin

I think the "state Mirror" feature would be a great addition. Could you have an option to turn such a feature off if the user's system couldn't handle the load? I am also using switchboard which looks for state changes and have not had any load problems.

Thanks for the great plugin

Posted on
Fri Oct 26, 2012 1:51 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

terrydew... I have used the device update subscription in the Group Trigger without problems. But, in that case, monitoring device/variable states is core to the functionality of the plugin. In the case of the meta-device it would be an ancillary feature, not key to the basic function of the plugin.

As you note, the state matching could be turned off in the plugin config and that might be worth considering. But, since it really takes just one trigger to monitor another device or variable, that seems like a lot less effort. Also, doing this with a trigger uses functionality already built into Indigo rather than re-creating that functionality in a plugin.

To make this easier, I will put together two sample scripts for controlling the Meta device state based on a device and a variable current state and post them here. But, for those who want to work this out on their own and need a hint, here is the basic flow:

a) Trigger on any change in state in the source device or variable
b) In the action, execute an embedded python script.
c) In the script:
    1) read the state of the device (or variable)
    2) If necessary, write some code to translate the source state to True or False
      Like: If inValue is "A" then outValue is False
    3) Set the Meta device to the source state

Posted on
Fri Oct 26, 2012 9:48 pm
jamus offline
Posts: 179
Joined: Dec 01, 2007

Re: Meta (Pseudo) Device Plugin

I solved my mirroring problem by adding my own action to the plugin so I can use it in a trigger. This functionality can probably be moved to it's own plugin, but it was easier adding it to an existing one.

Added the following to Actions.xml:
Code: Select all
        <Action id="mirrorAnotherDevice" deviceFilter="self">
                  <Name>Set device onState based on another device</Name>
                  <CallbackMethod>mirrorAnotherDevice</CallbackMethod>
                  <ConfigUI>
                                 <Field id="device" type="menu">
                                     <Label>Device:</Label>
                                     <List class="indigo.devices" filter="indigo.relay"/>
                                 </Field>
                 </ConfigUI>
        </Action>


Added the following function to plugin.py:
Code: Select all

        def mirrorAnotherDevice(self,action):
                if self.logLevel > 2: indigo.server.log(u"Mirror another device action called")
                if self.logLevel > 3: indigo.server.log("Action received: %s" % action)
                indigoDevice = indigo.devices[action.deviceId]
                sourceDeviceId = int(action.props.get('device', ""))
                try:
                        sourceDevice = indigo.devices[sourceDeviceId]
                except:
                        self.errorLog("Device not found.  Check configuration of action")
                        return
                indigoDevice.updateStateOnServer(key='onOffState',value=sourceDevice.onState)



Added the following to the end of validateActionConfigUi in plugin.py:
Code: Select all

                  elif typeId == "mirrorAnotherDevice":
                                 try:
                                                deviceId = int(valuesDict.get('device',""))
                                 except ValueError:
                                                errorMsgDict['device']=u"You must select a device."
                                                return (False, valuesDict, errorMsgDict)

                                 return (True,valuesDict)

Posted on
Sat Oct 27, 2012 3:09 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

jamus: Good solution. If you don't mind, I will include your action in the next release of the plugin.

When I read your first post, I had been thinking in terms of having the plugin do all the work, I.e. watching for changes in the device and then automatically, without the need for a trigger, effecting the state update. And, that was what I wanted to avoid. However, your solution fits the space nicely between plugin scripting (what I had proposed) and full scale automation of the process.

Now maybe some other creative person might want to write similar code to update the state of the Meta Device based on an Indigo variable value. :wink:

Thanks for a nice upgrade.

Posted on
Wed Jan 02, 2013 5:49 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Re: Meta (Pseudo) Device Plugin

How does the "META DIMMER" option work.

I have 2 LampLinc's that are commanded by a scene to work together as one.

I have created a META device to execute the scene from iTouch.

How can I get the META device to dim?

TYPE: Control Light/Appl
ACTION: ?
DEVICE: Meta

Posted on
Wed Jan 02, 2013 6:04 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

You could...
Change the brightness level in the devices window.
Change the brightness from the iTouch app (the most common use)
Change the level from a control page
Create a trigger+script to read changes in brightness from a read dimmer and then set the meta device to that level.

Posted on
Wed Jan 02, 2013 6:51 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Re: Meta (Pseudo) Device Plugin

berkinet wrote:
You could...
Change the brightness level in the devices window.
Change the brightness from the iTouch app (the most common use)
Change the level from a control page
Create a trigger+script to read changes in brightness from a read dimmer and then set the meta device to that level.


- From the Device window, slider does not dim the lights [log shows brightness changes]
- From iTouch, the pop-up slider does not dim the lights [log shows brightness changes]

What are the correct iTouch SERVER ACTION setting?

What does "response to change in brightness" do? I have it set to "do nothing", since I don't know what it does, or a real-life scenario of what it can do.

Posted on
Wed Jan 02, 2013 7:13 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

Take a look at the Meta-Device announcement thread. But, basically, you must define an action that is invoked anytime the brightness level of the meta-device.

Posted on
Wed Jan 02, 2013 7:55 pm
CraigM offline
Posts: 578
Joined: Oct 28, 2007

Re: Meta (Pseudo) Device Plugin

berkinet wrote:
...But, basically, you must define an action that is invoked anytime the brightness level of the meta-device.


For dimmer device creation: A separate pulldown menu will appear allowing you to select the action to take when a brighten/dim event is received. This means you can have separate Actions for On/Off and Brighten/Dim. For Brightness level changes, the same Action Group event will be executed regardless of whether the brightness increases or decreases.

I'm sorry , but this doesn't even begin to explain what the needed Action Group should be, or its settings.

The only options I see for actions are:
CONTROL LIGHT/APPL
On, Off, Toggle, Set brightness, Dim by %, Brighten by %

PLUGIN
Set device brightness level

These are all absolute choices. What action allows the device to know slider movements??

Posted on
Wed Jan 02, 2013 9:49 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

If you want to control something analogous to the brightness level of the Meta-Device, your action must include (or would probably just be) a script. For Brightness level changes, the same Action Group event will be executed regardless of whether the brightness increases or decreases.

If your Action script needs to have the current brightness level (as would be the case if you want to set something to an arbitrary level between 0 and 100), first it will have to query the meta device to get its brightness information and then use that to set the brightness of some real device. The following two line scripts should do what you want:

      In Python that would be something like:
      # Assume the meta-device is device number 123 and the controlled device is 456
      theBrightness = indigo.devices[123].states['brightnessLevel']
      indigo.dimmer.setBrightness(456, value=theBrightness)

      And, in AppleScript:
      -- Assume the meta-device is named Meta Dimmer and the controlled device is named Office Lamp
      set theBrightness to the brightness of device "Meta Dimmer"
      set brightness of device "Office Lamp" to theBrightness

Posted on
Thu Jan 03, 2013 10:21 am
Dewster35 offline
Posts: 1030
Joined: Jul 06, 2010
Location: Petoskey, MI

Re: Meta (Pseudo) Device Plugin

I am using indigo 6 and trying to setup the meta device plugin to control a scene. I have "zones" of lights, work, home living, home sleeping, outside etc. that are already setup as scenes. All was well, added the devices and everything was OK. Then I realize that I had my office lights but they weren't in a zone, so I setup my downstairs working zone in the controller as a scene, synced everything. However, upon trying to add the new meta device for that zone, the scene does not show up. I tried reloading the plugin, restarting indigo, but nothing seems to add that to the dropdown list. Is there a limit to how many scenes this plugin can look at in the controller? I have 30 currrently setup.

Posted on
Thu Jan 03, 2013 12:11 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Meta (Pseudo) Device Plugin

Dewster35 wrote:
...Is there a limit to how many scenes this plugin can look at in the controller? I have 30 currrently setup.

There is no limit to the number of scenes that can be listed. And I just double checked the code under Indigo 6. However, I have a suspicion as to where the problem lies.

First, Disable the MetaDevice plugin. Then, in a Finder window, go to the Indigo 6 Plugins folder. Then open (Right click and select "Show Package Contents") the MetaDevice plugin. Then, navigate down to Contents -> Server Plugin. Finally delete the following two files: berkinet.pyc and plugin.pyc (Only the pyc files, not the py files. Finally, restart the plugin.

Let me know if this resolves the problem.

Who is online

Users browsing this forum: No registered users and 2 guests