Control husqvarna automower with esphome

Hello, i have connected a wemos d1 mini to the serial port of my automower. I want’t to send serial command and receive the response. I have all the command i wan’t to send. Can you help me to create a functionnal code.

My actual code is:


esphome:
  name: automower

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0
  level: VERY_VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "TXU6oyUBozoXKYmllDalOrL9TTZaOpvVCUDTgwkGkoQ="

ota:
  password: "0e255c38597a595dacd7cb6b0be0f874"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Automower Fallback Hotspot"
    password: !secret wifi_password

captive_portal:

uart:
  tx_pin: GPIO5
  rx_pin: GPIO4
  baud_rate: 115200
  debug:

switch:
  - platform: uart
    name: "test"
    data: [0x02, 0x12, 0x01, 0x01, 0x9F, 0x03]

1 Like

Hello, did you manage to get it working?

Can be done by flashing a Wemos D1 mini with ESP-Link. Connect the Wemos with the automower on the apprioate pins. (keep an eye on the 3,3V tolerance of the rs-232 port of the automower.
(I asume we talk about the G2 version of automower, a 220AC or 230ACX for example. (later models have an interface from huqvarna with can be used.)

for this case, the automower can be controlled by sending the (serial) command code, to the automover.
this is achieved by sending the codes through a socket + port connection for the Wemos.

my goal is, to send my automower to its base, when it is raining, and continue after it is dry and stays dry for 2 hours. (mowing can be done when it is raining, but makes the mower very dirty :slight_smile: ).

the commands to send can by done in appdaemon python or by a simple shell command.

I’ve not integrated it all yet, but I can send these simple commands to the WemosD1, which appear on the serial port:

create a file: shell_commands.yaml
include this in configuration.yaml (shell_command: !include shell_commands.yaml)
and put this in shell_command.yaml:
(the code that are send, are not the correct one, just as an example, see below for the right codes)
my wemos has a fixed IP adres which is 192.168.2.239 and the port adres for ESP_LINK is 23
I’m using a WemosD1 pro, because it has an option to use an external antenna for a better signal, but the standard wemosD1 will do the trick also.

automower_home: echo -e "\xA1\xA2" | nc 192.168.2.239 23
automower_continue: echo -e "\xB1\xB2" | nc 192.168.2.239 23

(I have to test if this is enough, because the automower is sending the commands received back, dont know I’ve got to check these, then a simple python program is needed for send/receiving)

these commands can be used in HA automation to do the trick.
for example

- id: '1681396553747'
  alias: Automower go home
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_boolean.automower_home_continue
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: shell_command.automower_home
    data: {}
  mode: single

here’s an old link for detailed info about the protocol etc:
http://www.roboternetz.de/community/threads/1330-AutoMower-von-Elektrolux-und-Husqvarna/page8?p=89398#post89398

the codes for sending the automower to its base are : “0F805F000D” (hex)
and to set the mower in automode again: “0F805F000E” (hex)

Hi @thisim ,
Have you managed to get it running?
Would you kindly provide me your code to readout the serial port?
Thanks in advance.

Hi everyone

Actualy I’m connecting to my Gardena R40LI (Identical to Husquvarna) using a ESP8266 with Arduino SW I found here: https://gitlab.com/nbrgmn/wall-e-esp8266-automower/-/merge_requests/1/diffs?commit_id=713b1db6716f79974d7f6b6e6f55a14936661071

I’ve integrated it to Home Assistant using MQTT, but there is also a JSON available.
There is only one issue I found. The ESP is not reconnecting to WIFI if connection dropped.

@smitec11 how is this working out? I have a 305 that I would love to connect to homeassistant. I was hoping to find a bluetooth integration but none exist. Mostly I want to see the status of the mower, do you know if this is available from the serial port?
Many thanks!

Here is a basic version of ESP home firmware that works on my 220ac

1 Like

@ mikechristiansen, sorry for the late responce, missed the new message somehow.
I change the way for connecting to the AC220/AC230, I used an esp32 (can also be done with a esp8266), to connect with the mower. used existing code for this, see this link : GitHub - prozzerg/AMConnect

I am not sure how and if this works for a 305?

Hi Chris,
have you been able to make it work with an ESP32 ? I followed the connection diagram but I don’t get any data from the serial when I use the 5v pin. I’m able to get same data when on the 3.3v pin but the mower does not start properly (welcome screen is blinking). Any idea what I’m doing wrong ?
Thanks

I have managed to connect my automower 230acx to my HA using this project GitHub - prozzerg/AMConnect
I used a LOLIN32 lite. Connected pin 17 to RX of the automower and pin 16 to TX of the automower. I had to use Serial2 instead of Serial1.

Hi
I wounder if it possible to use a uart gps modul with your code?

Hi Daarn,

Everything is possible;)

I guess you would have to add it as a separate component in yaml file and it could send the position to HA.
Something more complex would have to be done if you want a local logic (stop the mower if it’s at some gps position… )

It seems to be fun and easy to do. I think I will try :wink:

I also found the GPS Component. But I’m not sure how to add a second uart pins or if I can use the same.

You cannot use the same uart.
The esp8266 only has one (complete) uart but esphome automatically creates a software serial if pins are not the one for hardware uart.
Esp32 has several hardware uart (than can be bound on almost any gpio)

I’m using ESP32 but don’t know how defind the secound pair of pins ESPhome give me error only

Please look at this example to define several uarts. (Using a yaml array)
How can I declare two UARTs in yaml? · Issue #521 · esphome/issues · GitHub