Integrate the electric absorption readings of Sonoff POW up Home Assistant

4 minutes of reading
AIMS OF THE GUIDE
CONCEPTS FACED:
  • Software installation and configuration
SOFTWARE COMPONENTS USED:
Prerequisites
  • Un Sonoff POW updated to firmware Sonoff-Tasmota (or alternative firmware that offers MQTT readings)
  • Home Assistant configured and working
  • MQTT Broker configured and working (eg mosquitto, or the broker included with Home Assistant)
  • Components Home Assistant "MQTT"Configured and working
PHYSICAL DEVICES USED:
GUIDE more indicated for:

All environments

Notes and disclaimer
  • qualsiasi eventuale modifica agli impianti domestici dev'essere progettata ed realizzata SOLO da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.

Abstract

Home Assistant provides native support al proMQTT tocollo through a called component, for theappanointed, "MQTT". If you have an electric absorption sensor equipped with such support proProtocol (eg. a Sonoff POW riproprogrammed Sonoff-Tasmota), it is possible to integrate the metrics in a very simple way on Home Assistant.

The possibility of acquiring sensors of this type allows, on the one hand, users, to check the progress of the absorption indicator of specific (or groups of) household appliances in particular electricity users, on the other, to home automation, to intervene automatically in the event of abnormal situations (for example, disconnecting an appliance to prevent an automatic disconnection from the grid in the event of excessive load).

In this guide we will see how to configure these sensors starting from the component "Sensor"Of Home Assistant, specifically the platform (sub-component) “MQTT Sensor"

Installation

No need to install anything: just add to the configuration of Home Assistant the entry for the sensor / sensors you want to add.

Nb To use this platform it is necessary that the "MQTT" component of Home Assistant has been previously configured (see first part of the card dedicated to the "MQTT" component). We also recommend to read carefully the guide dedicated to the theme of configuration of the MQTT components in the profirst home automation.

POW Readings

Il Sonoff POW is an intelligent switch with the capacity to provide various metrics, Especially the R2 version. As anticipated, the implementation of the signing Sonoff-Tasmota frees it from the factory ecosystem and makes it compatible with the proMQTT tocol through which, once configured, properiodically produces (every few seconds, adjustable) of the telemetry in notation JSON full of interesting data.

A classic payload JSON procoming from a POW riproprogrammed Tasmota is the following:

tele/pow1/SENSOR = {"Time":"2018-02-15T17:37:10","ENERGY":{"TotalStartTime":"2018-11-14T18:39:40","Total":6.294,"Yesterday":5.340,"Today":0.954,"Period":217,"Power":2635,"ApparentPower":2650,"ReactivePower":282,"Factor":0.99,"Voltage":227,"Current":11.661}}

The fields are explained as follows:

FieldUnitDescription
TotalStartTimeDateUpdate datenamefor the total absorption "Total"
TotalkWhEnergy absorbed total
YesterdaykWhEnergy absorbed on the previous day in the range 00: 00 - 23: 59
TodaykWhEnergy absorbed on the current day
PeriodkWhEnergy absorbed starting from the previous reading
PowerWInstant absorption
ApparentPowerWVolt-Amps
ReactivePowerWReactive voltampere
FactorPower factor
VoltageVPotential difference in volts currently delivered (voltage)
CurrentACurrent intensity in ampere currently delivered (amperage)

Nb not all of the metrics shown are available using the template Sonoff POW R1.

Configuration

There are many metrics, so many can be the sensors configurable at Home Assistant.
In a single block, let's see how to configure 11 entity of "sensor" type.

Nb We will assume that the POW MQTT name is "SonoffPOW"And that, of course, is correctly configured (under the menu item" Configuration ">" Configure Module ") at the interface of Sonoff-Tasmota.

sensor:
  - platform: mqtt
    name: "Data aggiornamento"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].TotalStartTime }}"
    qos: 1
    unit_of_measurement : "Date"

  - platform: mqtt
    name: "Assorbimento TOTALE"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].Total }}"
    qos: 1
    unit_of_measurement : "kWh"

  - platform: mqtt
    name: "Assorbimento ieri"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].Yesterday }}"
    qos: 1
    unit_of_measurement : "kWh"

  - platform: mqtt
    name: "Assorbimento oggi"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].Today }}"
    unit_of_measurement: "kWh"

  - platform: mqtt
    name: "Assorbimento da ultima lettura"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].Period }}"
    unit_of_measurement: "kWh"

  - platform: mqtt
    name: "Assorbimento istantaneo"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].Power }}"
    unit_of_measurement: "Watt"

  - platform: mqtt
    name: "Voltampere"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].ApparentPower }}"
    unit_of_measurement: "Watt"

  - platform: mqtt
    name: "Voltampere reattivo"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].ReactivePower }}"
    unit_of_measurement: "Watt"

  - platform: mqtt
    name: "Voltaggio"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].Voltage }}"
    unit_of_measurement: "Volt"

  - platform: mqtt
    name: "Amperaggio"
    state_topic: "tele/SonoffPOW/SENSOR"
    value_template: "{{value_json['ENERGY'].Current }}"
    unit_of_measurement: "Ampere"

This configuration will generate, as explained, eleven different ones entity of "sensor" type:

  • sensor.data_aggiornamento
  • sensor.assorbimento_totale
  • sensor.assorbimento_ieri
  • sensor.assorbimento_oggi
  • sensor.assorbimento_da_ultima_lettura
  • sensor.assorbimento_istantaneo
  • sensor.voltampere
  • sensor.voltampere_reattivo
  • sensor.voltaggio
  • sensor.amperaggio

which can be used either as an instant and historical reading, as well as in automations more disparate.

Examples at the fronted

Home Assistant Sonoff POW Washing Machine - Ampere
Absorption expressed in Ampere (Current)
Home Assistant Sonoff POW Washing machine - Watts
Absorption expressed in Watts

Final note

Often the electric absorption sensors produce large amounts of data. This happens because this measurement is extremely variable over time; this, unfortunately, often causes proproblems with home automation Home Assistant which, by default, saves any input data; this data hypertrophy is also often a direct consequence of the breakdown of the microSD on which theHUB is installed. To avoid all this we always recommend referring to this guide to significantly reduce the amount of data saved.


Configure consumption meter on Home Assistant


Electrical absorption under control via home automation Home Assistant


Home Assistant Official LogoATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Home Assistant, for any doubt, question, information on the specific merit of these components.

inDomus telegram channel