Event support for Scene Controllers

Sounds like great progress!
Misread your earlier posts, I didn’t realize that you were without entities being loaded on discovery.

if you drop this in the home-assistant/homeassistant/components/zwave/discovery_schemas.py you should have the system start to recognize the scene controller.

	{const.DISC_COMPONENT: 'switch',
     const.DISC_GENERIC_DEVICE_CLASS: [const.GENERIC_TYPE_STATIC_CONTROLLER],
     const.DISC_SPECIFIC_DEVICE_CLASS: [const.SPECIFIC_TYPE_SCENE_CONTROLLER ],
     const.DISC_VALUES: dict(DEFAULT_VALUES_SCHEMA, **{
         const.DISC_PRIMARY: {
             const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_CENTRAL_SCENE]
         },
         'indicator': {
             const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_INDICATOR]
         }})},

from there you need to modify ZwaveSwitch (or create a new class that is chosen in get_device() to handle the indicator value. https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/switch/zwave.py#L21

Interested?

Devan

That would only trigger once per scene controller right? Can I return an array of devices from get_device()? Any other way to end up with 5 switch entities?

I think for it to work right you can only return one but, I had thought (never confirmed) that the discovery would be run for each of the instances in the command class.

That is the issue I ran into. There is only 1 instance of the command class.

I would need to confirm but, according to the device config aren’t there 5 instances in the scene controller command class?

I don’t think so. I have the indicator command class being discovered as a sensor right now. If there were 5 instances, I would be getting 5 sensors discovered.

That’s unfortunate, I can try and look at this over the weekend I hope with logging but I had hoped that using the COMMAND_CLASS_CENTRAL_SCENE as the primary value would have caused it to run discovery for each instance in the command class (and bundle the same COMMAND_CLASS_INDICATOR value to each).

Maybe there’s something we could do have the COMMAND_CLASS_INDICATOR return a single device to the zwave discovery schema which creates 5 entities with the respective COMMAND_CLASS_CENTRAL_SCENE instance?

Entirely possible that you decide its not really even needed, I was just thinking how to create a switch entity to display in frontend for each of the COMMAND_CLASS_CENTRAL_SCENE instances. The thought was it would make automations cleaner with the entities tracking the scene event sand basic events against the indicator.

That would be great, but I wasn’t able to find a clean way to make it work that way. At this point, I have what I need. If someone can figure out how to improve it, that’s great. I’m going to focus on getting my PR up so it can get merged.

I submitted the PR this morning. https://github.com/home-assistant/home-assistant/pull/16638

Thanks again!

My PR was included in the 0.80 release.

1 Like

Thanks! With your additions and a little bit of AppDaemon magic, I’ve now got a full sync between a set of 5 input_booleans and the indicator lights on my RFWC5 scene controller! Everything’s ready to be hooked into some actual control of… something. Honestly not entirely sure what I’ll be controlling with mine yet.

Hi @blakeblackshear,

Thanks for implementing this. It works great for checking the state of and setting the indicators on my Cooper RF9501 switches. However, the indicator on my RF9517’s indicator does not have an entity created. By turning on debug level logging, I was able to see the value_id in the log file and use that in my automations. I’m not sure if I need to worry about the value_id changing, but it’d be cleaner to use the entity indirectly reference the value_id.

Is there a specific component I should enable debug logging for & restart home assistant to help debug this? I had enabled debug for all, which was a pretty massive & spammy file

Also, should I submit this as a bug in github?

Thanks.

If the device has the indicator command class defined, it should create an entity for it. Looks like that is an accessory switch, and I don’t have that model. Without having one myself, I can’t really say if it is a bug or just needing to edit the zwcfg file for that device.

Looking at the zwcfg, I see the same CommandClass element with attribute id=“135”
The text is exactly the same, so I think the zwcfg contents can be ruled out.

I’m a little new to this, but i see the sample for the config but wondering if you could help me understand how to configure it to my setup.

1 Like

Yeah, I’m noticing I have sensor entities from my dimmers but not my controller…

dimmer:

        <Node id="25" name="UpstairsLibraryL" location="" basic="4" generic="17" specific="4" type="Multilevel Scene Switch" listening="true" frequentListening="false" beaming="true" routing="true" max_baud_rate="40000" version="4" query_stage="Complete">
                <Manufacturer id="1a" name="Cooper">
                        <Product type="4449" id="101" name="RF9540-N All Load Dimmer Light Switch" />
                </Manufacturer>
                <CommandClasses>
...
                        <CommandClass id="135" name="COMMAND_CLASS_INDICATOR" version="1" request_flags="4" innif="true">
                                <Instance index="1" />
                                <Value type="byte" genre="user" instance="1" index="0" label="Indicator" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="255" value="0" />
                        </CommandClass>
                </CommandClasses>
        </Node>

Scene Controller:

        <Node id="29" name="UpstairsSceneCon" location="" basic="2" generic="2" specific="2" type="Static Scene Controller" listening="true" frequentListening="false" beaming="true" routing="false" max_baud_rate="40000" version="3" query_stage="Complete">
                <Manufacturer id="1a" name="Cooper">
                        <Product type="574d" id="0" name="Unknown: type=574d, id=0000" />
                </Manufacturer>
                <CommandClasses>
...
                        <CommandClass id="135" name="COMMAND_CLASS_INDICATOR" version="1" request_flags="4" innif="true">
                                <Instance index="1" />
                                <Value type="byte" genre="user" instance="1" index="0" label="Indicator" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="255" value="0" />
                        </CommandClass>
                </CommandClasses>
        </Node>

My write up in another thread might be useful for people looking at this thread. It feels like I am doing some workarounds to make this scene controller function, but it seems to be working well.

1 Like

So for someone new that has a cooper scene controller, where do I start? I’ve added the zwave device. Now what?

Now that you’ve added the device, you should be able to find an entity called something like sensor.scene_contrl_indicator (something indicator). You’ll find it reports back a number. Each light on the controller matches up to one bit in that number, so if the top light is on, the number will be one. If the second one is also on, it’ll be three. Third one on also, you’ll have 7. So you can do a bitwise check on the indicator value to determine which lights are on.

In the Z-Wave settings for the scene controller, I associated group 255 to my Z-wave stick. I think this was a necessary step to receive an event (zwave.node_event) when the buttons were pressed, and not when they were just turned off? I don’t entirely remember.

I then made an AppDaemon script that listens for those "zwave.node_event"s and refreshes the indicator entity when they are received. You can see my script here, but note that I was lazy and hardcoded the entity id: https://pastebin.com/1PCXBE1V

Finally, I whipped up another AppDaemon script that listens for changes to the indicator entity and toggles a set of input_booleans appropriately (input_boolean.scene_switch[1-5]). On line 74, there’s a hardcoded node_id and value_id. The node_id is the Z-wave node ID, and the value ID should correspond to the indicator value, but I don’t remember how I found that value ID, or if it will be the same for you? Again, note that I hardcoded entity id’s in this script, so consider it more of a guideline: https://pastebin.com/iB80WMDb

From there, you can do whatever regular Home Assistant stuff you want on the input_booleans, and they should just update when you press the buttons on the scene control. Easy peasy!

I’m sure there are better ways to do this, but this was the way I opted to do it.

1 Like