Deduce the status of a non-home automation appliance with Home Assistant (by electric absorption)

8 minutes of reading
PURPOSES OF PROJET:
  • Use an approdeductive process to determine the operating status of a non-home automation appliance
  • Difficulty level: medium
  • Cost: null (net of the detection sensor)
CONCEPTS FACED:
SOFTWARE COMPONENTS USED:
PHYSICAL DEVICES USED:
PROJET MOST 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.
revision projet: 2.3

Abstract

Electric ovenTraditional appliances - those that do not have a domotic soul - are not excluded a priori from the possibility of "being domotized": the techniques for domotize the non-domotic they are indeed the most disparate. Just think of the air conditioners: in a few simple steps it is possible to make them piousnamedomotic systems although they are not designed to be used in this way.

What is often more difficult to obtain is operating status of a non domotic appliance: returning to the example of air conditioners, it is rather easy to manage them, it is difficult to understand if that command has gone successful or not.

For operating status of the appliance, it goes without saying, it means "what he is doing at a given time"

An electric oven, an iron they possess substantially two operational states: that "of heating"And that"of inactivity“, Obviously interspersed with the automatic action of a thermostat; also a washing machine owns two states - that "of washing"And that"of inactivity"- but in reality it has a much wider range of details:" 'water load","water heating","washing","rinse","drain water”Just to list the main ones.

Washing machineSame thing for air conditioners / air conditioners: they can obviously be "lit"Or"extinguished", But their many features and modes clearly express themselves in a wide variety of different operational states.

Know the operating status of an appliance is useful (if not necessary) to equip the prohis personal domotics of further "senses" for the purposes of notification, automation (for example, if the power supply to the appliance is removed / not removed in the event of the tenants leaving the environment), monitoring.

Home Assistant, through profirst model a entity, allows us to define virtual sensors which take on an (arbitrary) status rather than another starting fromabsorption analysis of the appliance itself. In fact, every appliance absorbs electricity: the way it does it can help us understand what the appliance is doing at a given moment.

What we need

ITEAD Sonoff POW R2
Sonoff POW.

Simple: first we need a sensor which detects the amount of electrical absorption measured immediately upstream of the appliance and that it is present downstream alone the appliance to be monitored. This is because any other users connected downstream of the sensor would confuse the measurements, which would be for theappanointed distorted.

Secondly it is important as such a sensor is integrated with Home Assistant, who appreceives the measurements and, through them, conditions the status of one or more virtual sensors defined in the configuration.

Sensorthere are many; we suggest the adoption of Sonoff POW R2 with firmware Tasmota, sensor for which we spent a dedicated ad hoc guide to the integration at Home Assistant profor the purpose of collecting information on electricity absorption. However, there are other alternatives, such as intelligent plugs with absorption detection (eg. FIBARO) or more complex units (Aeotec Home Energy Meter).

For the rest of the present projet will take for granted that the sensors Home Assistant to which reference will be made are powered by data collected from physical elements connected as explained above and therefore already integrated to theHUB personal.

Analysis

OPERATING STATE ON / OFF

The theory tells us that an appliance off absorb 0 Watt. Logic tells us, therefore, that any reading greater than 0 corresponds to a state on - operational.

This statement is correct, albeit purely theoretical. All sappIn fact, we say that appliances that are turned off but connected to the electricity network are often rappresent a consumption, albeit minimal. A modern TV, in standby, it can also absorb 1-2 Watts (if not more), absorption that appapplied to the above statement would consider it wrongly turned on. Another important parameter is the resolution of the data of absorption: a precise reading to the tenth of a Watt could be even more accurate in helping us to understand the absorption model linked to the appliance in question.

The first thing to do, therefore, is to check "in a waiting state" (standby) how much the appliance absorbs, so as to have a minimum value to be taken as a reference value for the state "off". Any value greater than the minimum value will therefore be attributed to the state "on - operational"

This approccio it is the most basic and is usually used to make virtual binary sensors, which they own appunto a simple on / off status.
Later we will see how to do it.

DETAILED OPERATING STATE

Obtaining detailed operating status data it is the more complex the behavioral variability is of the appliance itself e from the degree of detail you want to get.

The first thing to do is to observe the behavior of the appliance during a complete use cycle, which is the appliance, which one it is use and its duration. In this we are helped by the historian of Home Assistant: during and after the execution of the cycle it will be possible to understand if the various phases of the appliance operation provide or not a "model" evidence in the absorption graph.

Home Assistant Sonoff POW Washing machine - Watts
Example of absorption graph at the frontend of Home Assistant

If a washing machine it absorbs, say, an average value of 1500 Watts in the first half hour of washing (due to the heating of the water, which is a proparticularly energy-intensive process), an average of 300 Watts in the second half (washing) and 150 Watts last (rinse), then we will be able to define three different detailed operational states related to this appliance. This model is reconstructed, apptogether, from empirical analysis of the absorption graph at Home Assistant, which helps us understand the behavior of the appliance.

It goes without saying that an appliance with a "behavior" tends to tend very variableunfortunately, this task does not help us.

How to create sensors

Assumptions

In this projet we assume to have available - as explained above - an entity sensor that provides instant absorption (in Watts) upstream of a specific appliance. We will call him sensor.power.

Sensorand on / off

Since the operational status is rappresent of base by two possible conditions (on / off - 1 / 0) we will use a "Binary template Sensor"To define an entity that appanointed rappautomatically resets the state of the appliance starting from the instant absorption data supplied by sensor.power.

In configuration we will add:

binary_sensor:
  - platform: template
    sensors:
      stato_operativo_elettrodomestico:
        friendly_name: "Stato Operativo Elettrodomestico"
        value_template: "{{ states('sensor.power')|int > 0 }}"
        device_class: power
        delay_on:
          seconds: 30
        delay_off:
          minutes: 2

The meaning is simple: the sensor enters the state on ("On") when the value of sensor.power exceeds the 0; vice versa, go back up off ("Off") when the value drops to 0.

Some considerations:

  • since many modern appliances have a minimum absorption value (few Watts) even when substantially inactive (standby), it may be necessary to adjust the "0" at a slightly higher value, to be evaluated from case to case;
  • some modern appliances when they come activated (although not yet fully operational, see a washing machine with digital control panel on which to set i programs) They tend to proreduce consumption peaks (various Watts) lasting just a few moments. To prevent domotics from interpreting that absorption value> 0 (or greater than the value set on the basis of the first consideration) as full operation, a delay_on, or a value in seconds that the threshold exceeded value be kept stable to consider the sensor actually "on"(" On ");
  • similarly, during the actual period of operation of the appliance there may be moments of suspension appno activity (eg an iron that turns on / off the prointernal resistance): to avoid bad interpretations a delay_off in seconds, period in which an absorption value = 0 (or in any case less than the value set based on the first consideration) be kept stable to consider the sensor actually "off"(" Off ").

A binary state sensor is already, in itself, something very useful.

DETAIL SENSOR

Since the operational status detailed of the appliance is rappresentato from many possible, different conditions, we will use a "template Sensor"To define an entity that appanointed rappautomatically resists the state of the appliance starting from the absorption model obtained through the empirical observation of sensor.power.

Let's say we have a washing machine that works as follows:

  • tot minutes of water heating, with an average consumption of 1500 Watts;
  • total washing minutes, with an average consumption of 400 Watts;
  • total minutes of rinsing, with an average consumption of 150 Watts.

We will create, first of all, three binary sensors:

binary_sensor:
  - platform: template
    sensors:
      riscaldamento_lavatrice:
        value_template: {{ states('sensor.power')|int > 1500 }}
        delay_on:
          minutes: 2
        delay_off:
          minutes: 2
      lavaggio_lavatrice:
        value_template: {{ states('sensor.power')|int < 1500 and states('sensor.power')|int > 400 }}
        delay_on:
          minutes: 2
        delay_off:
          minutes: 2
      risciacquo_lavatrice:
        value_template: {{ states('sensor.power')|int < 400 and states('sensor.power')|int > 0 }}
        delay_on:
          minutes: 2
        delay_off:
          minutes: 2

These three sensors:

  • binary_sensor.riscaldamento_lavatrice
  • binary_sensor.lavaggio_lavatrice
  • binary_sensor.risciacquo_lavatrice

provvederanno to change status automatically ("on"/"off“) Based on the absorption ranges in Watts (previously observed in the consumption model) and on the basis of delay set in configuration.

Now we will define a "template Sensor"Which we will use as"collector"Of the states of the three"Binary Sensor"Previously defined:

sensor:
  - platform: template
    sensors:
      stato_operativo_lavatrice:
        friendly_name: "Stato Operativo Lavatrice"
        value_template: >-
          {% if is_state('binary_sensor.riscaldamento_lavatrice', 'on') %}
          Riscaldamento
          {% elif is_state('binary_sensor.lavaggio_lavatrice', 'on') %}
          Lavaggio
          {% elif is_state('binary_sensor.risciacquo_lavatrice', 'on') %}
          Risciacquo
          {% else %}
          Ciclo terminato
          {% endif %}

At this point we will have a sensor ("sensor.stato_operativo_lavatrice") Which will provide us, in real time, with the progress of the washing machine:

  • Heating
  • Washing
  • Rinse
  • Cycle completed

Obviously the above example can be valid also for many other scenarios, for example fan heaters (bathroom and not), electric water heaters, ovens, conditioners etc. It will be enough define the model, its states, sensors and nothing else.

EXAMPLE AT THE FRONTEND

An example of rappgraphic representation of previously declared sensors:

Home Assistant - Absorption indicators

Automation

At this point, as we are equipped with capable sensors to detect the operational status (simple and / or detailed) of the non-domotic appliance, in addition to consulting the states and trends over time we can prosee how to use them as trigger, condizioni and / or object of actions in ours automations.

Simple change of status

An example is to make sure to be alerted at the state change (from “on” a “off"And vice versa - or other) of the appliance.

In the automation that follows, the simple state of the appliance (surveyed through "binary_sensor.stato_operativo_elettrodomestico") Is the trigger (trigger) of an automation that prosees to alert a user through a notification Pushbullet conveyed through an entity called "notify.marco"

- alias: "Notifica per cambio di stato"
  trigger:
    platform: state
    entity_id: binary_sensor.stato_operativo_elettrodomestico
  condition: []
  action:
     service: notify.marco
     data_template:
       title: "Elettrodomestico"
       message: "L'elettrodomestico è passato da {{ trigger.from_state.state }} a {{ trigger.to_state.state }}"
More complex scenarios

Prolet us imagine having recorded a washing machine (simple state)on"/"off") And let us also imagine having domotized the influx of water in house rappresenting it with a called switch switch.acqua.

We also assume that you have defined a scene that is automatically executed when everyone leaves home (via one or more entities)Device Tracker"And related automation) and that provveda to automatically shut off the water setting to "off”This switch.

scene:
- name: Uscita di casa
  entities:
    switch.acqua: off

Obviously we would not like this automatic behavior in case let's leave the washing machine to work in our absence, because we would have the obvious need for leave the flow of water on.

At this point we would define one script as follows:

script:
  uscita_di_casa_sequence:
    sequence:
      - condition: state
        entity_id: binary_sensor.stato_operativo_elettrodomestico
        state: 'off'
      - service: switch.turn_off
        entity_id: switch.acqua

e We would modify the scene as follows:

scene:
- name: Uscita di casa
  entities:
    script.uscita_di_casa_sequence: on

So doing the scene "scene.uscita_di_casa"He would do so to trigger the script "script.uscita_di_casa_sequence", which would evaluate the status of the washing machine (through"binary_sensor.stato_operativo_elettrodomestico") is, alone in case it was "off" (then "non-operational washing machine'), prohe would close the water by setting to "off"The switch"switch.acqua"

Notice how "binary_sensor.stato_operativo_elettrodomestico"Is used, in this scenario, as a condition to evaluate a consequent action.

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.



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.


telegram

Stay up to date through ours Telegram channel!