How to issue a ZWave COMMAND_CLASS_SWITCH_ALL

I’m digging into the source of ZWaveSwitchAllCommandClass.java and trying to understand how to trigger the allOnMessage() and allOffMessage(). Reading in a previous thread it seemed like I could create a virtual item such as:

Switch house_on "On House" (Group_Test) {zwave="1:command=switch_all,switch_all_on=true"}
Switch house_off "Off House" (Group_Test) {zwave="1:command=switch_all,switch_all_off=true"}

and then perhaps use it in a rule based on scene commands from double clicking a switch:

rule "Scene Test"
when
    Item front_door_scene changed
then
    logWarn("Scene Test", front_door_scene.state.toString())
    switch (front_door_scene.state) {
        case 2.3: {
            house_on.sendCommand()
        }
        case 1.3: {
            house_off.sendCommand()
        }
    }
end  

but I’m definitely missing something on the binding side since the rule triggers fine.

I’m looking at how normal switches bind to the ZWaveBinarySwitchCommandClass but I still can’t see how their setValueMessage(level) is triggered from a item.sendCommand(ON).

  1. What’s the quickest way to get SWITCH_ALL working? The use case is double-clicking down on the switch next to my front door to efficiently and quickly shut down the whole house (except for devices that have opted out such as outside lights).

  2. What’s a good read/explanation to see how the binding and thing syntax resolve to the java calls I’m looking at?

I don’t understand the statement. If the rule triggers fine then what’s the problem?

As for 1, assuming you get this to work, it would only work with Zwave devices. If you need to control non-zwave devices too you need to do so in a Rule.

Assuming that only zwave is OK, then this is almost certainly going to be implemented using Association Groups I would think which you would configure on each device you want to respond to the double click.

The rule triggers and I get the log statement showing that the double click has been recognized and received. I can even turn on/off another device using double click. I just don’t know the syntax for reaching into the ZWaveSwitchAllCommandClass.java class and calling its allOnMessage().

My {zwave="1:command=switch_all,switch_all_on=true"} is wrong since I don’t get the log output from ZWaveSwitchAllCommandClass.java.

Since Zwave supports the All On/Off as a core command I don’t want use up an association group for this. I also want to have new devices join this action by default. They would since devices have to opt out of this command so it’s exactly what I want.

Everything is working fine if I issue the ZWave all on/off command outside of openHAB such as low level utility or with an external controller (Aeotec minimote). Looking at ZWaveSwitchAllCommandClass.java it also looks like openHAB already has the implementation to issue the network level command. I just don’t know the syntax to invoke it. Any idea? I think it would be an amazing feature an example for anyone with ZWave. I’m planning to use it as both a “goodbye/goodnight” and a “alarm scare them away”.

From A Rule? You don’t. You send commands or post updates to Items. You never reach into a specific binding and call a method on some random class.

That’s an internal class in the binding. That method can only be called from within the binding.

The proper way is to receive the double click command and trigger a ruke, which you say already works, and then issue the proper commands or updates to Items to turn things on or off or charge their state.

For something like this, I would put the items I want to control into a Group and any command sent to the Group will be sent to all of its members.

If you are using the 2.x version of the binding then this syntax is totally wrong. You discover Things from the Inbox and thin link Channels to Items. That is the old 1.x syntax.

You can’t. I’m not sure why it’s implemented at all as it is not available outside of the binding itself. We can’t use it. And even if we could, it works only with zwave devices and the whole point of OH is to implement this sort of behavior in a technology agnostic manner.

SWITCH_ALL is a zwave command class. The device next to your front door is apparently sending it. To use it in OH2, you will need an Item linked to a Channel. However, you would likely have better results with a group containing all your lights (even non-zwave), and sending ON/OFF to switches and previous state/OFF to dimmers.

@chris, some (all?) of my devices support the CC. There are no Channels added, but have seen some settings… is there some hidden functionality for it? If the binding supports it, and the Channel was added, would switching it ON/Off cause all supported lights to turn on/off?

So I’ve done some more reading on Z-Wave in general. This may not be how OpenHAB is designed to do but Z-Wave has three target addressing modes:

  1. Single target (one of the 232 nodes receives the command)
  2. Broadcast (send to node “255” which will send the command to ALL nodes)
  3. Multicast (use a bitfield header of 232 bits to send to a subset of the mesh)

OpenHAB uses mode #1 but SWITCH_ALL is really only useful in broadcast mode since each node will decide if it will respond to that command.

With things+channels+items, I realize this doesn’t fit with the model but is there a hardcoded “all” group that translates to a single message to node “255”. A broadcast function in OpenHAB? If not, would it work if I started working on a patch in this direction? Would it fit at all with the model?

Yes I realize I can do this with a manually maintained group but I have over 70 nodes and I would like an alarm to immediately turn on all devices, except the ones that have explicitly opted out of the SWITCH_ALL_ON.

Before doing anything, it will be best to ping @chris (the maintainer for the zwave binding). I think he was away on holiday last time I tried.

Currently this isn’t implemented. One of the issues (and I also have this problem with ZigBee) is that I can’t think of a way to link a channel to a group - there is no point in sending a SwitchAll command to individual devices - so somehow there needs to be a way to link channels directly to groups I think.

Does it make sense as a Channel on the controller, that multicasts the all ON/OFF? Assuming that is even possible. I see the GET can’t be multicast, but I don’t see that restriction on the SET.

Just to be clear, this would turn on all zwave devices. If you want to turn on ALL devices you need to use a Group. One of the main points of OH is that it can bridge between multiple different technologies. For example, if I wanted to turn on all my lights, I’d need to involve zwave and MQTT. Very few of us have only one technology in our environment.

Chris, could you set it up so there’s effectively an “all” channel? So then someone could bind an item to “zwave:device:xxxxxxxxxxxx:all:switch” and send ON/OFF to it? You don’t need to send a SwitchAll to individual devices, but you could effectively create an individual device that represents the entire network.

Hi. I fully understand you and have exactly the same problem having around 100 devices. When intrusion alarm triggers- I have siren and also turn on all my lights. And instead of sending 100 ”on” commands as today I would like to broadcast just one ZWAVE ALL ON command. So the relevant function in OH3 is defenitely needed! :face_with_monocle:

In my scenario it takes half a minute before all devices turns on alarm. And if during this time I decide to abort alarm (so switch off siren and all lights) then it doesn’t work immediately, since the network overflooded by commands. So I wait additionsl half a minute lustening for the nasty siren and wait for light ”disco” on-off. :dancer:

As a very ugly workaround I actually thought to open the cover on my minimote remote controller and connect some dry ZWave relay contacts to ALL ON button on minimote. By this I can simulate a physical press on the button. It is ugly but will work from OH. But still I would of course prefer to have a real function to trigger broadcast message to ZWave network. :+1:

I have a similar problem but with all off. I have a rule to shut off all my lights (which are all zwave) and it takes over a minute at times to shut everything off even with logic to check the state to make sure I’m only sending commands to items that are on to in theory reduce network traffic. Individual commands respond quickly otherwise so I’m 99% sure there’s nothing wrong with my network. Having the ability to send the native “all off” (or on) command would be a great addition and would at the very least reduce the added complexity of the rule I have for the same task while hopefully increasing the speed of turning everything off.

Subscribed. Would love to see if there’s a way to get multicast support on OH!

Fixing the high latency of zwave is one of the last things on my home automation to do list.

1 Like

I’m in the phase of optimizing the speed and responsiveness of the ZWave network and the ability to use ALL_ON or ALL_OFF would be just wonderful. Now I’m using OH Group to turn off all lights, and after turning ON and OFF the Group the ZWave network needs a couple of minutes to function normally again.

Fingers crossed.