Hello,
I’ve been trying to define a template sensor to tell me what is wrong with my house. Although i tried to have the best & most reliable equipment in it (Victron & Fronius for power management, Shelly for power measurement, Cisco & TPLink for networking, Aquara for lightswitching, etc), sometimes i get wrong notifications for “power down”/“power back online” when the network’s DHCP server hangs or router rebooting.
So, i though i should add a template sensor with dynamic evaluation of the status: if i only lose access to Fronius SMartmeter, then it’s a power issue, if i can no longer contact the smartmeter and 1-2 more network devices then it’s a network issue…
With the samples i found i came up to the following code:
Issue with
{%- if not is_state('sensor.smart_meter_ts_65a_3_current_phase_1','unavailable') and not is_state('sensor.smart_meter_ts_65a_3_current_phase_2','unavailable') and not is_state('sensor.smart_meter_ts_65a_3_current_phase_3','unavailable') and not is_state('sensor.shelly_3em_pro_mains_phase_a_current','unavailable')
-%}
{{' '+'nothing - all good'}}
{%- elif is_state('sensor.smart_meter_ts_65a_3_current_phase_1','unavailable') and is_state('sensor.smart_meter_ts_65a_3_current_phase_2','unavailable') and is_state('sensor.smart_meter_ts_65a_3_current_phase_3','unavailable') and is_state('sensor.shelly_3em_pro_mains_phase_a_current','unavailable')
-%}
{{' '+'Network'}}
{%- else -%}
{{' '+'Power'}}
{%- endif -%}
This seems to provide me with “Issue with Power” and “Issue with Network” and “Issue with nothing - all good”, which looks ok-ish as a starting point.
However, i would like to do the following and i don’t know how:
- define a list/map of devices to monitor
- loop through the list and if all are ‘unknown’, then it’s a network issue, otherwise a power issue, and of course if all are reachable, it’s normal status.
Can someone point me out to where i could find such code to get inspired with?
Thanks,
Gabriel