Event support for Scene Controllers

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

Thanks for writing this up! So I dont need to modify my zwcfg? Also, I’ve never done anything with AppDaemon scripts. Could you help me know what to do with those? Do I make these files and copy them in the config directory? I see the sensor.scene_contrl_indicator but it remains 0. I did associate all the buttons in the zwave settings to the z-wave stick. Should I just do 255 and not 1 - 5? I really appreciate you helping me with this I’ve been wanting to do this for a long time!

Okay - I added these files to my appDamen apps folder… Modified line 74…

Oh yeah, I forgot about modifying the zwcfg. You’ll have to add in the COMMAND_CLASS_CENTRAL_SCENE stuff as in some of Blake’s posts above.

The indicator entity won’t refresh automatically, it has to be specifically asked to refresh (That’s what the first of my two scripts does, refreshes it when we see events saying that something has changed). As a test in the meantime, you’d be able to manually make the call to the service to update it, just to be sure that things are working right. In the services tab, you’d want to use the “zwave.refresh_entity” service, and specify your indicator sensor as the entity_id. Afterwards, you should see the correct value in it.

For the AppDaemon scripts, you’ll need to install AppDaemon (might be easier or harder depending on how you have HA installed, eg Hassio vs a regular install). You’d then want to make a file for each script in /config/appdaemon/apps/ (ZwaveEventListener.py and SceneControllerHandler.py). Then in /config/appdaemon/apps/apps.yaml you’d need to add the following to activate instances of the scripts:

zwaveEventListener:
  module: ZwaveEventListener
  class: ZwaveEventListener

sceneControllerHandler:
  module: SceneControllerHandler
  class: SceneControllerHandler

To be honest, I thought I added associations for groups 1-5 as well, but it isn’t showing in my Z-Wave config. It probably wouldn’t hurt to do so.

In ZwaveEventListener.py you’d need to modify line 13 with the name of your zwave entity for the scene controller, and line 15 with your indicator entity.

In SceneControllerHandler.py:
-Lines 9, 23, update with your indicator entity
-Line 74 as mentioned, make sure it references the z-wave node id. The value_id may be fine as is?
-If you want to use other names for the individual switches, you’ll need to change all references to input_boolean.scene_switch_[1-5] to whatever you want.

Okay I actually just kind of figured that our and edited my apps.yaml file. Looking now…

019-02-06 21:31:36.691805 INFO AppDaemon Version 3.0.2 starting 2019-02-06 21:31:36.692122 INFO Configuration read from: /config/appdaemon/appdaemon.yaml 2019-02-06 21:31:36.693622 INFO AppDaemon: Starting Apps 2019-02-06 21:31:36.697448 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin 2019-02-06 21:31:36.805241 INFO AppDaemon: HASS: HASS Plugin Initializing 2019-02-06 21:31:36.805888 INFO AppDaemon: HASS: HASS Plugin initialization complete 2019-02-06 21:31:36.806380 INFO Starting Dashboards 2019-02-06 21:31:36.817816 INFO API is disabled 2019-02-06 21:31:36.828245 INFO AppDaemon: HASS: Connected to Home Assistant 0.86.4 2019-02-06 21:31:36.919660 INFO AppDaemon: Got initial state from namespace default 2019-02-06 21:31:38.919047 INFO AppDaemon: Reading config 2019-02-06 21:31:38.922004 WARNING AppDaemon: Error loading configuration 2019-02-06 21:31:38.922231 WARNING AppDaemon: parser says 2019-02-06 21:31:38.922636 WARNING AppDaemon: in "&lt;unicode string&gt;", line 5, column 2: zwaveEventListener: ^ 2019-02-06 21:31:38.922893 WARNING AppDaemon: expected &lt;block end&gt;, but found '&lt;block mapping start&gt;' while parsing a block mapping 2019-02-06 21:31:38.923197 WARNING AppDaemon: File '/config/appdaemon/apps/apps.yaml' invalid structure - ignoring 2019-02-06 21:31:38.923395 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified 2019-02-06 21:31:38.923657 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified 2019-02-06 21:31:38.924010 INFO AppDaemon: Adding /config/appdaemon/apps to module import path 2019-02-06 21:31:38.925116 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/zwaveeventlistener.py - ignoring 2019-02-06 21:31:38.925427 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/scenecontrollerhandler.py - ignoring 2019-02-06 21:31:38.925696 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/hello.py - ignoring 2019-02-06 21:31:38.926510 INFO AppDaemon: App initialization complete

I think that’s something to do with the formatting in your apps.yaml, IIRC.

“zwaveEventListener:” should have no spaces before it, and the next two lines should each be indented two spaces. Might have copied some funny blank characters that are getting misinterpreted

Yep that was it. Now I get this:

2019-02-06 21:37:50.999165 INFO AppDaemon Version 3.0.2 starting
2019-02-06 21:37:50.999568 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2019-02-06 21:37:51.001463 INFO AppDaemon: Starting Apps
2019-02-06 21:37:51.006395 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2019-02-06 21:37:51.094250 INFO AppDaemon: HASS: HASS Plugin Initializing
2019-02-06 21:37:51.094824 INFO AppDaemon: HASS: HASS Plugin initialization complete
2019-02-06 21:37:51.095214 INFO Starting Dashboards
2019-02-06 21:37:51.102805 INFO API is disabled
2019-02-06 21:37:51.112876 INFO AppDaemon: HASS: Connected to Home Assistant 0.86.4
2019-02-06 21:37:51.199866 INFO AppDaemon: Got initial state from namespace default
2019-02-06 21:37:53.195880 INFO AppDaemon: Reading config
2019-02-06 21:37:53.202411 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2019-02-06 21:37:53.202658 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2019-02-06 21:37:53.202927 INFO AppDaemon: App 'hello_world' added
2019-02-06 21:37:53.203200 INFO AppDaemon: App 'zwaveEventListener' added
2019-02-06 21:37:53.203446 INFO AppDaemon: App 'sceneControllerHandler' added
2019-02-06 21:37:53.203829 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2019-02-06 21:37:53.204923 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/zwaveeventlistener.py - ignoring
2019-02-06 21:37:53.205146 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/scenecontrollerhandler.py - ignoring
2019-02-06 21:37:53.205423 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2019-02-06 21:37:53.215528 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2019-02-06 21:37:53.314588 INFO hello_world: Hello from AppDaemon
2019-02-06 21:37:53.316225 INFO hello_world: You are now ready to run Apps!
2019-02-06 21:37:53.316400 INFO AppDaemon: Initializing app zwaveEventListener using class ZwaveEventListener from module ZwaveEventListener
2019-02-06 21:37:53.316623 WARNING AppDaemon: Unable to find module module ZwaveEventListener - zwaveEventListener is not initialized
2019-02-06 21:37:53.316769 INFO AppDaemon: Initializing app sceneControllerHandler using class SceneControllerHandler from module SceneControllerHandler
2019-02-06 21:37:53.316989 WARNING AppDaemon: Unable to find module module SceneControllerHandler - sceneControllerHandler is not initialized
2019-02-06 21:37:53.317732 INFO AppDaemon: App initialization complete