Zigbee became very unreliable for me lately. All my zigbee light switches have neutral wires so technically they should all be routers, I have a few IKEA tradfri outlet controls around to act as repeaters etc and despite all this every day some (random) lights become unavailable.
Most light switch modules are alibaba stuff but for some reason I couldn’t find two way / dimmer / >1 gang modules produced by known brands. I expect a significant WAF warning very soon.
I made an easy check for battery powered zigbee devices (these are more critical as they’re water leak sensors etc):
alias: Catch unavailable sensors
description: ""
trigger:
- platform: template
value_template: >-
{{
(expand(state_attr('binary_sensor.all_battery_sensors','entity_id'))|selectattr('state','in',
['unavailable', 'unknown', 'none'])|list | count) > 0 }}
- platform: time
at: "09:00:00"
- platform: time
at: "18:00:00"
condition: []
action:
- variables:
v_trigger_sensor_entity: |
{{ expand(state_attr('binary_sensor.all_battery_sensors','entity_id'))
|selectattr('state', 'in', ['unavailable', 'unknown', 'none'])
|map(attribute='entity_id') }}
v_trigger_sensor_name: |
{{ expand(state_attr('binary_sensor.all_battery_sensors','entity_id'))
|selectattr('state', 'in', ['unavailable', 'unknown', 'none'])
|map(attribute='name')
|join('\n') }}
- if:
- condition: template
value_template: >-
{{
(expand(state_attr('binary_sensor.all_battery_sensors','entity_id'))|selectattr('state',
'in', ['unavailable', 'unknown', 'none'])|list | count) > 0 }}
then:
- device_id: XXX
domain: mobile_app
type: notify
message: {{ v_trigger_sensor_name }} are unavailable, please check!
title: Unavailable devices
enabled: true
- service: button.press
target:
entity_id: "{{ v_trigger_sensor_entity }}"
else:
- device_id: XXX
domain: mobile_app
type: notify
message: All battery sensors are available, high five!
title: No unavailable devices
enabled: true
mode: single
all_battery_sensors is a binary sensor group. I make a cheeky attempt at a button.press when I catch an unavailable sensor but it never worked so far.
Sadly, this approach won’t work with a lot of the zigbee light problems as they are almost always available (at least seemingly available) but when they are turned on / off by HA they don’t obey to the order.
Before I jump into scripting, are there any solutions out there for this already? Solution is ideally to automatically fix but that’s probably too aggressive, even catching the problematic devices and notifying me is a big step.
I’m hoping I am not the only one facing this challenge