Landroid control in Homekit

Hi all,

Based on all the good work done by many others previously, I have expanded on the HomeKit implementation for Landroid robot mowers. This has only been tested on my Landroid 149E, but I assume will work on any others that share these common commands.

You will need both the Landroid-Cloud and HomeKit integrations installed, and your Landroid-Cloud integration configured and working through Home Assistant.

These scripts can be added to your configuration.yaml file. It will set up a range of switches that should all be exposed to Apple Home via a single HomeKit bridge that you can add to your Apple Home. These include:

  • A HomeKit bridge for Landroid
  • A ‘garage door’ sensor to indicate if the Landroid is docked
  • A ‘motion’ sensor to indicate if the Landroid is returning to dock
  • A ‘moisture’ sensor to indicate that the Landroid has detected rain
  • A ‘contact’ sensor to indicate that the Landroid is in error
  • A ‘contact’ sensor to indicate that the Landroid is in low battery (I have set it to <10%)
  • An on/off switch that can be used to start mowing/pause (on = start mowing, off = pause)
  • An on/off switch to return the robot to the dock (on = return, off = pause)
  • A ‘sticky’ on/off switch that pauses the robot (on = pause, off = does nothing - this allows you to choose to start mowing or return with the other switches)
  • An on/off switch for rain delay (on = delay 60 mins [can be configured], off = no rain delay)
  • An on/off switch to enable ‘party mode’ (on = party mode, off = party mode disabled)
  • An on/off switch for the Anti-Collision System

When configured, it should look like this:

I have put comments in the code to help you configure it.

You will need to replace “roger_the_roid” (which is my Landroid) with the name used in HA for your robot.

I hope this is of interest to some!

Macdownunder

## Code to be added to configuration.yaml
## Developed by Macdownunder using Landroid and HomeKit integrations
##
##  NB: You will need to replace "roger_the_roid" (which is my Landroid) with the name used in HA for your vacuum.



switch:
  - platform: template
    switches:

      # On/off switch to start mowing / pause (on = start mowing, off = pause)

      landroid_start_pause:
        friendly_name: "Landroid Start / Pause"
        value_template: >
          {{ is_state('lawn_mower.roger_the_roid', 'mowing') }}
        turn_on:
          service: lawn_mower.start_mowing
          data:
            entity_id: lawn_mower.roger_the_roid
        turn_off:
          service: lawn_mower.pause
          data:
            entity_id: lawn_mower.roger_the_roid

      # On/off switch to return to dock / pause (on = return to dock, off = pause)

      landroid_return_pause:
        friendly_name: "Landroid Return / Pause"
        value_template: >
          {{ is_state('lawn_mower.roger_the_roid', 'returning') }}
        turn_on:
          service: lawn_mower.dock
          data:
            entity_id: lawn_mower.roger_the_roid
        turn_off:
          service: lawn_mower.pause
          data:
            entity_id: lawn_mower.roger_the_roid

      # 'Sticky' On/off switch to pause / do nothing (on = pause, off = do nothing). This is so you can choose to start mowing again, or return to dock using the other switches.

      landroid_pause_sticky:
        friendly_name: "Landroid Pause"
        value_template: >
          {{ is_state('lawn_mower.roger_the_roid', 'paused') }}
        turn_on:
          service: lawn_mower.pause
          data:
            entity_id: lawn_mower.roger_the_roid
        turn_off:
          service: script.do_nothing

     # On/off switch to turn on/off rain delay (on = 60 min rain delay, off = turn off rain delay)
    
      landroid_rain_delay_60:
        friendly_name: "Landroid Rain Delay 60m"
        value_template: >
          {{ states('number.roger_the_roid_raindelay')|int >= 60 }}
        turn_on:
          service: number.set_value
          target:
            entity_id: number.roger_the_roid_raindelay
          data:
            value: 60  ##### you can set the pre-configured delay here (max 300 mins)
        turn_off:
          service: number.set_value
          target:
            entity_id: number.roger_the_roid_raindelay
          data:
            value: 0

script:

  # This script is for the 'off' side of the pause button.

  do_nothing:
    sequence: []


automation:


  # This turns off the 'returning to dock' switch when the robot has docked.

  - alias: "Dock turns off Start/Pause"
    trigger:
      - platform: state
        entity_id: switch.landroid_dock_pause
        to: "on"
    action:
      - service: switch.turn_off
        target:
          entity_id: switch.landroid_start_pause

  # This turns off the 'start' switch when the robot is paused.

  - alias: "Start turns off Dock/Pause"
    trigger:
      - platform: state
        entity_id: switch.landroid_start_pause
        to: "on"
    action:
      - service: switch.turn_off
        target:
          entity_id: switch.landroid_dock_pause

binary_sensor:

  - platform: template
    sensors:

      # This creates a 'garage door' sensor to indicate whether the robot has docked (open = out, close = docked)
 
      landroid_is_docked:
        friendly_name: "Landroid Docked"
        device_class: garage_door
        value_template: >
           {{ is_state('lawn_mower.roger_the_roid', 'docked') == false }}

      # This creates a 'motion' sensor to indicate that the robot is returning (motion detected = returning, no motion detected = not returning)

      landroid_returning:
        friendly_name: "Landroid Returning to Dock"
        device_class: motion # presence or motion, plug, garage_door, etc.
        value_template: >
          {{ is_state('lawn_mower.roger_the_roid', 'returning') }}

      # This creates a 'contact' sensor to incidate when the robot is in error (open = error, closed = no error) 

      landroid_error_contact:
        friendly_name: "Landroid Error Sensor"
        device_class: opening
        value_template: >
          {{ state_attr('sensor.roger_the_roid_error', 'id') | int != 0 }}

      # This creates a 'contact' sensor to incidate when the robot is in low battery (open = low battery, closed = not low battery). I have configured it to 10% 

      landroid_battery_low_contact:
        friendly_name: "Landroid Battery Low"
        device_class: opening  # Makes it a contact sensor in HomeKit
        value_template: >
          {{ states('sensor.roger_the_roid_battery') | int < 10 }}    ##### You can configure the percentage for low battery here by replacing the '10'

# Set up HomeKit integration bridge containing all entities to be exposed to HomeKit 

homekit:
  - name: Landroid
    port: 51827
    filter:
      include_entities:
        - binary_sensor.landroid_is_docked
        - binary_sensor.landroid_returning
        - binary_sensor.roger_the_roid_rainsensor_triggered
        - binary_sensor.landroid_error_contact
        - binary_sensor.landroid_battery_low_contact
        - switch.landroid_start_pause
        - switch.landroid_return_pause
        - switch.landroid_pause_sticky
        - switch.landroid_rain_delay_60
        - switch.roger_the_roid_acs
        - switch.roger_the_roid_party_mode

Thnx for sharing!