Automatically clean your home when you exit through home automation Home Assistant

4 minutes of reading
PURPOSES OF PROJET:
  • Define an automatism that starts the cleaning of the house against the abandonment of the environment by the tenants
  • Difficulty level: bass
  • Cost: did
CONCEPTS FACED:
SOFTWARE COMPONENTS USED:
PHYSICAL DEVICES USED:
PROJET MOST INDICATED FOR:

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere progettata ed effettuata 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: 1.0

Abstract

The idea of ​​a home that cleans itself it has always been an unattainable chimera, the dream proI hope to win once and for all the eternal war of man against domestic dirt. We say it immediately: this projet has no presumption of resolving the matter definitively, but rather that of winning a battle of this war.

Every day i robot vacuum cleaner more our houses: reliable, now not too expensive, they are appliances that allow you to keep the floors as clean as possible. On the other hand, they need to be put into operation while at home, with consequent annoyance (one must be careful not to trip over them and tolerate the noise) or be temporally planned (the models that support it, and in any case the planning can sometimes be inadequate to prohabits).

It wouldn't be nice if, when the whole family left the house, the robot left automatically?

In this prowe will see how the users introduced Home Assistant which proprio personale HUB for the profirst domotics and having a robot vacuum cleaner can realize aautomation such as to allow this type of automatism.

assumptions

In order to realize the present prosubstantially, it is necessary to do so integration by the profirst robot vacuum cleaner col proprio Home Assistant. For this purpose, the roads are essentially two:

iLife V5s Robot Vacuum Cleaner

In practice, something that is easily accomplished in 99,99% of cases. For the present procast, we assume the presence of an entity rappshowing the successful integration of the robot vacuum cleaner called "vacuum.robot_aspirapolvere", Regardless of the chosen integration platform. This entity will be indirect child of the component "Vacuum“, Therefore we will use the control services connected to it.
Di robot vacuum cleaner there are now plenty of them.

Second distinctive element of the present procast, the need to use entity of type "Device Tracker”To determine the presence / absence of tenants in the home. For the present prowe will assume the existence in configuration of the entity "group.famiglia”Deriving from the grouping of these entities. A Pprofoundation on this specific theme is available here.

Finally: we will define the automation of "automatic cleaning" so that it is executed only when "sufficient time" has passed since the last automatic cleaning.

Duration of the break

Let's start by defining a sensor that measures how long the vacuum cleaner has stopped in profirst charging dock, then paused, using the status "docked"Of the corresponding entity"vacuum.robot_aspirapolvere"

To do this we will use the platform "History Statistics Sensor"Daughter of the component"Sensor". We add in configuration the following code:

sensor:
  - platform: history_stats
    name: Durata ciclo aspirapolvere
    entity_id: vacuum.robot_aspirapolvere
    state: 'docked'
    type: ratio
    end: '{{ now() }}'
    duration:
      hours: 12

The resulting sensor entity ("sensor.durata_ciclo_aspirapolvere") Monitors the status"docked"Of the entity"vacuum.robot_aspirapolvere". This sensor indicates as 12 the hours of time taken in analysis and compares it with the time spent by the entity "vacuum.robot_aspirapolvere"In state"docked". When the sensor reports 100%, this value indicates that (at least) 12 hours have passed in the state “docked"

Cleaning and return script

At this point we define two script:

  • one who starts to the cleaning;
  • one that the terms - if in progress - and send the robot to profirst charging station.

The first will be used later in the block action dell 'automation which is performed when you leave the house, the second in the block action of the one performed when returning (if we return home while the robot is cleaning, we want to stop automatically):

script:
  vacuum_on:
    sequence:
      - condition: state
        entity_id: vacuum.robot_aspirapolvere
        state: 'docked'
      - condition: numeric_state
        entity_id: sensor.durata_ciclo_aspirapolvere
        above: 90
      - service: vacuum.clean
        entity_id: vacuum.robot_aspirapolvere
  vacuum_to_dock:
    sequence:
      - condition: state
        entity_id: vacuum.robot_aspirapolvere
        state: 'cleaning'
      - service: vacuum.stop
        entity_id: vacuum.robot_aspirapolvere
      - service: vacuum.return_to_base
        entity_id: vacuum.robot_aspirapolvere

The first script ("script.vacuum_on“) Checks in sequence that the robot appears in the profirst dock and then that the pause duration is higher than the 90% (using the sensor status “sensor.durata_ciclo_aspirapolvere"Previously defined): if the two conditions are exceeded, the service is performed vacuum.clean associated with our entity "vacuum.robot_aspirapolvere", Starting it.

The second script ("script.vacuum_to_dock"), Instead, when evoked, verifies that"vacuum.robot_aspirapolvere"Is actually being cleaned and, if it is, interrupts it and sends it to the charging base (services vacuum.stop e vacuum.return_to_base).

Automation

At this point, there is no lack in defining the two relative automations to the actions to be performed at the exit and back home (here an approfoundation) based on the assumptions and achievements defined up to now:

automation:
- alias: "USCITA"
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: group.famiglia
    from: 'home'
  condition: []
  action:
    - service: script.turn_on
      entity_id: script.vacuum_on

- alias: "RIENTRO"
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: group.famiglia
    to: 'home'
  condition: []
  action:
    - service: script.turn_on
      entity_id: script.vacuum_to_dock

The two automations ("automation.uscita" and "automation.rientro") Are triggered by the change of state of the entity"group.famiglia", Or when the family goes out or goes home (again, here there is an approelucidation).

conclusions

Obviously the needs of the individual can be specifically the most disparate, and even in this case the rule of "the limit is the imagination" is truer than ever. Quite simply, in the execution of the two scripts (especially the one for activating the robot) it is possible to add specific conditions relating to the prohabits: maybe it is not enough to start it when you leave, but it is also necessary to check that you are in a specific moment of the day. Also the duration of the break, of course, is adjustable: we have proplace 12 hours, but clearly it is a personal adjustment.

Obviously automation promail could be appalso freely granted to entities not only of the "Vacumm" type but also of another nature.


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.


Please comment below