Event support for Scene Controllers

I’m also really interested in getting this to work. I have the device and would love to help test if any wants. Thanks! Has any progress been made?

I wrote something up to create a sensor platform that reports indicator as the entity state and has a service for calling the set command.

Traveling right now so I haven’t had time to even validate the syntax on this but, here you go if you want to take a peek. As a disclaimer, I have no idea what I am doing when it comes to the home-assistant architecture (still reading the checklist/guidelines).

Has anyone got the Cooper 5 scene controller working with hassio ? Still no? If so, would appreciate an outline of the steps taken.

I got indicator working but I’m having second thoughts about this approach. May go in and just have it setup groups on scene controller to fire scene event on HA when button is activated (pressed with indicator light off).

Good luck! I hope someone can figure this out it works in homesheer and has me wondering if I should change :confused:

Still no progress?

I will be working on this soon. I really want to move away from ZWay, and this is the only thing holding me back at this point. I implemented it as an “App” in ZWay here, so I understand the details for how this controller works.

The execution environment for ZWay is a severely handicapped V8 implementation. For the life of me, I can’t understand why they didn’t just follow standard Node.js practices and implement all of this as a npm package.

Looks cool. I just read over it quick, looks like this code doesn’t handle any of the association work to notify the controller on button press, correct?

I’m thinking if I start this over again I would have the device creation do that and then just get the indicator status on a button press. Ran in to some confusion around how to direct the scene configuration/association with openzwave.

Also couldnt decide whether this made more sense as a scene controller, remote or group of switch device(s).

Not that I see time for this coming soon but, any thoughts?

That is correct, associating the controller with button needs to be setup beforehand. I do use those association groups to link up to my zwave switches so I get the hold to dim up and down. I didn’t want to mess with that here. The code isn’t anything I’m proud of, but I knew I would be moving away from Zway eventually anyways. The biggest thing I needed to accomplish was syncing the buttons across multiple controllers. This code will ensure that if any of the lights that are in the association groups are on, the indicator is on. Also, if all of the lights are off, the indicator is set off. This allows multiple scene controllers to stay in sync if you associate the same lights with buttons on multiple controllers. It also keeps them in sync if the light is turned on automatically via HASS.

I was thinking about implementing it as a group of switch devices when I port it over to HASS. You just have to fetch the indicator status on the generic scene off event since it doesn’t tell you what button actually turned off. There are some other quirks with the SceneConfiguration command class for these controllers. They aren’t the easiest to work with, but I wasn’t able to find anything comparable.

1 Like

Hope someone can get this to work… willing to test.

Started working on this today. It is my next project. I was able to get the scene events to show up similar to all the other central scene devices by adding this to my zwcfg_*.xml file.

<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>

I can also see the basic_set=0 event when I turn off a button. My current plan is to create a custom component that creates 5 switch components and checks the indicator value to determine the on/off status.

1 Like

Sounds great, you should be able to do this by editing the discovery schema in the existing Zwave component?

So the Component would listen for the BasicSet events and then refresh the indicator, then this would result in an event for the switch entity to trigger automation? I like it.

That’s what I am thinking. I know there are already some workarounds needed for the Schlage deadbolts, so I am planning to try and use that as an example.

@Devanl in a different thread, you mentioned that you were able to get the indicator commands to work. Can you share the details of what you got to work?

Unfortunately I seem to have never committed the working code, so its like it never happened :frowning:

What I remember doing was to add the COMMAND_CLASS_INDICATOR to the const.DISC_PRIMARY entry for the sensor entity. From there I was able to make a copy of the ZwaveDimmer and change it to make a ZwaveIndicatorSensor entry that supported async refresh of the indicator state.

What you might be better off doing though would be to add the COMMAND_CLASS_INDICATOR to the const.DISC_VALUES as an indicator attribute and adding support to ZwaveSwitch for handling a new indicator value/attribute. This way the indicator is tied to entity that creates the scene event?

I was never able to determine if the value_changed method in ZwaveLight was a good example of how things are supposed to be updated but, maybe you can listen for the bus event and then call self.values.indicator.refresh() which would later trigger the value_changed?

Good luck, feel free to bounce more ideas.

Devan

Were you ever able to actually set the indicator value?

I seem to recall that setting self.values.indicator.data caused the LED state on the controller to update. Don’t remember if there was some plumbing required there though. I basically followed what was done for color in ZwaveColorLight.

Had some time to tinker with this today. I was able to get a sensor setup for the indicator. Working on refreshing and setting its value next.
image

1 Like

Good bit of progress today. I ended up taking a different approach than I thought, but I think I have all of the pieces in place here to make it work. I just added a set_indicator service. At this point, I can check which LEDs are on, turn them on/off, and capture the scene events from the controllers. Now I just need to tie things together.

1 Like

I have everything working now. It isn’t plug and play, but you can get what you need with template switches and an automation. I couldn’t find a good way to have a single command class result in discovery of multiple devices, all of which needed to coordinate refreshing the indicator status to avoid making lots of extra calls. I ended up adding 2 new zwave services, set_indicator and refresh_indicator and new custom jinja filters for bitwise operations. Refreshing the indicator value is usually fast, but occasionally takes a few seconds. I would recommend triggering automations on the zwave.scene_activated event rather than the template switch state as it will just be faster. Unfortunately, we will just have to live with an occasional delay for turning things off. Now I need to figure out the process for opening a PR as this will be my first.

The configuration ends up looking like this:

automation:
  - alias: Sync the indicator on button events
    trigger:
      - platform: event
        event_type: zwave.scene_activated
        event_data:
          entity_id: zwave.scene_contrl
      - platform: event
        event_type: zwave.node_event
        event_data:
          entity_id: zwave.scene_contrl
    action:
      - service: zwave.refresh_indicator
        data: 
          node_id: 3
switch:
  - platform: template
    switches:
      button_1:
        value_template: "{{ states.sensor.scene_contrl_indicator.state | int | bitwise_and(1) > 0 }}"
        turn_on:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int + 1 }}"
        turn_off:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int - 1 }}"
      button_2:
        value_template: "{{ states.sensor.scene_contrl_indicator.state | int | bitwise_and(2) > 0 }}"
        turn_on:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int + 2 }}"
        turn_off:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int - 2 }}"
      button_3:
        value_template: "{{ states.sensor.scene_contrl_indicator.state | int | bitwise_and(4) > 0 }}"
        turn_on:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int + 4 }}"
        turn_off:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int - 4 }}"
      button_4:
        value_template: "{{ states.sensor.scene_contrl_indicator.state | int | bitwise_and(8) > 0 }}"
        turn_on:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int + 8 }}"
        turn_off:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int - 8 }}"
      button_5:
        value_template: "{{ states.sensor.scene_contrl_indicator.state | int | bitwise_and(16) > 0 }}"
        turn_on:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int + 16 }}"
        turn_off:
          service: zwave.set_indicator
          data_template:
            node_id: 3
            value: "{{ states.sensor.scene_contrl_indicator.state | int - 16 }}"