Monitor the power supply of your home via Home Assistant

If you like it, share it

For monitor the power supply of home, in our case 220Vac we use the Xiaomi Mi Windows and Doors Sensor (ZigBee) (for more info see here) with a little modification of hardware that are shown below.

In practice we use a 5Vcc relay powered by a USB power supply and we connect the contact of it:
in parallel to the magnetic contact present on the Xiaomi Mi Windows and Doors Sensor.
In this way we simulate the magnet that is normally used to understand if a window and/or door is open and/or closed.

If the power supply is present we will have the relay energized and therefore the magnetic contact will be closed so we will signal that the 220Vac is OK.
If there is no power supply the relay will be off and therefore the magnetic contact will be open and we will signal the FAIL of 220Vac.

For more info concerning the way to use Telegram in Home Assistant see this tutorial.

The automation is quite simple, read below.

First create a new automation using the Xiaomi Mi Windows and Doors Sensor (binary_sensor.openclose_16).
The following example is trigger on OPENED which means NO power and send a message (Manca 220Vac) to Tablet and Cellular.
The HTTP API key is the identification of your Telegram bot, for more info see here.

To create the automation in the ACTIONS you must select CALL SERVICE and then go to the YAML editor by clicking on the three vertical dots at the top right and modify the text as shown above.

Do the same for OK 220Vac trigger not_opened, see below.