HA1974
(NNo)
May 25, 2022, 9:48pm
1
I have 4 fibaro motion sensor, which are battery powered and its status is not (correct)updated
I used zwave JS to read it status
I try Z-Wave JS: Refresh value(s) in an automation but often it is still 100%. And after some time teh automation where these sensors is in not working correctly anymore
So i want to check if the sensor is still sending updates
like :sensor.last_update
but how can i check this in an automation . and send a warning that a sensor is not updated anymore or update sensor is > 2h ?
For battery powered devices I use this package. It is based on the device wake-up interval.
# multisensor_1
# ENTITY_ID to monitor
# TIMEOUT
input_boolean:
zwave_multisensor_1_alarm_enable:
template:
- trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: sensor.multisensor_1_node_status
to: awake
sensor:
- name: "multisensor_1_last_updated"
state: "{{ now() }} "
sensor:
- platform: template
sensors:
zwave_multisensor_1_latency:
unit_of_measurement: secs
value_template: >-
{%- if as_timestamp(states("sensor.multisensor_1_last_updated"),0) == 0 %}
0
{%- else %}
{{ ((as_timestamp(now(), 0) | int(0)) - as_timestamp(states('sensor.multisensor_1_last_updated'),0) | int(0)) }}
{%- endif %}
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
- sensor.multisensor_1_node_status
- input_boolean.zwave_multisensor_1_alarm_enable
- alert.zwave_multisensor_1
- sensor.zwave_multisensor_1_latency
I also have this variant that is based on getting a value update. This only works for things that periodically send data (like a temperature sensor), since motion sensors only send data on motion this approach does not work.
Note you’ll need to replace ENTITY_ID, COMMAND_CLASS, PROPERTY_NAME, and TIMEOUT
# multisensor_1
# ENTITY_ID to monitor
# TIMEOUT
input_boolean:
zwave_multisensor_1_alarm_enable:
template:
- trigger:
- platform: homeassistant
event: start
- 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: >-
{%- if as_timestamp(states("sensor.multisensor_1_last_updated"),0) == 0 %}
0
{%- else %}
{{ ((as_timestamp(now(), 0) | int(0)) - as_timestamp(states('sensor.multisensor_1_last_updated'),0) | int(0)) }}
{%- endif %}
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
- sensor.multisensor_1_node_status
- input_boolean.zwave_multisensor_1_alarm_enable
- alert.zwave_multisensor_1
- sensor.zwave_multisensor_1_latency
HA1974
(NNo)
May 28, 2022, 7:39am
3
Hi @PeteRage
thx for your code
My motion fibaro sensors are actually every 4 in one sensors , light, temperature, motion and fibation
So every 5 min the sensor sends data for the LUX value ( so lamps can be turned on/off)
This means the motion sensors are awake. But not sending data, like battery level every 5 min. i have to check now many times it check that normally ( now have an automation refresh value)
But i wil check you code , maybe i can use it also
greetz