søndag 10. november 2019

My first time in Node-RED, motion sensor automation

I have heard about Node-RED several times. But until now I tried to do everything in Home Assistant and yaml.

Today I decided to try it out, I watched a couple of youtube videos and decided to try it out with a motion sensor and a light.

I only want it to turn on if we're home, and if the sun is down. And then to turn off when there's no motion detected.

Below is a picture of the flow. The names are in norwegian. So I'll explain.



First box is a state node of the motion sensor wich is connected to a switch.
The switch have two outputs on and off. If on is detected it goes through the "ute?" and "borte" which checks the current state of two input boolean switches I made. One for out and one for away. If one of those are on the flow stops. If not it goes on to the "Sol nede?" which checks if the sun is below the horizon.
If it's not below the horizon the flow stops. If it is it continues to "Lys av?" which checks if the light is off. If the light is off it turns it on. If not the flow stops.

If the motion detector goes to off, it turns the light off "Slå av lys"

A bit hard to explain only in words. But I hope you get the Idea.

onsdag 6. november 2019

Add Roborock S5 and create an easy automation for daily cleaning

I did buy a Roborock S5. Wifey was happy for this. 
Thw first I had to do was of course to set it up in Home Assistant

To do this you first have to find the token of the vacuum. I've got an android-phone so I did it like this:

First downloaded an earlier version of the Mi Home app: https://www.apkmirror.com/apk/xiaomi-inc/mihome/mihome-5-4-49-release/

I have to use that older version because the newer versions donesn't save the token in the log file.

Installed the app and connected the Roborock, then opened the log-file which is found in the smarthome/logs folder on the phone and searched for "token", then added the following lines in configuration.yaml:


vacuum:
  - platform: xiaomi_miio
    host: 192.168.1.108
    token: *******************
    name: Gudrun

I also reserved the dhcp in my router. So that the vacuum will get the same ip-adress every time the router reboots.

Then I created the automation for daily cleaning:


- id: '1568470324361'
  alias: Støvsuge
  trigger:
  - at: '10:00:00'
    platform: time
  condition: []
  action:
  - data:
      entity_id: vacuum.gudrun
    service: vacuum.start
  initial_state: 'true'

I will later add a condition that if we're on a vacation the automation will not run.