I have a binary sensor, which depends on 2 other sensor values. In effect I am trying to detect area outages (which are not due to Loadshedding - yes, I am in South Africa). The first sensor it depends on, is one read from an inverter, which tells me that it is seeing the mains from the utility company. The second is from an integration which works with the Loadshedding schedule, and simply tells me that Loadshedding is currently being applied in our area. So this custom binary sensor should be True when the Loadshedding is Off, and the Inverterâs Utility sensor is also Off.
So the code I have is as follows:
- binary_sensor:
- name: Area Outage Detected
unique_id: binary_sensor.area_outage_detected
delay_on: "0:05:00"
state: >
{% set ls = is_state('sensor.load_shedding_in_my_area', 'On') %}
{% set gs = is_state('sensor.inverter_grid_connected_status', 'On-Grid') %}
{% if ls or gs %}
{{ 'no' }}
{% else %}
{{ 'yes' }}
{% endif %}
This part mostly works, but it triggers when the Loadshedding is being applied in my area, as well as when the grid down (for an area outage). This result is false positives.
This sensor is used in a notifier script, where it will notify us, when it is an area outage in stead of just loadshedding (where power will be back within about 2 hours or 4 hours if we are at high stages). The idea being that we can prepare for situations where we will be without power for extended periods of time (and thus ensure we reduce our load on the inverter batteries).
Area outages are currently rare, but have happened a couple of times in the past few months. The strain being put on the grid infrastructure by the constant loadshedding have caused various substations to explode or catch fire (resulting in no power for weeks in affected areas). I want to get early notification in such a case.
Any help will be greatly appreciated.