Support for zwave indicator command class

I’m finding a few devices where I’d like to use HA to sync the indicator value via the get/set indicator command class.

Not sure how to make this really happen, maybe a sensor for the get? Perhaps call a service for setting, can you support set with a sensor?

Thanks,
Devan

I’ve added a +1 vote here, but let me add in why I’d like to see this added.

I have a Cooper Aspire RF light switch and an accessory switch. I have set up their group associations in OZWCP. Physically pressing the buttons, all is well. If I turn on or off the accessory switch via Z-wave, nothing happens (which is fine), but if I turn on or off the main switch via Z-wave, the accessory switch does not follow, and requires two presses in order to toggle the lights. I also noticed that the blue LED does not reflect the state of the main switch.

Tooling around with OZWCP, I have noticed that if I set the indicator of the accessory switch when setting the main switch via Z-wave, the behavior is as desired (single press at accessory switch toggles the lights).

I’d like to set up an automation to keep the accessory switch’s indicator in sync with the state of the main switch. Not sure if there is a (more) “right” way to do this, but that’s what I’ve figured out.

@kvermilion, I have the same switches and a similar need. The two devices alone are pretty good at following each other as long as the associations are correct and no other devices try and talk to them (ie controller). So yes, I was basically going to have an automation that detected a state change on one and updated the other, if they weren’t in sync.

I took a swing at this the other day. Making a sensor platform (or is it component?) for the indicator command class was pretty straightforward with a discovery schema update. The trouble is I have not figured out what else needs to be implemented in order to have the state update on device change (a restart of hass will show the right value but I’m sure there’s another way). I was going to copy the refresh methods from the zwave light component, just haven’t been able to get around to it.

I don’t know if it stays a sensor either once I get to the set service.

Devan

Hi @Devanl,

I was thinking a nice solution would be adding a service to the zwave component which would allow the sending of arbitrary commands. I haven’t looked at openzwave-python docs & code to determine if that is even feasible. This of course would only be a solution for “set” operations, but I think it would be handy in general.

– Kevin

Could probably be done with an integer argument for command number. Not sure what the best way is to package parameter data. Maybe a bytestring?

I too am wondering about how to do this.

I noticed this thread

It appears that python-openzwave doesn’t support the indicator command class, so it will need to be added there first.

I did get indicator command working, it just appears to be very non-standard so I wasn’t sure what to do with it. If you have some ideas I can try and get it together.

For the scene controller switch, I’m not convinced it’s the right approach.

1 Like

Hi Devan,

Thanks for linking the progress you made in the other thread.
I gave your solution a try, and it doesn’t look like it’s working for me. I installed using the following commandline, from within my virtual environment:

 pip3 install --upgrade git+git://github.com/devanl/home-assistant.git@dev 

Here’s the errors from my log file:

2018-06-09 12:23:33 INFO (MainThread) [homeassistant.core] Bus:Handling     <Event state_changed[L]: entity_id=switch.kitchen_lights_switch, old_state=None, new_state=<state switch.kitchen_lights_switch=on; node_id=6, value_index=0, value_instance=1, value_id=72057594143391744, old_entity_id=switch.kitchen_lights_switch_6_0, new_entity_id=switch.kitchen_lights_switch, friendly_name=Kitchen Lights Switch, emulated_hue_hidden=False @ 2018-06-09T12:23:33.187498-07:00>>
2018-06-09 12:23:33 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: timestamp=1528572213.183307, level=ERROR, message=Error in manager callback, exception=Traceback (most recent call last):
  File "/opt/ha/lib/python3.6/site-packages/openzwave/network.py", line 950, in zwcallback
    self._handle_value_added(args)
  File "/opt/ha/lib/python3.6/site-packages/openzwave/network.py", line 1480, in _handle_value_added
    'value' : self.nodes[args['nodeId']].values[args['valueId']['id']]})
  File "/opt/ha/lib/python3.6/site-packages/pydispatch/dispatcher.py", line 338, in send
    **named
  File "/opt/ha/lib/python3.6/site-packages/pydispatch/robustapply.py", line 55, in robustApply
    return receiver(*arguments, **named)
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/zwave/__init__.py", line 320, in value_added
    hass, schema, value, config, device_config)
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/zwave/__init__.py", line 738, in __init__
    self._check_entity_ready()
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/zwave/__init__.py", line 828, in _check_entity_ready
    node_config=node_config, hass=self._hass)
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/sensor/zwave.py", line 35, in get_device
    return ZWaveIndicatorSensor(values)
TypeError: __init__() missing 2 required positional arguments: 'refresh' and 'delay'
, source=components/sensor/zwave.py>
2018-06-09 12:23:33 ERROR (Dummy-3) [openzwave] Error in manager callback
Traceback (most recent call last):
  File "/opt/ha/lib/python3.6/site-packages/openzwave/network.py", line 950, in zwcallback
    self._handle_value_added(args)
  File "/opt/ha/lib/python3.6/site-packages/openzwave/network.py", line 1480, in _handle_value_added
    'value' : self.nodes[args['nodeId']].values[args['valueId']['id']]})
  File "/opt/ha/lib/python3.6/site-packages/pydispatch/dispatcher.py", line 338, in send
    **named
  File "/opt/ha/lib/python3.6/site-packages/pydispatch/robustapply.py", line 55, in robustApply
    return receiver(*arguments, **named)
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/zwave/__init__.py", line 320, in value_added
    hass, schema, value, config, device_config)
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/zwave/__init__.py", line 738, in __init__
    self._check_entity_ready()
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/zwave/__init__.py", line 828, in _check_entity_ready
    node_config=node_config, hass=self._hass)
  File "/opt/ha/lib/python3.6/site-packages/homeassistant/components/sensor/zwave.py", line 35, in get_device
    return ZWaveIndicatorSensor(values)
TypeError: __init__() missing 2 required positional arguments: 'refresh' and 'delay'
1 Like

I am not sure how much is thanks to people doing work in the background, but I got the Cooper/Eaton 5 button scene working today using the huidance from the Z-Wave Device Specific Settings. https://www.home-assistant.io/docs/z-wave/device-specific/

I also had to use zensys-tools to configure the button scenes and associations, as described in the link below, as open-zwave doesn’t support those command classes. BTW, some of the commands I had to send multiple times. https://community.openhab.org/t/tutorial-cooper-rfwc5-scene-controller-with-openhab2/31731

I had to tweak some of the names, as could be expected, but I can now trigger automations based on presses from the five main buttons. The power button still doesn’t work, as this all relies on HASS polling the indicator lights when it detects a scene event and the power button doesn’t have an indicator.

Just happy that it works well enough to serve my purpose.

Might see about getting the power button to work some day.

Congratulations on your success, any chance you are planning to share your steps?

  1. back everything up, because one of us might screw this up.
  2. attach cooper/eaton 5 button scene controller to z-wave network as normal
  3. Follow the instructions in this guide to use zensys-tools to configure cooper scene controller (note: wait at least 10 seconds between sending commands. Most of my problems with this were from trying to go to fast)
    https://community.openhab.org/t/tutorial-cooper-rfwc5-scene-controller-with-openhab2/31731
  4. Install Samba share HASS.IO add-on and configure it. Replacing the CAPSLOCK text in the text below to fit your needs should work. Your workgroud is probably “WORKGROUP”, if you haven’t made any changes to windows workgroup settings.
    {
    “workgroup”: “WORKGROUP”,
    “username”: “ASTRINGOFCHARACTERS”,
    “password”: “ASTRINGOFCHARACTERS”,
    “interface”: “”,
    “allow_hosts”: [
    “10.0.0.0/8”,
    “172.16.0.0/12”,
    “192.168.0.0/16”
    “IP.ADDRESS.OF.CLIENT”
    ]
    }
  5. start samba add-on
  6. open windows file explorer
  7. type \IP.ADDRESS.OF.HASS (your actual HASS IP address preceded by the double “”) into windows file explorer and hit enter
  8. type in the username and password you configured
  9. (optional setup ssh and connect with putty to control turning HASS on and off)
  10. either use Putty or HASSIO->configuration->general page to “stop” HASSIO
  11. install notepad++
  12. go back to windows explorer folder
  13. open config folder
  14. add the code in the link below tells you to add to your zwcfg file (for RFWDC), making sure you don’t include any tabs (only use spacebar for indenting)
    https://www.home-assistant.io/docs/z-wave/device-specific/
  15. restart HASS.io (if you didn’t setup ssh, the easiest thing might be to reset the entire device/virtual machine)
  16. in HASS.io, click on entities ("<>" Under developer section on the bottom left)
  17. find the entity that is like “sensor.scene_contrl_indicator”
  18. record the exact name. Mine was sensor.scene_contrl_indicator_2
  19. record the node id for your sensor.scene_contrl_indicator and zwave.scene_contrl. Mine were both 10
  20. go back to this link and add the “switch:” code to your configuration.xml and add the “automation:” code to your automation.xml, starting from the “id:”
    https://www.home-assistant.io/docs/z-wave/device-specific/
    19b) replace the instances of “sensor.scene_contrl_indicator” in the code you just added with the one you noted in step 16.
    19c) replace the node_id: in the code you just added with the node id: you noted in step 18.
    19d) replace the node_id for the zwave.scene_contrl with the correct node_id from entities in step 18
  21. setup your automation to trigger on the switch changes from the switches you just added.
    QED

note: in step 19, you will have to add a hyphen before the automation id. they didn’t include that in the code example. This might also require adjusting all the other indentation to match.

BTW, I still don’t have an automation written to write back to the indicators when another switch makes a change. I just started working on that part.

Okay, I got the switches to sync correctly. So everything pretty much works at this point and I just need to add the automation.

I had just made a type when setting the node_id in the switches as in the code below. It needs to be the node id of the scene controller.

switch:
  - platform: template
    switches:
      button_1_led:
        value_template: "{{ states('sensor.scene_contrl_indicator_2')|int|bitwise_and(1) > 0 }}"
        turn_on:
          service: zwave.set_node_value
          data_template:
            node_id: 10
            value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
            value: "{{ states('sensor.scene_contrl_indicator_2')|int + 1 }}"
        turn_off:
          service: zwave.set_node_value
          data_template:
            node_id: 10
            value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
            value: "{{ states('sensor.scene_contrl_indicator_2')|int - 1 }}"

So here is an example of how I am writing to the indicators within an automation

  action:
    - service: zwave.set_node_value
      data_template:
        node_id: 10
        value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
        value: 8

The value of 8 in binary is 00010, so it will cause indicator 4 to turn on and all others to turn off.

I got my automation working with this. Shared below, in case it is useful to anyone else.

This is triggered by the dummy switches synced to the indicators that the steps in the previous post setup.
What it does:

  1. Pressing any button or switching a switch on the GUI will turn on that indicator, turn off the others, and adjust lights to the programmed levels.
  2. When all the or indicators are off, it will turn on the fifth indicator, which will also cause its routine to run (this is my all lights off state.)

- id: scene_1_on
  alias: scene 1 on
  trigger:
    - platform: state
      entity_id: switch.button_1_led
      to: 'on'
  action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.test_switch_1
    - service: zwave.set_node_value
      data_template:
        node_id: 10
        value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
        value: 1
    - service: light.turn_on
      entity_id: light.allloaddim_level_4
      data_template:
        brightness: 255
    - service: light.turn_on
      entity_id: light.allloaddim_level_5
      data_template:
        brightness: 255
        
- id: scene_2_on
  alias: scene 2 on
  trigger:
    - platform: state
      entity_id: switch.button_2_led
      to: 'on'
  action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.test_switch_2
    - service: zwave.set_node_value
      data_template:
        node_id: 10
        value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
        value: 2
    - service: light.turn_on
      entity_id: light.allloaddim_level_4
      data_template:
        brightness: 180
    - service: light.turn_on
      entity_id: light.allloaddim_level_5
      data_template:
        brightness: 180
        
- id: scene_3_on
  alias: scene 3 on
  trigger:
    - platform: state
      entity_id: switch.button_3_led
      to: 'on'
  action:
    - service: zwave.set_node_value
      data_template:
        node_id: 10
        value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
        value: 4
    - service: light.turn_on
      entity_id: light.allloaddim_level_4
      data_template:
        brightness: 100
    - service: light.turn_on
      entity_id: light.allloaddim_level_5
      data_template:
        brightness: 100

- id: scene_4_on
  alias: scene 4 on
  trigger:
    - platform: state
      entity_id: switch.button_4_led
      to: 'on'
  action:
    - service: zwave.set_node_value
      data_template:
        node_id: 10
        value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
        value: 8
    - service: light.turn_on
      entity_id: light.allloaddim_level_5
      data_template:
        brightness: 100
    - service: light.turn_off
      entity_id: light.allloaddim_level_4

- id: scene_5_on
  alias: scene 5 on
  trigger:
    - platform: state
      entity_id: switch.button_5_led
      to: 'on'
  action:
    - service: zwave.set_node_value
      data_template:
        node_id: 10
        value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
        value: 16
    - service: light.turn_off
      entity_id: light.allloaddim_level_4
    - service: light.turn_off
      entity_id: light.allloaddim_level_5

- id: all_scene_off
  alias: all scene off
  trigger:
    - platform: state
      entity_id: switch.button_1_led
      to: 'off'
    - platform: state
      entity_id: switch.button_2_led
      to: 'off'
    - platform: state
      entity_id: switch.button_3_led
      to: 'off'
    - platform: state
      entity_id: switch.button_4_led
      to: 'off'
    - platform: state
      entity_id: switch.button_5_led
      to: 'off'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: switch.button_1_led
        state: 'off'
      - condition: state
        entity_id: switch.button_2_led
        state: 'off'
      - condition: state
        entity_id: switch.button_3_led
        state: 'off'
      - condition: state
        entity_id: switch.button_4_led
        state: 'off'
      - condition: state
        entity_id: switch.button_5_led
        state: 'off'
  action:
    - service: zwave.set_node_value
      data_template:
        node_id: 10
        value_id: "{{ state_attr('sensor.scene_contrl_indicator_2','value_id') }}"
        value: 16