Skip to content

Instantly share code, notes, and snippets.

@vermut
Created April 28, 2024 19:25
Show Gist options
  • Save vermut/b4f66d254f27b49380e876dc1645f922 to your computer and use it in GitHub Desktop.
Save vermut/b4f66d254f27b49380e876dc1645f922 to your computer and use it in GitHub Desktop.
OpenMower HASS Integration (MQTT LawnMower way)
mqtt:
- lawn_mower:
- name: "OpenMower"
activity_state_topic: "openmower/robot_state/json"
activity_value_template: >-
{% set current_state = value_json.current_state %}
{% if current_state in ["MOWING", "DOCKING", "UNDOCKING"] %}
mowing
{% elif current_state in ["IDLE"] %}
{{ "docked" if bool(value_json.is_charging) else "paused" }}
{% else %}
none
{% endif %}
start_mowing_command_topic: "openmower/action"
start_mowing_command_template: "mower_logic:idle/start_mowing"
dock_command_topic: "openmower/action"
dock_command_template: "mower_logic:mowing/abort_mowing"
pause_command_topic: "openmower/action"
pause_command_template: "mower_logic:mowing/pause"
json_attributes_topic: "openmower/robot_state/json"
device:
identifiers: openmower
@vermut
Copy link
Author

vermut commented Apr 28, 2024

This assumes that you've configured OpenMower to connect to HomeAssistant's MQTT server (which you also configured).

It's important that you keep the openmower prefix in mower_config.txt.

export OM_MQTT_ENABLE=True
export OM_MQTT_HOSTNAME="CHANGEME"
export OM_MQTT_PORT="1883"
export OM_MQTT_USER="CHANGEME"
export OM_MQTT_PASSWORD="CHANGEME"
export OM_MQTT_TOPIC_PREFIX="openmower"

@rovo89
Copy link

rovo89 commented Apr 28, 2024

I'm just getting started with HA, but I think including the position as attribute might blow up the states recorder DB: home-assistant/core#111582 (comment)

@vermut
Copy link
Author

vermut commented Apr 30, 2024

I'm just getting started with HA, but I think including the position as attribute might blow up the states recorder DB: home-assistant/core#111582 (comment)

I read some docs, it seems like that indeed all state_attr changes are logged to history, but it gets pruned every 10 days (default setting). So no harm, especially if it's temporary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment