Event support for Scene Controllers

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

Another questions, when I look in the zwave log and press a button on the scene controller, should I see a message from that node - My scene controller node is 58, and when I press a button on it, I don’t see it displaying anything in the log.

The error messages look like you may have named the files in all lowercase. The capitalization is important in this case, so they should be “SceneControllerHandler.py” and “ZwaveEventListener.py”. Alternately you could modify the “module” lines to match the capitalization of the file names you’ve given them.

Did you shut down Z-Wave before modifying zwcfg? You should be able to see a message in the logs when you press the buttons, so if you aren’t seeing them, I suspect something isn’t set up right.

Okay, corrected case.

2019-02-06 21:42:20.261895 INFO AppDaemon Version 3.0.2 starting
2019-02-06 21:42:20.262209 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2019-02-06 21:42:20.263699 INFO AppDaemon: Starting Apps
2019-02-06 21:42:20.267393 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2019-02-06 21:42:20.350715 INFO AppDaemon: HASS: HASS Plugin Initializing
2019-02-06 21:42:20.351259 INFO AppDaemon: HASS: HASS Plugin initialization complete
2019-02-06 21:42:20.351644 INFO Starting Dashboards
2019-02-06 21:42:20.358897 INFO API is disabled
2019-02-06 21:42:20.368559 INFO AppDaemon: HASS: Connected to Home Assistant 0.86.4
2019-02-06 21:42:20.486812 INFO AppDaemon: Got initial state from namespace default
2019-02-06 21:42:22.448841 INFO AppDaemon: Reading config
2019-02-06 21:42:22.455251 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2019-02-06 21:42:22.455498 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2019-02-06 21:42:22.455775 INFO AppDaemon: App 'hello_world' added
2019-02-06 21:42:22.455980 INFO AppDaemon: App 'zwaveEventListener' added
2019-02-06 21:42:22.456159 INFO AppDaemon: App 'sceneControllerHandler' added
2019-02-06 21:42:22.456447 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2019-02-06 21:42:22.457462 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/SceneControllerHandler.py
2019-02-06 21:42:22.467480 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2019-02-06 21:42:22.468126 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ZwaveEventListener.py
2019-02-06 21:42:22.468799 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2019-02-06 21:42:22.559851 INFO hello_world: Hello from AppDaemon
2019-02-06 21:42:22.561153 INFO hello_world: You are now ready to run Apps!
2019-02-06 21:42:22.561327 INFO AppDaemon: Initializing app zwaveEventListener using class ZwaveEventListener from module ZwaveEventListener
2019-02-06 21:42:22.562910 INFO zwaveEventListener: Listening for Z-Wave Events
2019-02-06 21:42:22.563201 INFO AppDaemon: Initializing app sceneControllerHandler using class SceneControllerHandler from module SceneControllerHandler
2019-02-06 21:42:22.564710 INFO sceneControllerHandler: Handling scene controller stuff
2019-02-06 21:42:22.565010 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_1 not found in AppDaemon
2019-02-06 21:42:22.565157 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_1 not found in AppDaemon
2019-02-06 21:42:22.593182 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_2 not found in AppDaemon
2019-02-06 21:42:22.593517 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_2 not found in AppDaemon
2019-02-06 21:42:22.613604 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_3 not found in AppDaemon
2019-02-06 21:42:22.613975 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_3 not found in AppDaemon
2019-02-06 21:42:22.634595 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_4 not found in AppDaemon
2019-02-06 21:42:22.634984 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_4 not found in AppDaemon
2019-02-06 21:42:22.701376 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_5 not found in AppDaemon
2019-02-06 21:42:22.701735 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_5 not found in AppDaemon
2019-02-06 21:42:22.729499 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_1 not found in AppDaemon
2019-02-06 21:42:22.730021 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_2 not found in AppDaemon
2019-02-06 21:42:22.730558 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_3 not found in AppDaemon
2019-02-06 21:42:22.730808 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_4 not found in AppDaemon
2019-02-06 21:42:22.731070 WARNING AppDaemon: sceneControllerHandler: Entity input_boolean.scene_switch_5 not found in AppDaemon
2019-02-06 21:42:22.732206 INFO AppDaemon: App initialization complete

You’ll need to create the input_booleans in your regular Home Assistant configuration.yaml. In my case, that would look like:

input_boolean:
  scene_switch_1:
    name: Scene Controller 1
    initial: off
  scene_switch_2:
    name: Scene Controller 2
    initial: off
  scene_switch_3:
    name: Scene Controller 3
    initial: off
  scene_switch_4:
    name: Scene Controller 4
    initial: off
  scene_switch_5:
    name: Scene Controller 5
    initial: off