Thanks that was the ticket! Would be nice to have a table of those CC_IDs :-).
Here’s the full solution:
# sensor_2
# sensor.sensor_2_temperature to monitor
# 480
input_boolean:
zwave_sensor_2_alarm_enable:
template:
- trigger:
- platform: zwave_js.value_updated
entity_id:
- sensor.sensor_2_temperature
command_class: 49
property: Air temperature
sensor:
- name: "sensor_2_last_updated"
state: "{{ now() }} "
sensor:
- platform: template
sensors:
zwave_sensor_2_latency:
unit_of_measurement: secs
value_template: "{{ ((as_timestamp(now(), 0) | int(0)) - as_timestamp(states('sensor.sensor_2_last_updated'),0) | int(0)) }}"
availability_template: "{{ as_timestamp(states.sensor.sensor_2_temperature.last_updated,0) | int(0) > 0 }}"
binary_sensor:
- platform: template
sensors:
zwave_sensor_2_online:
value_template: >-
{{ ( 480 - (states('sensor.zwave_sensor_2_latency') | int(0))) > 0 and
states('sensor.sensor_2_node_status') != 'dead' and
states('sensor.sensor_2_node_status') != 'unavailable' and
states('sensor.sensor_2_node_status') != 'unknown'
}}
zwave_sensor_2_alert:
value_template: '{{ is_state("binary_sensor.zwave_sensor_2_online", "on") and is_state("input_boolean.zwave_sensor_2_alarm_enable", "on") }}'
alert:
zwave_sensor_2:
name: zwave sensor_2 alert
message: '{{ state_attr("zone.home","friendly_name") }} zwave sensor_2 offline - Latency: {{ states("sensor.zwave_sensor_2_latency") }} Node {{ states("sensor.zwave_sensor_2_node_status") }}'
done_message: '{{ state_attr("zone.home","friendly_name") }} zwave sensor_2 online'
entity_id: binary_sensor.zwave_sensor_2_alert
state: "on"
repeat: 240
can_acknowledge: true
skip_first: false
notifiers:
- sms_notifiers_all
recorder:
include:
entities:
- binary_sensor.zwave_sensor_2_online
- binary_sensor.zwave_sensor_2_alert
- zwave.sensor_2_node_status
- input_boolean.zwave_sensor_2_alarm_enable
- alert.zwave_sensor_2
Since I have more than one device I do this for, I created a parameretized package
# multisensor_1
# ENTITY_ID to monitor
# TIMEOUT
input_boolean:
zwave_multisensor_1_alarm_enable:
template:
- trigger:
- platform: zwave_js.value_updated
entity_id:
- ENTITY_ID
command_class: COMMAND_CLASS
property: PROPERTY_NAME
sensor:
- name: "multisensor_1_last_updated"
state: "{{ now() }} "
sensor:
- platform: template
sensors:
zwave_multisensor_1_latency:
unit_of_measurement: secs
value_template: "{{ ((as_timestamp(now(), 0) | int(0)) - as_timestamp(states('sensor.multisensor_1_last_updated'),0) | int(0)) }}"
availability_template: "{{ as_timestamp(states.ENTITY_ID.last_updated,0) | int(0) > 0 }}"
binary_sensor:
- platform: template
sensors:
zwave_multisensor_1_online:
value_template: >-
{{ ( TIMEOUT - (states('sensor.zwave_multisensor_1_latency') | int(0))) > 0 and
states('sensor.multisensor_1_node_status') != 'dead' and
states('sensor.multisensor_1_node_status') != 'unavailable' and
states('sensor.multisensor_1_node_status') != 'unknown'
}}
zwave_multisensor_1_alert:
value_template: '{{ is_state("binary_sensor.zwave_multisensor_1_online", "on") and is_state("input_boolean.zwave_multisensor_1_alarm_enable", "on") }}'
alert:
zwave_multisensor_1:
name: zwave multisensor_1 alert
message: '{{ state_attr("zone.home","friendly_name") }} zwave multisensor_1 offline - Latency: {{ states("sensor.zwave_multisensor_1_latency") }} Node {{ states("sensor.zwave_multisensor_1_node_status") }}'
done_message: '{{ state_attr("zone.home","friendly_name") }} zwave multisensor_1 online'
entity_id: binary_sensor.zwave_multisensor_1_alert
state: "on"
repeat: 240
can_acknowledge: true
skip_first: false
notifiers:
- sms_notifiers_all
recorder:
include:
entities:
- binary_sensor.zwave_multisensor_1_online
- binary_sensor.zwave_multisensor_1_alert
- zwave.multisensor_1_node_status
- input_boolean.zwave_multisensor_1_alarm_enable
- alert.zwave_multisensor_1
Then blast out the configuration
TARGET="/mnt/c/github/ha_house2"
zwave_js_health_template()
# ZWAVE Entity
# ENTITY_ID to monitor
# TIMEOUT
# COMMAND_CLASS
# PROPERTY_NAME
# Output file
{
sed "s/multisensor_1/$1/g" zwave_js_health_template_multisensor_1_package.yaml |
sed "s/ENTITY_ID/$2/g" | sed "s/TIMEOUT/$3/g" | sed "s/COMMAND_CLASS/$4/g" | sed "s/PROPERTY_NAME/$5/g"> $TARGET/packages/$6
}
zwave_js_health_template sensor_2 sensor.sensor_2_temperature 480 49 "Air temperature" zwave_js_health_template_sensor_2_package.yaml
zwave_js_health_template entrance sensor.entrance_temperature 600 49 "Air temperature" zwave_js_health_template_entrance_package.yaml
zwave_js_health_template basement sensor.basement_temperature 480 49 "Air temperature" zwave_js_health_template_basement_package.yaml
zwave_js_health_template garage_sensor sensor.garage_temperature 600 49 "Air temperature" zwave_js_health_template_garage_sensor_package.yaml
zwave_js_health_template upstairs_thermostat climate.upstairs_thermostat 1200 49 "Air temperature" zwave_js_health_template_upstairs_thermostat_package.yaml
zwave_js_health_template switch_2 switch.switch_2_switch 1200 37 currentValue zwave_js_health_template_switch_2_package.yaml
zwave_js_health_template outdoor_switch switch.outdoor_switch 1200 37 currentValue zwave_js_health_template_outdoor_switch_package.yaml
zwave_js_health_template hotwater_heater switch.hotwater_heater_switch 1200 37 currentValue zwave_js_health_template_hotwater_heater_switch_package.yaml
zwave_js_health_template loft_fan_1 fan.loft_fan_1_level 1200 38 currentValue zwave_js_health_template_loft_fan_1_package.yaml
zwave_js_health_template loft_fan_2 fan.loft_fan_2_level 1200 38 currentValue zwave_js_health_template_loft_fan_2_package.yaml
I still have some other devices that I need to discover the command_class and property_names for.
For devices that don’t report periodically (like switch states) I run automatons like this
- id: "loft_fan_2 poll switch state"
alias: loft_fan_2 poll switch state
description: "Automation to periodically poll switches"
trigger:
- platform: time_pattern
minutes: "/10"
- platform: homeassistant
event: start
action:
- service: zwave_js.refresh_value
data:
entity_id: fan.loft_fan_2_level
So I poll it every 10 minute and generate an alert if no switch state is received in 20 minutes.