Event support for Scene Controllers

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 "<unicode string>", line 5, column 2: zwaveEventListener: ^ 2019-02-06 21:31:38.922893 WARNING AppDaemon: expected <block end>, but found '<block mapping start>' 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

What I added to the ZWCFG is no longer there. I stopped hassio when I edited it. How do I stop z-wave? Okay. I added changes to configuration.yaml restarting HA.

Going into Configuration>Z-Wave and hitting Stop Network should be sufficient, from what I remember.

Here is what I added:

			
			<CommandClass id="91" name="COMMAND_CLASS_CENTRAL_SCENE" version="1" request_flags="5" innif="true" scenecount="0">
                <Instance index="1" />
                <Value type="int" genre="system" instance="1" index="0" label="Scene Count" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                <Value type="int" genre="system" instance="1" index="1" label="Button One" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                <Value type="int" genre="system" instance="1" index="2" label="Button Two" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                <Value type="int" genre="system" instance="1" index="3" label="Button Three" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                <Value type="int" genre="system" instance="1" index="4" label="Button Four" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                <Value type="int" genre="system" instance="1" index="5" label="Button Five" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
            </CommandClass>
			
		</CommandClasses>
	</Node>
</Driver>

That looks fine to me, and matches what is shown above. In my case, I did make ‘scenecount=“5”’ on the COMMAND_CLASS_CENTRAL_SCENE line, and in the ‘label=“Scene Count”’ line, I made it ‘value=“5”’ at the end. I don’t think that actually matters though. I think I had been working from some other example.

I feel like we are so close! Still not seeing anything from the scene controllers node when I press a button. When I pasted in the values above, I didn’t just put it at the end of the file, I placed it above the /driver and /node is that right?

The file I’m editing is: zwcfg_0xf94fffb5.xml

It’s hard to say exactly without knowing the full contents of your zwcfg file (Mine is almost 3000 lines long), but in the context of your file it should be located somewhere along the lines of this:

<Node id="58" name="Scene Contrl".... blah blah
  <Manufacturer>
    blah blah
  </Manufacturer
  <CommandClasses>
    <CommandClass id="32".....>
      blah blah
    </CommandClass>
    <CommandClass id="33".....>
      blah blah
    </CommandClass>
    <CommandClass id="34".....>
      blah blah
    </CommandClass>
    <CommandClass id="43".....>
      blah blah
    </CommandClass>
    <CommandClass id="91".....>
      THIS IS THE ONE YOU ACTUALLY CARE ABOUT, YOUR STUFF GOES HERE
    </CommandClass>
    <CommandClass id="112".....>
      blah blah
    </CommandClass>
    <CommandClass id="113".....>
      blah blah
    </CommandClass>
    <CommandClass id="114".....>
      blah blah
    </CommandClass>
    <CommandClass id="119".....>
      blah blah
    </CommandClass>
    <CommandClass id="133".....>
      blah blah
    </CommandClass>
    <CommandClass id="134".....>
      blah blah
    </CommandClass>
    <CommandClass id="135".....>
      blah blah
    </CommandClass>
  </CommandClasses>
</Node>

You may or may not have other Nodes listed in your file (if you do or do not have other Z-Wave devices. Make sure you’re making the changes within the correct Node!

Also, I feel like I was doing full restarts of Hassio after making changes to zwcfg, because it felt like it wasn’t loading things properly. It was probably overkill. Seems like you’re editing the right file. Everything after zwcfg is some generated identifer.

Okay, I believe I did what you said above. I will verify. About the only thing I see now is there are a few returns or line spaces between the new entries I added. I will remove and restart HA. I really appreciate you helping me!

Ugg! I opened the zwcfg after restart HA and the text I added was gone again, even after I stopped the zwave. Hmm… Stopped HA by running

 hassio ha stop

made change and restarting