Home Assistant: Sockets control robotic lawn mowers
As mentioned in a previous post, I control my robotic lawnmower, a Husqvarna Automower, affectionately known as Oswald, via a controllable power outlet. The principle behind this is that the mower only starts when the charging station gets a current from the socket. My motivations for the power outlet were the lack of a rain sensor and the lack of available control options. For a few years I used a simple PHP page for control, see: www.script-example.com/smartplug-steuerung and later on I developed it with the PHP framework Laravel for the control. After transferring more and more automation tasks to Home Assistant in the meantime, the robotic mower was another logical step. Compared to the earlier solutions, the control with Home Assistant was much faster and easier to implement, especially since I don't have to worry about collecting the data, evaluating and displaying it. I was able to take over the logic for the control from the basic idea of the existing projects. I have limited the mowing phase directly in the settings of the device to the morning, so that Oswald disturbs as little as possible. Home Assistant is supposed to turn on the outlet only when it hasn't rained, the weather forecast is right, and the sun is shining, so that the device doesn't come into conflict with certain nocturnal or crepuscular animals.
The automation in detail
Besides certain times, the power generation of my balcony power plant serves as a trigger. The mower starts in the morning when the sun is shining and is deactivated again in the evening when the mower is in the charging station. I can tell if the mower has found its way back to the charging station by the power consumption: Under 3 watts, the mower is fully charged and in the station. If the mower ever fails to find its way home, I get a notification on my cell phone. As a condition for the start, I have queried the weather in the automation: The past precipitation values and a weather forecast are used:
Trigger | Description |
---|---|
When BalkonKW Total AC Output Power (Active) is above 110. | Above 110 watts from the balcony power plant: the sun is shining: In the actions: Check if the mower should start and turn on the power outlet if necessary. |
If the time is equal to 18:00 | In the evening In the actions: Check if the mower is in the charging station and if necessary turn off the socket, or send a notification. |
Actions
Execute 'Switch on?' if 'Morning' otherwise 'Evening: Turn off'
|
Here is the finished process as YAML-Text
alias: Oswald
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.balkonkw_total_ac_output_power_active
above: 110
- platform: time
at: "18:00:00"
condition: []
action:
- if:
- condition: time
before: "13:00:00"
alias: Late morning
then:
- if:
- condition: numeric_state
entity_id: sensor.balkonkw_total_ac_output_power_active
above: 110
- condition: device
type: is_off
device_id: ???
entity_id: switch.oswald_switch
domain: switch
- condition: numeric_state
entity_id: sensor.rain_zamg
below: 1
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.openweathermap_forecast_precipitation
below: 50
- condition: numeric_state
entity_id: sensor.openweathermap_forecast_precipitation
below: 2
alias: weather forecast
then:
- type: turn_on
device_id: ???
entity_id: switch.oswald_switch
domain: switch
- service: notify.mobile_app_sm_??
data:
title: It's dry and PV supplies -> Oswald on
message: "{{states('sensor.balkonkw_total_ac_output_power_active')}}Watt"
alias: PV supplies? Turn on?
alias: Turn on?
else:
- if:
- condition: device
type: is_on
device_id: ???
entity_id: switch.oswald_switch
domain: switch
then:
- if:
- condition: numeric_state
entity_id: sensor.oswald_active_power
below: 3
then:
- type: turn_off
device_id: ???
entity_id: switch.oswald_switch
domain: switch
else:
- service: notify.mobile_app_sm_??
data:
title: Oswald not turned off
message: "Power: {{states('sensor.oswald_active_power')}}Watt"
alias: "In the evening: switch off"
mode: single
The Yaml-Text can be posted into an empty automation and adapted to your needs. The historical precipitation values, in the flow "sensor.rain_zamg" I get by curl from a publicly accessible website, similar to the readout of the PV values of my balcony power plant: PV Balcony Power Plant Commissioning and HA Integration. See also, HA: Use values of any WebGUI as entities
{{percentage}} % positive