Robonect module in Husqavarna Automower via mqtt vacuum

Something like this should work:

- platform: rest
  resource: http://192.168.XX.XX/json?cmd=status
  name: blades
  value_template: "{{ value_json.blades.quality }}"
  username: X
  password: X
  json_attributes_path: '$.blades'
  json_attributes:
    - hours
    - days
1 Like

I am at a loss here about how should i set this up.

I created an automations.yaml -file, copy-pasted the scripts there. Did the same to other files.

I have some experience with simple esp8266 temperature sensors around the house using mqtt to get the values but i cannot grasp the concept how this integration has been set up.

What the end result looks like? What card is added from the overview menu?

Sorry to be a total doofus about this but i did not grasp the concept from this thread yet :slight_smile:

If you have set up your mower correctly the data will added to the senors through MQTT. Have you added the MQTT settings in Robonect?

I can’t seem to get the communication from HA to robonect to work. I get the data from the mower from mqqt, but nothing happens on the robot when I change in the input select list. Any clews?

anybody translated all this configuration to the new model for MQTT already? Is it simply all same but only the sensors "sensor: - platform: mqtt state_topic: " ist to be changed to “mqtt: sensor: - state_topic:” and it should work the same as before?

I would not do this, if you want to change anyway. Just use the publish service and the discovery way) to avoid all the yaml-loads, etc. Put it in a script, run it once (!) and you have all the entities and on top a device (which is not possible with yaml config). Here my config.

alias: MQTT Discovery Huqvarna Automower 330x
sequence:
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_gps_breitengrad/config
      retain: true
      payload: |
        {
          "state_topic": "automower/gps/latitude",
          "name": "Mähroboter GPS Breitengrad",
          "unique_id": "unique_id_mahroboter_gps_breitengrad",
          "object_id": "mahroboter_gps_breitengrad",
          "icon": "mdi:crosshairs-gps",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_gps_langengrad/config
      retain: true
      payload: |
        {
          "state_topic": "automower/gps/longitude",
          "name": "Mähroboter GPS Längengrad",
          "unique_id": "unique_id_mahroboter_gps_langengrad",
          "object_id": "mahroboter_gps_langengrad",
          "icon": "mdi:crosshairs-gps",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_gps_anzahl_satelliten/config
      retain: true
      payload: |
        {
          "state_topic": "automower/gps/satellites",
          "name": "Mähroboter GPS Anzahl Satelliten",
          "unique_id": "unique_id_mahroboter_gps_anzahl_satelliten",
          "object_id": "mahroboter_gps_anzahl_satelliten",
          "icon": "mdi:crosshairs-gps",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_luftfeuchte/config
      retain: true
      payload: |
        {
          "state_topic": "automower/health/climate/humidity",
          "name": "Mähroboter Luftfeuchte",
          "unique_id": "unique_id_mahroboter_luftfeuchte",
          "object_id": "mahroboter_luftfeuchte",
          "device_class": "humidity",
          "state_class": "measurement",
          "unit_of_measurement": "%",
          "icon": "mdi:water-percent",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_temperatur/config
      retain: true
      payload: |
        {
          "state_topic": "automower/health/climate/temperature",
          "name": "Mähroboter Temperatur",
          "unique_id": "unique_id_mahroboter_temperatur",
          "object_id": "mahroboter_temperatur",
          "device_class": "temperature",
          "state_class": "measurement",
          "unit_of_measurement": "°C",
          "icon": "mdi:thermometer",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_batteriespannung/config
      retain: true
      payload: |
        {
          "state_topic": "automower/health/voltage/batt",
          "name": "Mähroboter Batteriespannung",
          "unique_id": "unique_id_mahroboter_batteriespannung",
          "object_id": "mahroboter_batteriespannung",
          "device_class": "voltage",
          "state_class": "measurement",
          "unit_of_measurement": "V",
          "icon": "mdi:sine-wave",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_betriebsspannung_maher/config
      retain: true
      payload: |
        {
          "state_topic": "automower/health/voltage/ext33",
          "name": "Mähroboter Betriebsspannung Mäher",
          "unique_id": "unique_id_mahroboter_betriebsspannung_maher",
          "object_id": "mahroboter_betriebsspannung_maher",
          "device_class": "voltage",
          "state_class": "measurement",
          "unit_of_measurement": "V",
          "icon": "mdi:sine-wave",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_betriebsspannung_robonect/config
      retain: true
      payload: |
        {
          "state_topic": "automower/health/voltage/int33",
          "name": "Mähroboter Betriebsspannung Robonect",
          "unique_id": "unique_id_mahroboter_betriebsspannung_robonect",
          "object_id": "mahroboter_betriebsspannung_robonect",
          "device_class": "voltage",
          "state_class": "measurement",
          "unit_of_measurement": "V",
          "icon": "mdi:sine-wave",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_batterie/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/battery/charge",
          "name": "Mähroboter Batterie",
          "unique_id": "unique_id_mahroboter_batterie",
          "object_id": "mahroboter_batterie",
          "device_class": "battery",
          "state_class": "measurement",
          "unit_of_measurement": "%",
          "icon": "mdi:battery",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_messertage/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/blades/days",
          "name": "Mähroboter Messertage",
          "unique_id": "unique_id_mahroboter_messertage",
          "object_id": "mahroboter_messertage",
          "unit_of_measurement": "Tage",
          "icon": "mdi:terraform",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_messerstunden/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/blades/hours",
          "name": "Mähroboter Messerstunden",
          "unique_id": "unique_id_mahroboter_messerstunden",
          "object_id": "mahroboter_messerstunden",
          "unit_of_measurement": "Stunden",
          "icon": "mdi:terraform",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_messerqualitat/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/blades/quality",
          "name": "Mähroboter Messerqualität",
          "unique_id": "unique_id_mahroboter_messerqualitat",
          "object_id": "mahroboter_messerqualitat",
          "unit_of_measurement": "%",
          "icon": "mdi:terraform",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_fehlercode/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/error/code",
          "name": "Mähroboter Fehlercode",
          "unique_id": "unique_id_mahroboter_fehlercode",
          "object_id": "mahroboter_fehlercode",
          "icon": "mdi:alert-circle",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_fehlernachricht/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/error/message",
          "name": "Mähroboter Fehlernachricht",
          "unique_id": "unique_id_mahroboter_fehlernachricht",
          "object_id": "mahroboter_fehlernachricht",
          "icon": "mdi:alert-circle",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_betriebsstunden/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/statistic/hours",
          "name": "Mähroboter Betriebsstunden",
          "unique_id": "unique_id_mahroboter_betriebsstunden",
          "object_id": "mahroboter_betriebsstunden",
          "unit_of_measurement": "Stunden",
          "icon": "mdi:timer-sand",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_status_raw/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/status",
          "name": "Mähroboter Status Raw",
          "unique_id": "unique_id_mahroboter_status_raw",
          "object_id": "mahroboter_status_raw",
          "icon": "mdi:list-status",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_im_aktuellen_status/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/status/duration",
          "name": "Mähroboter Zeit im aktuellen Status",
          "unique_id": "unique_id_mahroboter_im_aktuellen_status",
          "object_id": "mahroboter_im_aktuellen_status",
          "unit_of_measurement": "Minuten",
          "icon": "mdi:timer",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_status_plain/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/status/plain",
          "name": "Mähroboter Status Plain",
          "unique_id": "unique_id_mahroboter_status_plain",
          "object_id": "mahroboter_status_plain",
          "icon": "mdi:list-status",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_substatus_raw/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/substatus",
          "name": "Mähroboter Substatus Raw",
          "unique_id": "unique_id_mahroboter_substatus_raw",
          "object_id": "mahroboter_substatus_raw",
          "icon": "mdi:list-status",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_substatus_plain/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/substatus/plain",
          "name": "Mähroboter Substatus Plain",
          "unique_id": "unique_id_mahroboter_substatus_plain",
          "object_id": "mahroboter_substatus_plain",
          "icon": "mdi:list-status",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_nachster_start_datum/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/timer/next/date",
          "name": "Mähroboter Nächster Start Datum",
          "unique_id": "unique_id_mahroboter_nachster_start_datum",
          "object_id": "mahroboter_nachster_start_datum",
          "icon": "mdi:calendar",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_nachster_start_uhrzeit/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/timer/next/time",
          "name": "Mähroboter Nächster Start Uhrzeit",
          "unique_id": "unique_id_mahroboter_nachster_start_uhrzeit",
          "object_id": "mahroboter_nachster_start_uhrzeit",
          "icon": "mdi:calendar",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_nachster_start_timestamp/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/timer/next/unix",
          "name": "Mähroboter Nächster Start Timestamp",
          "unique_id": "unique_id_mahroboter_nachster_start_timestamp",
          "object_id": "mahroboter_nachster_start_timestamp",
          "icon": "mdi:calendar",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_strecke_bis_startpunkt/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/distance",
          "name": "Mähroboter Strecke bis Startpunkt",
          "unique_id": "unique_id_mahroboter_strecke_bis_startpunkt",
          "object_id": "mahroboter_strecke_bis_startpunkt",
          "icon": "mdi:map-marker-distance",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_modus_raw/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/mode",
          "name": "Mähroboter Modus Raw",
          "unique_id": "unique_id_mahroboter_modus_raw",
          "object_id": "mahroboter_modus_raw",
          "icon": "mdi:state-machine",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_gestoppt/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/stopped",
          "name": "Mähroboter gestoppt",
          "unique_id": "unique_id_mahroboter_gestoppt",
          "object_id": "mahroboter_gestoppt",
          "icon": "mdi:octagon",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_passage_geoffnet/config
      retain: true
      payload: |
        {
          "state_topic": "automower/passage/open",
          "name": "Mähroboter Passage geöffnet",
          "unique_id": "unique_id_mahroboter_passage_geoffnet",
          "object_id": "mahroboter_passage_geoffnet",
          "icon": "mdi:fence",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_wetterstop_aktiv/config
      retain: true
      payload: |
        {
          "state_topic": "automower/weather/data/break",
          "name": "Mähroboter Wetterstop aktiv",
          "unique_id": "unique_id_mahroboter_wetterstop_aktiv",
          "object_id": "mahroboter_wetterstop_aktiv",
          "icon": "mdi:stop",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/mahroboter_wifi_signal/config
      retain: true
      payload: |
        {
          "state_topic": "automower/wlan/rssi",
          "name": "Mähroboter Wifi-Signal",
          "unique_id": "unique_id_mahroboter_wifi_signal",
          "object_id": "mahroboter_wifi_signal",
          "device_class": "signal_strength",
          "state_class": "measurement",
          "unit_of_measurement": "dBm",
          "icon": "mdi:wifi",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "4.05.00"
          }
        }
mode: single

I meanwhile simply tried after my post and what should I tell: It works. It was not so much to re-work but still I am interested in your method as this not being all under the hood of one device annoys me a long time already. So would you mind to detail a bit how this works, the “Put it in a script, run it once (!)” in detail? I assume what you posted below as your config is the result and not the script, am I right? And how does this adapt to other models of mowers and robonects (I see GPS, mine does not have)?

No, this is already the script, not the result. So you can copy and adopt. Just remove the topics, which you don’t use or add, if I missed some. Or rename. And then only execute it. Done.

But how do you control then the mower? I cannot find any of the “automower/control” topics in your script. So the device has only sensors, but no action is possible on it. You created scripts to publish MQTT messages on each control action?
What kind of Robonect do you have? many of the topics in your script don´t even exist in mine, just checked by MQTT Explorer, e.g. I neither have any GPS nor Blades nor a “automower/mower/error” branch… Or is this dependent not on the robonect but the mower?

Didn’t get this. control via

      - service: mqtt.publish
        data:
          topic: automower/control
          payload: start

etc. as before. Didn’t define anything for that before in yaml. And therefor, of course, this is only the replacement for the mqtt yaml sensor entities.

Again. This is a script to add the entities (instead of defining them in config-yaml) with the pros of faster startup time, a device etc., not a automower steering script.

I have the Robonect® Hx. But I doubt, that it is related to the automower modell, but to the Robonect fw, which mqtt topics you have. Here 1.3

Missing MQTT topic branches: you´re right, updating FW to 1.3b brought some of those to mine, too.

Yes, yes. Understood: this script creates the device adding all those sensors. What I am after is to add also the control to the device like having a mode selector or start or stop buttons directly linked to the device - and not only as scripts unlinked to the device which “owns” the sensors only. Maybe this is also possible somehow?

This is possible in defining e.g. a template vacuum. But I don’t like this, because of some limitations. And this one is then not connected to the device created above, because it is not possible to link yaml-entities to devices. Unfortunately.

  - platform: template
    vacuums:
      mahroboter_husqvarna_330x:
        friendly_name: "Mähroboter Husqvarna 330x"
        unique_id: unique_id_mahroboter_husqvarna_330x
        value_template: |
          {% if is_state("sensor.mahroboter_status_raw", "0") %}
            idle
          {% elif is_state("sensor.mahroboter_status_raw", "1") %}
            docked
          {% elif is_state("sensor.mahroboter_status_raw", "2") %}
            cleaning
          {% elif is_state("sensor.mahroboter_status_raw", "3") %}
            returning
          {% elif is_state("sensor.mahroboter_status_raw", "4") %}
            docked
          {% elif is_state("sensor.mahroboter_status_raw", "5") %}
            cleaning
          {% elif is_state("sensor.mahroboter_status_raw", "7") %}
            error
          {% elif is_state("sensor.mahroboter_status_raw", "8") %}
            error
          {% elif is_state("sensor.mahroboter_status_raw", "16") %}
            docked
          {% elif is_state("sensor.mahroboter_status_raw", "17") %}
            docked
          {% elif is_state("sensor.mahroboter_status_raw", "18") %}
            idle
          {% else %}
            error
          {% endif %}
        battery_level_template: "{{ states('sensor.mahroboter_batterie')|int(default=0) }}"
        start:
          service: script.rasenmahersteuerung_robonect
          data:
            message: start
        stop:
          service: script.rasenmahersteuerung_robonect
          data:
            message: stop
        return_to_base:
          service: script.rasenmahersteuerung_robonect
          data:
            message: eod
        locate:
          service: script.rasenmahersteuerung_robonect
          data:
            message: auto
        attribute_templates:
          substatus: "{{ states('sensor.mahroboter_substatus_raw') }}: {{ states('sensor.mahroboter_substatus_plain') }}"
          status: "{{ states('sensor.mahroboter_status_raw') }}: {{ states('sensor.mahroboter_status_plain') }}"

Thanks for that script, @arganto . It is such a nice way to integrate the mower into HA.
Is there a way to get the plain mode from the robonect? Currently in the script there is only the raw mode which gives me eg 2 for the (german) mode ‘Schäft’.

I’m further looking for a good way to control two things:

  1. I would like to be able to set the mower mode
  2. I would like to send an adhoc mowing job to my mower like in the robonect UI. Does anyone have an idea, how to to this from the HA UI? First step could be to send a fix job starting from now for 1 hour. Second step could be, to caonfigure an individuel input for the duration of the job starting by now.

You have to define template sensors, e.g.

  - sensor:
      - name: Mähroboter Modus lesbar
        unique_id: unique_id_mahroboter_modus_lesbar
        state: >
          {% if is_state("sensor.mahroboter_modus_raw", "0") %}
            Automatik
          {% elif is_state("sensor.mahroboter_modus_raw", "1") %}
            Manuell
          {% elif is_state("sensor.mahroboter_modus_raw", "2") %}
            Home
          {% elif is_state("sensor.mahroboter_modus_raw", "3") %}
            Demo
          {% else %}
            Versuche herauszufinden was {{ states("sensor.mahroboter_modus_raw") }} bedeutet
          {% endif %}
        icon: mdi:state-machine

  - sensor:
      - name: Mähroboter Status lesbar
        unique_id: unique_id_mahroboter_status_lesbar
        state: >
          {% if is_state("sensor.mahroboter_status_raw", "0") %}
            Erkenne Status
          {% elif is_state("sensor.mahroboter_status_raw", "1") %}
            Parkt
          {% elif is_state("sensor.mahroboter_status_raw", "2") %}
            Mäht
          {% elif is_state("sensor.mahroboter_status_raw", "3") %}
            Fährt heim
          {% elif is_state("sensor.mahroboter_status_raw", "4") %}
            Lädt
          {% elif is_state("sensor.mahroboter_status_raw", "5") %}
            Sucht
          {% elif is_state("sensor.mahroboter_status_raw", "7") %}
            Fehler
          {% elif is_state("sensor.mahroboter_status_raw", "8") %}
            Schleifensignal verloren
          {% elif is_state("sensor.mahroboter_status_raw", "16") %}
            Aus
          {% elif is_state("sensor.mahroboter_status_raw", "17") %}
            Schläft
          {% elif is_state("sensor.mahroboter_status_raw", "18") %}
            Wartet_auf_Garagentor
          {% else %}
            Versuche herauszufinden was {{ states("sensor.mahroboter_status_raw") }} bedeutet
          {% endif %}
        icon: mdi:list-status
1 Like

For ad-hoc start, I have defined a rest-sensor

rest_command:
  start_husqvarna_330x5:
    url: "http://xxx.xxx.xxx.xxx/xml?cmd=mode&mode=job&duration={{ duration }}&remotestart={{ remotestart }}&after=auto"
    method: POST
    username: !secret robonect_username
    password: !secret robonect_password

And the call it vias this service with parameters, like last call here. In this whole scipts you can find further calls and topics as well:

alias: Rasenmähersteuerung Robonect
sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ message == 'start' }}"
        sequence:
          - service: mqtt.publish
            data:
              topic: automower/control
              payload: start
      - conditions:
          - condition: template
            value_template: "{{ message == 'stop' }}"
        sequence:
          - service: mqtt.publish
            data:
              topic: automower/control
              payload: stop
      - conditions:
          - condition: template
            value_template: "{{ message == 'home' }}"
        sequence:
          - service: input_select.select_option
            target:
              entity_id: input_select.mahroboter_gesetzter_modus
            data:
              option: Dauerparken
          - service: mqtt.publish
            data:
              topic: automower/control/mode
              payload: home
      - conditions:
          - condition: template
            value_template: "{{ message == 'eoj' }}"
        sequence:
          - service: input_select.select_option
            target:
              entity_id: input_select.mahroboter_gesetzter_modus
            data:
              option: Jobende
          - service: mqtt.publish
            data:
              topic: automower/control/mode
              payload: home
          - wait_for_trigger:
              - platform: state
                entity_id: sensor.mahroboter_status_raw
                to: "4"
                for:
                  hours: 0
                  minutes: 0
                  seconds: 5
                enabled: true
              - platform: state
                entity_id: sensor.mahroboter_status_raw
                to: "17"
                for:
                  hours: 0
                  minutes: 0
                  seconds: 5
                enabled: true
            enabled: false
            continue_on_timeout: false
          - wait_template: |-
              {{ states("sensor.mahroboter_nachster_start_datum") >
              strptime(states("sensor.date_time"), "%Y-%m-%d,
              %H:%M").date()|string
                 or (states("sensor.mahroboter_nachster_start_uhrzeit") != "00:00:00"
                     and as_local(strptime(states("sensor.date_time"), "%Y-%m-%d, %H:%M"))+timedelta(hours = 0, minutes = 30)
                         > as_datetime(states("sensor.mahroboter_nachster_start_datum")+"T"+states("sensor.mahroboter_nachster_start_uhrzeit")+"+02:00")
                    )
              }}
            continue_on_timeout: false
            enabled: false
          - delay:
              hours: 3
              minutes: 0
              seconds: 0
              milliseconds: 0
          - service: input_select.select_option
            target:
              entity_id: input_select.mahroboter_gesetzter_modus
            data:
              option: Automatik
          - service: mqtt.publish
            data:
              topic: automower/control/mode
              payload: auto
      - conditions:
          - condition: template
            value_template: "{{ message == 'eod' }}"
        sequence:
          - service: input_select.select_option
            target:
              entity_id: input_select.mahroboter_gesetzter_modus
            data:
              option: Tagesende
          - service: mqtt.publish
            data:
              topic: automower/control/mode
              payload: eod
      - conditions:
          - condition: template
            value_template: "{{ message == 'auto' }}"
        sequence:
          - service: input_select.select_option
            target:
              entity_id: input_select.mahroboter_gesetzter_modus
            data:
              option: Automatik
          - service: mqtt.publish
            data:
              topic: automower/control/mode
              payload: auto
      - conditions:
          - condition: template
            value_template: "{{ message == 'job' }}"
        sequence:
          - service: rest_command.start_husqvarna_330x5
            data:
              remotestart: "{{ remotestart }}"
              duration: "{{ duration }}"
mode: restart
icon: mdi:robot-mower

and inside UI I call this script via service-calls, like

                  tap_action:
                    action: call-service
                    service: script.rasenmahersteuerung_robonect
                    service_data:
                      message: eoj

or

        tap_action:
          action: |
            [[[
              if (states["sensor.mahroboter_status_raw"].state == "100"
                || states["sensor.mahroboter_status_raw"].state == "4"
                || states["sensor.mahroboter_status_raw"].state == "16"
                || states["sensor.mahroboter_status_raw"].state == "17"
              )
                return "call-service";
              else
                return "none";
            ]]]
          service: script.rasenmahersteuerung_robonect
          service_data:
            message: job
            remotestart: '4'
            duration: 90
          haptic: success
1 Like

OK, but the new sensor will not be connected to the MQTT Device, right?
The readable Status comes aout of the mqtt topic “/mower/status/plain”, so that a teamplate sensor should not be necessary.

Found here a thread where the possible controls via mqtt are descriped. Will try to use them.

Right. Unfortunately, not.

Regarding the services: Yes, but you can not use mqtt for everything. I used it in the script above, where it is possible. Just double-check. In other cases, you have to use the rest call, like the “Fernstart” and Duration.

The plain-Status is not as you want to have, because there are to many (with e.g. added meters in text in way to start and home station, etc.). You will see. :wink: Because of that I defined my own in addition.

BTW The above calls come in my case from an own card build with stacks and button-cards. Yes it is in style of an available vacuum-card, but as this was not able to do, what I want, I created this own one from scratch. Including the picture, which is of course moving, if mower is moving. :joy:

image

The 1, 2, 3 ar starting ad-hoc at different starting positions. Start and Stop are clear and Home is setting the status in another popup

image

But you can see, that the execution for all of them is bundled in the script above.

2 Likes

That looks rearly great! This is, what I want to reach :wink:
But step by step …
Where did you cnfigure your Sensor with the rest_command? I can’t find the right place or format to do it.
The Script is in place but needs the additional input Helper. Thats my next step.

It has to be defined in the configuration.yaml