[sub]Note: See at the end of this post for updates.[/sub]
[sub]Updated: 02 September 2013[/sub]
I was reading through the forums, and stumbled across an old post by Ap15e called AOO - a plugin that would turn Z-Wave devices (that supported it) on or off using the ALL ON or ALL OFF Z-Wave command.
Original discussion on this can be found at:
http://forum.micasaverde.com/index.php/topic,9034.msg59072.html#msg59072
And more info with the no longer available AOO plugin:
http://forum.micasaverde.com/index.php/topic,9080.0.html
READ THESE TWO TOPICS FIRST BEFORE TRYING TO USE – IT MAY NOT WORK FOR YOU AND/OR ALL OF YOUR Z-WAVE DEVICES!! TRIAL AND ERROR ON YOUR PART IS REQUIRED TO FIND OUT IF/HOW YOU CAN USE THIS PLUGIN!
WARNING: This plugin may trigger devices other than what you have configured. The UI in Vera is not always updated to show the current state of the device, so you will have to visually check to make sure everything is on or off. I highly recommend you use the information in the AOO plugin thread to disable any devices you don’t want triggered before using this plugin.
I was disappointed that this was a plugin that was no long available to for download/use. Since the concept of operation was described in detail in the two forum posts above, I decided I would try my hand at making my own plugin.
I present to you:
All Control Plugin v.05
The theory behind the operation/function of this plugin is, if a Z-Wave device supports and has been configured to respond to the ALL ON or ALL OFF Z-wave command, then you can control those devices with a single push of a button.
I used the Binary Light device for the interface, with the buttons labeled “All On” and “All Off”. It should function as a master light switch.
The plugin has the following variables that must be configured:
Devices - A list of devices (using altids) and config mode.
Format: [alt id]=[mode].
Where mode is:
0 - Disabled (device ignores)
1 - Off enabled
2 - On enabled
255 - On and Off enabled
Suppose you have three devices, all with the alt ids of 5,6 and 7. You want to disable 5, have 6 respond to both ON and OFF commands, and 7 only respond to the ON command. To do this, you would set the Devices variable to:
5=0,6=255,7=2
SendMode - Changes the behavior of the data passed with the SendMode command. The data will either use spaces or dashes to separate the data items passed.
0 - Don’t use dashes (default)
1 - Use dashes
StartupConfig - This will prevent the ACP Plugin from calling the config routine at startup.
0 - Off. Prevents the config routine from being called at startup.
1 - On. Calls the config routine at startup (default)
ForceSetup - This will cause the configure routine to be called before the ALL ON or ALL OFF command, causing them to be re-setup on each run.
0 - Off, don’t setup z-wave devices before sending ALL ON/OFF command (default)
1 - On, configure z-wave devices before sending ALL ON/OFF command
Note: If you set StartupConfig to 0, ForceSetup must be set to 1.
VerboseDebug - causes additional messages to be sent to the log file
0 - Off (default)
1 - On
OnCount - Number of times to send the ALL ON command (default = 1).
OffCount - Number of times to send the ALL OFF command (default = 1).
Delay - Number of milliseconds to delay between sending each successive ALL ON/OFF command (default = 1000)
ConfigDelay - Number of seconds to delay after running the device config route - used with ForceSetup (default = 10 seconds).
UseSetTarget - This will turn the specified devices on or off using the SetTarget call rather than broadcasting the ZWave ALL ON/OFF commands.
0 - Off. Use ZWave ALL ON/OFF (default)
1 - On. Use SetTarget
ReverseOnOff - Changes the behavior of the ALL ON/OFF switch, reversing its behavior (i.e., SetTarget = 0 will turn on devices, etc.) ( 0 = normal mode, 1= reverse mode).
Here are the functions that you can use:
(Called using: [tt]urn:acp-plugin-org:serviceId:ACP_Service1[/tt] )
AllOff - will send the ALL OFF command
AllOn - will send the ALL ON command
GetStatus - will return the value of Status (1=on, 0=off)
ToggleState - will “toggle” the switch to the opposite of its current state. If the switch is on, then it will turn off, etc.
(Called using: [tt]urn:upnp-org:serviceId:SwitchPower1[/tt])
SetTarget - used in the same manner as the SetTarget function for a normal light. (0 = turn off, 1= turn on)
GetStatus - will return the value of Status (1=on, 0=off)
GetTarget - will return the value of the Target state variable (always seems to be 0). (Included since it shows up when querying the SwitchPower service as an item)
I’ve noticed that you often have to wait a bit before the ZWave ALL ON or ALL OFF command will work. The values that you use to configure your device depends on what it supports.
Hopefully someone finds this useful.
Let me know what bugs you find.
Oops: I mixed up ALL OFF and ALL ON in the SendData command. Fixed!
[hr]
Updates:
-
I realized that I had the wrong ServiceId in the .json file. I was not using SwitchPower for the events list. I just updated the .json file now to use the correct ServiceId.
-
There was a small problem with the checking on startup that prevented logging of all the devices and the status they were set to. This has been fixed.
-
Part of the problem with reusing code, you sometimes miss something when you are too “close” to the subject. There was one variable that I forgot to change the name of in the switch status function. It is fixed now.
Version .02:
I have added the ability to send multiple ALL ON/OFF commands when using this plugin.
By setting the OnCount and OffCount variables, you can have the plugin send successive ALL ON/OFF commands. I have found that this helps with the problem I noted above with devices sometimes ignoring the ALL ON/OFF command.
The Delay variable defines the amount of time to wait between sending each successive ALL ON/OFF command. This code currently does not check for an invalid value in this variable, so I would recommend not using a value less than 1 or one larger than 1000.
Version .03:
I fixed the SetTarget function, making the plugin now act like a light switch. I’ve tested this with HomeWave and it works like it should.
Calling it with:
{ "u:SetTargetResponse": { "OK": "OK" } }
The SetTarget function will not immediately call the function to send the ALL ON/OFF command. Instead, it updates the Status variable, and then using luup.call_timer, it will queue appropriate ALL ON/OFF command to be called 3 seconds later.
I found that, when the plugin is setup to send multiple ALL ON/OFF commands, the delay caused by calling the ALL ON/OFF routine directly results in the command being called multiple times. This was due to the change in the Status variable not being caught, and the delay making the application think the command failed or timed out.
A new variable called StartupConfig is now available. Setting this to 0 will prevent the device configuration routine from running at startup. By not having the config routine run at startup, you can now have multiple ACP Plugin devices, all setup to control different groups of lights.
If you set this to 0, then you must set ForceSetup to 1. The plugin will check to make sure you haven’t set both to 0, preventing you from shooting yourself in the foot.
An example of how you would set this up
Suppose you had the following devices:
4 - Living room lamp #1
5 - Living room lamp #2
6 - Living room lamp #3
10 - Front Porch Light
11 - Back Porch Light
14 - Bedroom table lamp #1
15 - Bedroom table lamp #2
You want to control your lamps by the location they are in, having them controlled by a ACP Plugin device. To do this, you would create three ACP Plugin devices, and set the devices variable to:
Living room:
4=255,5=255,6=255,10=0,11=0,14=0,15=0
Outside lights:
4=0,5=0,6=0,10=255,11=255,14=0,15=0
Bedroom lights:
4=0,5=0,6=0,10=0,11=0,14=155,15=255
You would also set each plugin’s ForceSetup to 1 and StartupConfig to 0.
In theory, this should:
- Re-configure your ZWave devices, so only those you want to respond will (you need to include ALL ZWave devices that respond to the ALL ON/OFF command)
- The ALL ON/OFF command will be sent.
- Your configured devices will turn on or off.
Version .04:
I’ve come to realize that due to either limitations of the Vera3, ZWave or both, that trying to:
-
Use multiple instances of this plugin, with StartupConfig=0 and ForceSetup=1, may not produce the results expected. In fact, it is likely that without ConfigDelay set to something around 30 seconds, that your devices will not even respond to the ALL ON/ALL OFF command broadcast.
-
Trying to run this plugin with the ALL ON/OFF command right after reloading/startup will not do anything. You have to wait about 20 seconds before your devices will respond.
-
Any type of activity (Vera/plugins or ZWave devices/network) can cause the ALL ON/OFF command to not work/be ignored.
(ConfigDelay is a new variable in this version)
So, that being said. I’ve added some new features to this plugin that will allow you to turn devices on /off using calling the [tt]SetTarget[/tt] service of each ZWave device.
I’ve added a new variable called UseSetTarget, that when set to 1, will use [tt]SetTarget[/tt] to turn your devices on/off. The parameters passed in the Devices line will act the same using either the ZWave ALL ON/OFF or SetTarget modes of control.
(Note that sometimes Vera may show in the logs that all the SetTarget calls have been passed, but it will hang momentarily before all your devices respond.)
Since the SetTarget command requires device IDs, and I really didn’t want to break any configuration options from the previous versions, I’ve implemented function that maps device IDs to the ALTIDs specified in the Devices variable. Turning on VerboseDebug will allow you to see some of this mapping in action.
I’ve also modified what the AllOn/AllOff function calls do. They now just call SetTarget with the appropriate value (0 or 1).
And there are some changes/cleanup to the code as well.
Version .05:
There are just more general cleanups of the code. I didn’t realize that I have not been using service and serviceId when defining my services, instead I was using device. I’ve fixed this now.
<serviceType>urn:acp-plugin-org:service:ACP_Service:1</serviceType>
<serviceId>urn:acp-plugin-org:serviceId:ACP_Service1</serviceId>
Looks like I will need to check my other plugins for the same error. Not sure how that creeped in, but I found it using this on my Vera: http://<VeraIP>:3480/data_request?id=invoke
That was when I realized that the :device: should be :serviceId:
I have added two more functions:
GetTarget and ToggleState
Support for the ReverseOnOff variable has also been added. This will allow you to change how to switch acts, effectively setting it to act the opposite of what you specify with SetTarget. I added this just for completeness, since each individual ZWave light switch in the system should already have this defined if it was installed backwards, etc.