I have a Z-Wave light switch and there are various configuration parameters on the switch that I have automations to change as needed. I want to be able to read the current value of one of the parameters. Here’s an example of some YAML in my automations.yaml to write the value, but I have no way to actually read the value:
action:
- service: zwave_js.set_value
data:
value: 55
endpoint: "0"
property: "32"
command_class: "112"
Does anyone know how I could read this value periodically and put it into a template sensor or similar?
Thanks
I kind of answered my own question here. The solution is to use Z-Wave JS UI. Under Settings you have to uncheck the “Disable MQTT Gateway” option which then allows you to connect it to your MQTT instance (you can use Mosquitto which you’re probably already using in HA anyway).
Then the challenge becomes finding the right channel for what value you want to read. I went into the Mosquitto integration configuration and listened to the “zwave#” topic to see everything that was being sent over. In my case the topic was zwave/8/112/0/32 for the sensor I wanted to read.
My final code ended up looking like this (this would be added in configuration.yaml alongside your other MQTT sensors if you have them):
mqtt:
sensor:
- name: "Office Default Brightness"
state_topic: "zwave/8/112/0/32"
unit_of_measurement: "%"
value_template: "{{ value_json.value | int }}"
Then you would read the value the same way you’d read from any sensor. Here’s a segment of my automation which reads the value and sets brightness accordingly:
action:
- service: light.turn_on
data:
brightness_pct: "{{ states(\"sensor.office_default_brightness\") }}"
target:
entity_id: light.office_lights
1 Like