From 23c80a5df548c4ecc39ff0e720e4ce8be35572a9 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 9 Jul 2023 16:37:51 +0200 Subject: [PATCH 1/8] Create _index.md Add openmower in home assistant with mqtt --- .../Home_assitant_MQTT/_index.md | 307 ++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 content/en/docs/contributions/Home_assitant_MQTT/_index.md diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md new file mode 100644 index 0000000..6a03264 --- /dev/null +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -0,0 +1,307 @@ +--- +title: Add OpenMower in Home Assitant with MQTT +linkTitle: Home Assistant +description: > + Add OpenMower in Home Assitant with MQTT. +--- + +Author: Etienne@discord , DocGalaxyBlock@discord , JuergenLeber@discord + +### Prerequisites +- **Home assistant** +- **[Mosquitto broker addons](https://github.com/home-assistant/addons/tree/master/mosquitto)** + + +### Step 0: Configure mqtt in Home Assistant +Go to to addons settings and add in "Logins" + ```bash + - username: openmoweruser + password: openmowerpass +``` +Of course choose your own password. + +### Step 2: Install and setup MQTT bridqe on openmower +Create mqtt-bridge.conf for connect bridge to HA Mosquitto +```bash +sudo mkdir /boot/openmower/mqtt +sudo nano /boot/openmower/mqtt/mqtt-bridge.conf +``` +Paste your config: +```bash +connection bridge-to-external-broker + +try_private true +cleansession true +topic # out 0 "" openmower/ +topic # in 0 "" openmower/ + +address 192.168.XXX.XXX # Ip of HA instance + +remote_username openmoweruser +remote_password openmowerpass +``` +You need change IP adress,user and password. + +Create mosquitto.conf for connect bridge to openmower (ROS) +```bash +sudo mkdir /etc/mosquitto/ +sudo nano /etc/mosquitto/mosquitto.conf +``` +Paste (nothing to change here). +```bash +# A full description of the configuration file is at +# /usr/share/doc/mosquitto/examples/mosquitto.conf.example + +pid_file /run/mosquitto/openmower-mqtt-bridge.pid + +log_type notice +#log_dest /var/log/mosquitto/ +#some random port +listener 18838 + + +#the bridge to the openmower container +connection bridge-to-openmower + +try_private true +cleansession true +topic # out 0 +topic # in 0 +address localhost + +#include the config for the external bridge +include_dir /boot/openmower/mqtt +``` + +Create openmower-mqtt-bridge.service +```bash +sudo nano /etc/systemd/system/openmower-mqtt-bridge.service +``` +Paste (nothing to change here). +```bash +[Unit] +Description=OpenMower MQTT Bridge +Documentation=man:mosquitto.conf(5) man:mosquitto(8) +After=network.target openmower.service openmower-debug.service +Wants=network.target +StartLimitBurst=0 + +[Service] +Type=notify +NotifyAccess=main +ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +RestartSec=10s +ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto +ExecStartPre=/bin/chown mosquitto /var/log/mosquitto +ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto +ExecStartPre=/bin/chown mosquitto /run/mosquitto + +[Install] +WantedBy=multi-user.target +``` + +Install and launch mqtt-bridge +```bash +systemctl disable podman-auto-update.timer podman-auto-update.service +sudo apt-get update +sudo apt-get install -y mosquitto #!don't update the mosquitto.conf! +systemctl mask mosquitto.service +systemctl enable openmower-mqtt-bridge.service +systemctl enable podman-auto-update.timer podman-auto-update.service +``` +Now openmower is connet to your HA MQTT addons. +You can check with [MQTT Explorer](http://mqtt-explorer.com/) + + +### Step 3: Configure Home Assistant configuration.yaml +add in configuration.yaml +```bash + mqtt: !include mqtt.yaml +``` + +Then create a new file mqtt.yaml and paste: +```bash +############################# MQTT sensors ########################### +sensor: + - state_topic: "openmower/robot_state/json" + name: "OpenMower Gps" + device_class: distance + unique_id: "OM/sensors/om_gps_accuracy" + value_template: "{{ value_json.pose.pos_accuracy }}" + json_attributes_topic: "pos_accuracy" + unit_of_measurement: "m" + + - state_topic: "openmower/sensors/om_mow_esc_temp/data" + name: "OpenMower Mow ESC Temp" + unique_id: "OM/sensors/om_mow_esc_temp" + value_template: "{{ value | round(2) }}" + unit_of_measurement: "°C" + + - state_topic: "openmower/sensors/om_mow_motor_temp/data" + name: "OpenMower Mow Motor Temp" + unique_id: "OM/sensors/om_mow_esc_temp/data" + value_template: "{{ value | round(2) }}" + unit_of_measurement: "°C" + + - state_topic: "openmower/sensors/om_left_esc_temp/data" + name: "OpenMower Left ESC Temp" + unique_id: "OM/sensors/om_left_esc_temp" + value_template: "{{ value | round(2) }}" + unit_of_measurement: "°C" + + - state_topic: "openmower/sensors/om_right_esc_temp/data" + name: "OpenMower Right ESC Temp" + unique_id: "OM/sensors/om_right_esc_temp" + value_template: "{{ value | round(2) }}" + unit_of_measurement: "°C" + + - state_topic: "openmower/sensors/om_charge_current/data" + name: "OpenMower Charge Current" + device_class: current + unique_id: "OM/sensors/om_charge_current" + value_template: "{{ value | round(2) }}" + unit_of_measurement: "A" + + - state_topic: "openmower/sensors/om_v_battery/data" + name: "OpenMower V Battery" + device_class: voltage + unique_id: "OM/sensors/om_v_battery" + value_template: "{{ value | round(2) }}" + unit_of_measurement: "V" + + - state_topic: "openmower/sensors/om_v_charge/data" + name: "OpenMowerV Charge" + device_class: voltage + unique_id: "OM/sensors/om_v_charge" + value_template: "{{ value | round(2) }}" + unit_of_measurement: "V" + + - state_topic: "openmower/robot_state/json" + name: "OpenMower Battery %" + device_class: battery + value_template: "{{ value_json.battery_percentage | round(2) | float * 100 }}" + json_attributes_topic: "battery_percentage" + unique_id: "OM/robot_state/battery_percentage" + unit_of_measurement: "%" + + - state_topic: "openmower/robot_state/json" + name: "OpenMower Current State" + value_template: "{{ value_json.current_state }}" + unique_id: "OM/robot_state/current_state" + json_attributes_topic: "current_state" + +binary_sensor: + - state_topic: "openmower/robot_state/json" + name: "OpenMower Emergency" + device_class: safety + unique_id: "OM/sensors/om_emergency" + value_template: "{{ value_json.emergency }}" + payload_on: "1" + payload_off: "0" + json_attributes_topic: "emergency" + + + - state_topic: "openmower/robot_state/json" + name: "OpenMower is Charging" + device_class: battery_charging + value_template: "{{ value_json.is_charging }}" + payload_on: "1" + payload_off: "0" + unique_id: "OM/robot_state/is_charging" + json_attributes_topic: "is charging" + +button: + - unique_id: "OM/actions/start_mowing" + name: "OpenMower start mowing" + command_topic: "openmower//action" + payload_press: "mower_logic:idle/start_mowing" + availability_mode: "all" + availability: + - topic: "openmower/actions/json" + value_template: > + {% for actions in value_json -%} + {% if actions.action_id == "mower_logic:idle/start_mowing" -%} + {{ actions.enabled }} + {%- endif %} + {%- endfor %} + payload_available: "1" + payload_not_available: "0" + qos: 0 + retain: false + + - unique_id: "OM/actions/abort_mowing" + name: "OpenMower abort mowing" + command_topic: "openmower//action" + payload_press: "mower_logic:mowing/abort_mowing" + availability_mode: "all" + availability: + - topic: "openmower/actions/json" + value_template: > + {% for actions in value_json -%} + {% if actions.action_id == "mower_logic:mowing/abort_mowing" -%} + {{ actions.enabled }} + {%- endif %} + {%- endfor %} + payload_available: "1" + payload_not_available: "0" + qos: 0 + retain: false + - unique_id: "OM/actions/pause_mowing" + name: "OpenMower pause mowing" + command_topic: "openmower//action" + payload_press: "mower_logic:mowing/pause" + availability_mode: "all" + availability: + - topic: "openmower/actions/json" + value_template: > + {% for actions in value_json -%} + {% if actions.action_id == "mower_logic:mowing/pause" -%} + {{ actions.enabled }} + {%- endif %} + {%- endfor %} + payload_available: "1" + payload_not_available: "0" + qos: 0 + retain: false + + - unique_id: "OM/actions/continue_mowing" + name: "OpenMower continue mowing" + command_topic: "openmower//action" + payload_press: "mower_logic:mowing/continue" + availability_mode: "all" + availability: + - topic: "openmower/actions/json" + value_template: > + {% for actions in value_json -%} + {% if actions.action_id == "mower_logic:mowing/continue" -%} + {{ actions.enabled }} + {%- endif %} + {%- endfor %} + payload_available: "1" + payload_not_available: "0" + qos: 0 + retain: false + + - unique_id: "OM/actions/skip_area" + name: "OpenMower skip area" + command_topic: "openmower//action" + payload_press: "mower_logic:mowing/skip_area" + availability_mode: "all" + availability: + - topic: "openmower/actions/json" + value_template: > + {% for actions in value_json -%} + {% if actions.action_id == "mower_logic:mowing/skip_area" -%} + {{ actions.enabled }} + {%- endif %} + {%- endfor %} + payload_available: "1" + payload_not_available: "0" + qos: 0 + retain: false +``` + +### Step 4: Create your own dashboard in HA +After that you can create your dashbord! Enjoy! From 0152d8f60730fe4aea4005303afdb26c3093a6f0 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 9 Jul 2023 17:04:56 +0200 Subject: [PATCH 2/8] Add mqtt-bridge service status --- .../Home_assitant_MQTT/_index.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md index 6a03264..29d9fb3 100644 --- a/content/en/docs/contributions/Home_assitant_MQTT/_index.md +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -111,6 +111,29 @@ systemctl mask mosquitto.service systemctl enable openmower-mqtt-bridge.service systemctl enable podman-auto-update.timer podman-auto-update.service ``` +Test if service is started: +```bash +sudo systemctl status openmower-mqtt-bridge.service +``` +Should return something like this: +```bash +● openmower-mqtt-bridge.service - OpenMower MQTT Bridge + Loaded: loaded (/etc/systemd/system/openmower-mqtt-bridge.service; enabled; vendor preset: enabled) + Active: active (running) since Sat 2023-07-08 10:14:55 BST; 1 day 5h ago + Docs: man:mosquitto.conf(5) + man:mosquitto(8) + Process: 5977 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS) + Process: 5978 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS) + Process: 5979 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS) + Process: 5980 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS) + Main PID: 5981 (mosquitto) + Tasks: 1 (limit: 4471) + CPU: 7min 52.689s + CGroup: /system.slice/openmower-mqtt-bridge.service + └─5981 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf + +Jul 08 22:43:28 openmower mosquitto[5981]: 1688852608: Connecting bridge (step 1) bridge-to-external-broker (192.168.xxx.xxx:1883) +``` Now openmower is connet to your HA MQTT addons. You can check with [MQTT Explorer](http://mqtt-explorer.com/) From 49c2d9403ce991c927019689043d936497057532 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 9 Jul 2023 21:43:03 +0200 Subject: [PATCH 3/8] Update _index.md Delete install mqtt section --- .../Home_assitant_MQTT/_index.md | 99 +++---------------- 1 file changed, 15 insertions(+), 84 deletions(-) diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md index 29d9fb3..84f8f9f 100644 --- a/content/en/docs/contributions/Home_assitant_MQTT/_index.md +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -20,97 +20,28 @@ Go to to addons settings and add in "Logins" ``` Of course choose your own password. -### Step 2: Install and setup MQTT bridqe on openmower -Create mqtt-bridge.conf for connect bridge to HA Mosquitto +### Step 2: Setup MQTT bridqe on openmower +Enable MQTT on mower_config.txt ```bash -sudo mkdir /boot/openmower/mqtt -sudo nano /boot/openmower/mqtt/mqtt-bridge.conf -``` -Paste your config: -```bash -connection bridge-to-external-broker - -try_private true -cleansession true -topic # out 0 "" openmower/ -topic # in 0 "" openmower/ - -address 192.168.XXX.XXX # Ip of HA instance - -remote_username openmoweruser -remote_password openmowerpass +sudo nano /boot/openmower/mower_config.txt ``` You need change IP adress,user and password. -Create mosquitto.conf for connect bridge to openmower (ROS) +Exemple: ```bash -sudo mkdir /etc/mosquitto/ -sudo nano /etc/mosquitto/mosquitto.conf -``` -Paste (nothing to change here). -```bash -# A full description of the configuration file is at -# /usr/share/doc/mosquitto/examples/mosquitto.conf.example - -pid_file /run/mosquitto/openmower-mqtt-bridge.pid - -log_type notice -#log_dest /var/log/mosquitto/ -#some random port -listener 18838 - - -#the bridge to the openmower container -connection bridge-to-openmower +################################ +## External MQTT Broker ## +################################ +# Set thes in order to publish status data to your external MQTT broker. +# This is for use with smart home. -try_private true -cleansession true -topic # out 0 -topic # in 0 -address localhost - -#include the config for the external bridge -include_dir /boot/openmower/mqtt -``` - -Create openmower-mqtt-bridge.service -```bash -sudo nano /etc/systemd/system/openmower-mqtt-bridge.service -``` -Paste (nothing to change here). -```bash -[Unit] -Description=OpenMower MQTT Bridge -Documentation=man:mosquitto.conf(5) man:mosquitto(8) -After=network.target openmower.service openmower-debug.service -Wants=network.target -StartLimitBurst=0 - -[Service] -Type=notify -NotifyAccess=main -ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -ExecReload=/bin/kill -HUP $MAINPID -Restart=on-failure -RestartSec=10s -ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto -ExecStartPre=/bin/chown mosquitto /var/log/mosquitto -ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto -ExecStartPre=/bin/chown mosquitto /run/mosquitto - -[Install] -WantedBy=multi-user.target +export OM_MQTT_ENABLE=True +export OM_MQTT_HOSTNAME="192.168.1.100" +export OM_MQTT_PORT="1883" +export OM_MQTT_USER="openmoweruser" +export OM_MQTT_PASSWORD="openmowerpass" ``` -Install and launch mqtt-bridge -```bash -systemctl disable podman-auto-update.timer podman-auto-update.service -sudo apt-get update -sudo apt-get install -y mosquitto #!don't update the mosquitto.conf! -systemctl mask mosquitto.service -systemctl enable openmower-mqtt-bridge.service -systemctl enable podman-auto-update.timer podman-auto-update.service -``` Test if service is started: ```bash sudo systemctl status openmower-mqtt-bridge.service @@ -134,7 +65,7 @@ Should return something like this: Jul 08 22:43:28 openmower mosquitto[5981]: 1688852608: Connecting bridge (step 1) bridge-to-external-broker (192.168.xxx.xxx:1883) ``` -Now openmower is connet to your HA MQTT addons. +Now openmower is connect to your HA MQTT addons. You can check with [MQTT Explorer](http://mqtt-explorer.com/) From f424286e561390fb1709cbf2ea6d06436521a063 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 23 Jul 2023 20:19:36 +0200 Subject: [PATCH 4/8] Update content/en/docs/contributions/Home_assitant_MQTT/_index.md Co-authored-by: Pavels Veretennikovs --- content/en/docs/contributions/Home_assitant_MQTT/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md index 84f8f9f..c16adf1 100644 --- a/content/en/docs/contributions/Home_assitant_MQTT/_index.md +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -20,7 +20,7 @@ Go to to addons settings and add in "Logins" ``` Of course choose your own password. -### Step 2: Setup MQTT bridqe on openmower +### Step 2: Setup MQTT bridge on OpenMower Enable MQTT on mower_config.txt ```bash sudo nano /boot/openmower/mower_config.txt From 8633dfb5b696f7f473de9a5ebd76cad7e7dc0b90 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 23 Jul 2023 20:19:44 +0200 Subject: [PATCH 5/8] Update content/en/docs/contributions/Home_assitant_MQTT/_index.md Co-authored-by: Pavels Veretennikovs --- content/en/docs/contributions/Home_assitant_MQTT/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md index c16adf1..5acb369 100644 --- a/content/en/docs/contributions/Home_assitant_MQTT/_index.md +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -8,7 +8,7 @@ description: > Author: Etienne@discord , DocGalaxyBlock@discord , JuergenLeber@discord ### Prerequisites -- **Home assistant** +- **Home Assistant** - **[Mosquitto broker addons](https://github.com/home-assistant/addons/tree/master/mosquitto)** From b558b19ad8604c81779f5282b74fe234f6547506 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 23 Jul 2023 20:19:49 +0200 Subject: [PATCH 6/8] Update content/en/docs/contributions/Home_assitant_MQTT/_index.md Co-authored-by: Pavels Veretennikovs --- content/en/docs/contributions/Home_assitant_MQTT/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md index 5acb369..88d6977 100644 --- a/content/en/docs/contributions/Home_assitant_MQTT/_index.md +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -25,7 +25,7 @@ Enable MQTT on mower_config.txt ```bash sudo nano /boot/openmower/mower_config.txt ``` -You need change IP adress,user and password. +You need to change IP address, user and password. Exemple: ```bash From 816daf58a712c5fa684fb629ff10776d1a44dcd9 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 23 Jul 2023 20:19:53 +0200 Subject: [PATCH 7/8] Update content/en/docs/contributions/Home_assitant_MQTT/_index.md Co-authored-by: Pavels Veretennikovs --- content/en/docs/contributions/Home_assitant_MQTT/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md index 88d6977..28b69bc 100644 --- a/content/en/docs/contributions/Home_assitant_MQTT/_index.md +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -27,7 +27,7 @@ sudo nano /boot/openmower/mower_config.txt ``` You need to change IP address, user and password. -Exemple: +Example: ```bash ################################ ## External MQTT Broker ## From b06da5f82ec0f9fa4b8350c23225da84e7826cb6 Mon Sep 17 00:00:00 2001 From: tetiti20 Date: Sun, 23 Jul 2023 20:19:58 +0200 Subject: [PATCH 8/8] Update content/en/docs/contributions/Home_assitant_MQTT/_index.md Co-authored-by: Pavels Veretennikovs --- content/en/docs/contributions/Home_assitant_MQTT/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/contributions/Home_assitant_MQTT/_index.md b/content/en/docs/contributions/Home_assitant_MQTT/_index.md index 28b69bc..e031cba 100644 --- a/content/en/docs/contributions/Home_assitant_MQTT/_index.md +++ b/content/en/docs/contributions/Home_assitant_MQTT/_index.md @@ -65,7 +65,7 @@ Should return something like this: Jul 08 22:43:28 openmower mosquitto[5981]: 1688852608: Connecting bridge (step 1) bridge-to-external-broker (192.168.xxx.xxx:1883) ``` -Now openmower is connect to your HA MQTT addons. +Now OpenMower is connected to your HA MQTT addons. You can check with [MQTT Explorer](http://mqtt-explorer.com/)