Last active
January 7, 2022 12:08
-
-
Save gtrabanco/476bc119448319a1db510f6948361f47 to your computer and use it in GitHub Desktop.
Configuración extendida para robot aspiradores de Valetudo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Vacuum-extended-config | |
# Versión: 1.0.0 | |
# Autor: Gabriel Trabanco Llano <[email protected]> | |
# https://github.com/gtrabanco https://keybase.io/gtrabanco | |
# LICENCIA: SIN LICENCIA. Haz lo que quieras pero la atribución es bien recibida | |
# por mi ego. | |
# | |
# There is a english version here: https://gist.github.com/gtrabanco/87320443dcd30ac10990f87b0c423e19 | |
# Puedes agregar este archivo por partes incrustandolo en tu configuración por partes o | |
# puedes agregar el archivo entero como un paquete: | |
# homeassistant: | |
# packages: | |
# vacuum: !include vacuum.yaml | |
# ESTE ARCHIVO NECESITA CAMBIOS POR TU PARTE | |
# · Primeramente tienes que cambiar <vacuum_ip_or_ha_ip> por la ip donde tengas Valetudo | |
# instalado ya que puede ser tu misma aspiradora o bien en Home Assistant si usas el addon | |
# congatudo. En este último caso debes habilitar el acceso externo del addon, en mi caso | |
# he usado el puerto 18080 ya que el 80 y el 8080 los tengo ocupados con otros addons. | |
# · Por la misma razón que lo anterior y por lo que se dice del puerto tienes que cambiar | |
# <valetudo_port> por el puerto. Si tienes valetudo en la conga puedes borrar (incluyendo | |
# los dos puntos previos o puedes añadir "80" sin las comillas. Lo del puerto en Congatudo | |
# se explica en este artículo (en inglés): | |
# - https://freecon.ga/blog/get-area-and-time-in-ha-from-valetudo/ | |
# · MULTIPLES ASPIRADORAS: Si tienes varias. Debes cambiar el prefijo "aspiradora_" de todas | |
# las entidades para que el nombre de la entidad sea distinto y añadir tantos archivos de | |
# configuración como aspiradoras tengas en casa. | |
# · Tienes que cambiar el prefijo de valetudo y el identificador de la conga al que corresponda | |
# para tu aspiradora, en este archivo suponemos que el prefijo es "valetudo" y el identificador | |
# es "robot". | |
# · Cambiar la entidad de tu aspiradora por la que corresponga, aquí hemos supuesto que la entidad | |
# de tu aspiradora es "vacuum.robot". | |
# REQUISITOS PARA LAS NOTIFICACIONES | |
# He metido notificaciones accionables (actionalbe notifications) en las notificaciones que se | |
# envian cuando hay un mapa pendiente pero requiere de configuración manual por tu parte. Estas | |
# notificaciones permiten aceptar un mapa nuevo cuando hay un mapa pendiente. | |
# Requisitos: | |
# · Home Assistant > 2021.05 | |
# · Aplicación móvil de Home Assistant para iOS o Android | |
# · NODE-RED con la paleta `node-red-contrib-valetudo` | |
# · Este flow que tiene comentarios sobre cosas que debes configurar manualmente. | |
# [{"id":"68cdb83722fb413c","type":"tab","label":"Vacuum: Save map","disabled":false,"info":"Save current map to a png file in:\n/share/vacuum/current_map.png","env":[]},{"id":"3e8d57cacbf1b976","type":"mqtt in","z":"68cdb83722fb413c","name":"<valetudo_prefix>/<vacuum_identifier>/MapData/map-data","topic":"<valetudo_prefix>/<vacuum_identifier>/MapData/map-data","qos":"0","datatype":"auto","broker":"a0efc2dff11d94d6","nl":false,"rap":true,"rh":0,"inputs":0,"x":280,"y":140,"wires":[["983c7005bc28067a"]]},{"id":"e4f72565521ec2cf","type":"file","z":"68cdb83722fb413c","name":"/media/vacuum/current_map.png","filename":"/media/vacuum/current_map.png","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":940,"y":140,"wires":[[]]},{"id":"983c7005bc28067a","type":"valetudo-map-png","z":"68cdb83722fb413c","name":"","drawPath":true,"drawCharger":true,"drawRobot":true,"scale":4,"defer":2000,"cropX1":"","cropX2":"","cropY1":"","cropY2":"","x":650,"y":140,"wires":[["e4f72565521ec2cf","1a868008115d7360"]]},{"id":"e27d3dc13af41951","type":"comment","z":"68cdb83722fb413c","name":"Change the topic - Cambiar el topic","info":"The topic for your conga can be other and not this one, is probable: valetudo/robot...\nYou may change only until second slash \"/\" (not included the slash).\nTo know yours you can use mqtt explorer or see it in \"Congatudo Addon\" > \"Settings\" > \"MQTT\"\n\nUntil the first slash \"/\" is, in the absolute botton, the option \"Topic prefix\".\n\nThe next word (\"robot\" in my case), is the \"Identifier\".\n\n--\n\nEl topic para tu conga no tiene porque ser este, es probable que sea: valetudo/robot...\nSolo deberías cambiar hasta la segunda barra (no incluida).\nPuedes usar mqtt explorer para averiguarlo o verlo en el addon de congatudo > settings > mqtt\n\nHasta la primera barra \"/\" está abajo del todo, es la opción que se llama \"Topic prefix\".\n\nLo que va después (\"robot\" en mi caso) de la primera barra es el \"Identifier\".\n","x":270,"y":100,"wires":[]},{"id":"ace748d133cdfa03","type":"comment","z":"68cdb83722fb413c","name":"Path to store the map - Almacenar el mapa","info":"Here the path to the map. Important check that is checked \"Create Directory If It Doesn't Exist?\".\n\nTo used this map with actionable notifications you need to store on `/media` path.\n\n--\n\nAqui la ruta al mapa. Es importante que compruebes que está marcado \"Create Directory If It Doesn't Exist?\".\n\nPara ver el mapa en las notificaciones, necesitas almacenar el mapa en `/media`.\n","x":640,"y":100,"wires":[]},{"id":"932a6df3e920f0fb","type":"comment","z":"68cdb83722fb413c","name":"Save Map as file","info":"You should change:\n- \"valetudo\" for your vaccum topic.\n- \"robot\" for your vacuum identifier.\n","x":130,"y":60,"wires":[]},{"id":"1a868008115d7360","type":"base64","z":"68cdb83722fb413c","name":"","action":"","property":"payload","x":860,"y":200,"wires":[["22de8811fba8cde6"]]},{"id":"22de8811fba8cde6","type":"change","z":"68cdb83722fb413c","name":"","rules":[{"t":"set","p":"vacuum_current_map","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":200,"wires":[[]]},{"id":"a0efc2dff11d94d6","type":"mqtt-broker","name":"Home Assistant MQTT","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}] | |
# Probado con Home Assistant: 2021.12.5, 2021.12.8 | |
# Notificaciones probadas con la aplicación Home Assistant para iOS | |
# Por favor, notificar fallos en los comentarios. | |
rest: | |
- scan_interval: 5 | |
resource: "http://<valetudo_or_ha_ip>:<valetudo_port>/api/v2/robot/state/attributes" | |
sensor: | |
- name: "Vacuum current clean area" | |
state_class: "measurement" | |
json_attributes_path: "$[4]" | |
json_attributes: | |
- __class | |
- metadata | |
- type | |
- value | |
value_template: >- | |
{% set current_value = int(value_json[4]['value'], 0) %} | |
{% if current_value > 0 %} | |
{{ current_value | float / 10000 }} | |
{% else %} | |
{{ current_value | float }} | |
{% endif %} | |
- name: "Vacuum current clean duration" | |
state_class: "total" | |
json_attributes_path: "$[3]" | |
json_attributes: | |
- __class | |
- metadata | |
- type | |
- value | |
value_template: >- | |
{{ int(value_json[3]['value'],0) }} | |
rest_command: | |
vacuum_accept_map: | |
url: "http://<valetudo_or_ha_ip>:<valetudo_port>/api/v2/robot/capabilities/PendingMapChangeHandlingCapability" | |
method: PUT | |
verify_ssl: false | |
content_type: "application/x-www-form-urlencoded" | |
payload: 'action=accept' | |
binary_sensor vacuum_pending_map: | |
platform: rest | |
scan_interval: 3 | |
name: "Vacuum has pending map" | |
resource: "http://<valetudo_or_ha_ip>:<valetudo_port>/api/v2/robot/capabilities/PendingMapChangeHandlingCapability" | |
value_template: >- | |
{{ value_json['pending'] }} | |
binary_sensor vacuum_mop_attached: | |
platform: mqtt | |
name: "Vacuum Mop Attached" | |
# Change for yours <vacuum_mqtt_prefix>/<vacuum_identifier>/AttachmentStateAttribute/mop | |
state_topic: "valetudo/robot/AttachmentStateAttribute/mop" | |
payload_on: "true" | |
payload_off: "false" | |
qos: 0 | |
binary_sensor vacuum_dustbin_attached: | |
platform: mqtt | |
name: "Vacuum Dustbin Attached" | |
# Change for yours <vacuum_mqtt_prefix>/<vacuum_identifier>/AttachmentStateAttribute/dustbin | |
state_topic: "valetudo/robot/AttachmentStateAttribute/dustbin" | |
payload_on: "true" | |
payload_off: "false" | |
qos: 0 | |
binary_sensor vacuum_watertank_attached: | |
platform: mqtt | |
name: "Vacuum Watertank Attached" | |
# Change for yours <vacuum_mqtt_prefix>/<vacuum_identifier>/AttachmentStateAttribute/watertank | |
state_topic: "valetudo/robot/AttachmentStateAttribute/watertank" | |
payload_on: "true" | |
payload_off: "false" | |
qos: 0 | |
sensor vacuum_today_cleaning_number: | |
platform: history_stats | |
name: "Vacuum today total cleanings" | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
state: "cleaning" | |
type: "count" | |
start: "{{ now().replace(hour=0, minute=0, second=0) }}" | |
end: "{{ now() }}" | |
sensor vacuum_today_cleaning_time: | |
platform: history_stats | |
name: "Vacuum total time cleaning today" | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
state: "cleaning" | |
type: "time" | |
start: "{{ now().replace(hour=0, minute=0, second=0) }}" | |
end: "{{ now() }}" | |
input_number: | |
vacuum_last_clean_area: | |
name: "Vacuum last clean area" | |
icon: "mdi:texture-box" | |
min: 0 | |
max: 9999999 | |
step: 1 | |
mode: box | |
vacuum_last_clean_duration: | |
name: "Vacuum last clean duration" | |
icon: "mdi:timer" | |
min: 0 | |
max: 9999999 | |
step: 1 | |
mode: box | |
script: | |
vacuum_accept_pending_map: | |
alias: Vacuum Accept Pending Map | |
sequence: | |
- service: rest_command.vacuum_accept_map | |
- delay: | |
hours: 0 | |
minutes: 0 | |
seconds: 3 | |
milliseconds: 0 | |
- service: rest.reload | |
- service: persistent_notification.dismiss | |
data: | |
notification_id: "vacuum_pending_map" | |
mode: single | |
icon: "mdi:map-check-outline" | |
automation: | |
- alias: "Vacuum: Accept Pending Map" | |
description: "Accept pending map when accepted through notification" | |
trigger: | |
- platform: event | |
event_type: mobile_app_notification_action | |
event_data: | |
action: "ACCEPT_VACUUM_PENDING_MAP" | |
condition: | |
- condition: state | |
entity_id: binary_sensor.vacuum_has_pending_map | |
state: 'on' | |
action: | |
- service: rest_command.vacuum_accept_map | |
- alias: 'Vacuum: Dismiss Pending Map Notifications' | |
description: 'Dismiss all possible to dismiss notifications when pending map is set to off' | |
trigger: | |
- platform: state | |
entity_id: binary_sensor.vacuum_has_pending_map | |
to: 'off' | |
from: 'on' | |
condition: | |
- condition: state | |
entity_id: binary_sensor.vacuum_has_pending_map | |
state: "off" | |
action: | |
- service: persistent_notification.dismiss | |
data: | |
notification_id: "vacuum_pending_map" | |
- service: notify.notify | |
data: | |
message: "clear_notification" | |
data: | |
tag: "vacuum_pending_map" | |
- alias: 'Vacuum: Notify Pending Map' | |
description: 'Notify if the vacuum has a pending map to be accepted' | |
trigger: | |
- platform: state | |
entity_id: binary_sensor.vacuum_has_pending_map | |
- platform: homeassistant | |
event: start | |
- platform: state | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
condition: | |
- condition: and | |
conditions: | |
- condition: state | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
state: docked | |
- condition: state | |
entity_id: binary_sensor.vacuum_has_pending_map | |
state: 'on' | |
action: | |
- service: persistent_notification.create | |
data: | |
notification_id: "vacuum_pending_map" | |
title: "Vacuum: Pending Map" | |
message: "The map of your vacuum should be accepted by running the script [`script.vacuum_accept_pending_map`](/config/script/dashboard)." | |
- service: notify.notify | |
data: | |
message: "Do you want to accept this map?" | |
title: "Vacuum map changed" | |
data: | |
tag: "vacuum_pending_map" | |
url: “/config/script/dashboard” | |
# To work this requires NODE-RED with the palette `node-red-contrib-valetudo` | |
# and also with the flow: | |
# [{"id":"68cdb83722fb413c","type":"tab","label":"Vacuum: Save map","disabled":false,"info":"Save current map to a png file in:\n/share/vacuum/current_map.png","env":[]},{"id":"3e8d57cacbf1b976","type":"mqtt in","z":"68cdb83722fb413c","name":"<valetudo_prefix>/<vacuum_identifier>/MapData/map-data","topic":"<valetudo_prefix>/<vacuum_identifier>/MapData/map-data","qos":"0","datatype":"auto","broker":"a0efc2dff11d94d6","nl":false,"rap":true,"rh":0,"inputs":0,"x":280,"y":140,"wires":[["983c7005bc28067a"]]},{"id":"e4f72565521ec2cf","type":"file","z":"68cdb83722fb413c","name":"/media/vacuum/current_map.png","filename":"/media/vacuum/current_map.png","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":940,"y":140,"wires":[[]]},{"id":"983c7005bc28067a","type":"valetudo-map-png","z":"68cdb83722fb413c","name":"","drawPath":true,"drawCharger":true,"drawRobot":true,"scale":4,"defer":2000,"cropX1":"","cropX2":"","cropY1":"","cropY2":"","x":650,"y":140,"wires":[["e4f72565521ec2cf","1a868008115d7360"]]},{"id":"e27d3dc13af41951","type":"comment","z":"68cdb83722fb413c","name":"Change the topic - Cambiar el topic","info":"The topic for your conga can be other and not this one, is probable: valetudo/robot...\nYou may change only until second slash \"/\" (not included the slash).\nTo know yours you can use mqtt explorer or see it in \"Congatudo Addon\" > \"Settings\" > \"MQTT\"\n\nUntil the first slash \"/\" is, in the absolute botton, the option \"Topic prefix\".\n\nThe next word (\"robot\" in my case), is the \"Identifier\".\n\n--\n\nEl topic para tu conga no tiene porque ser este, es probable que sea: valetudo/robot...\nSolo deberías cambiar hasta la segunda barra (no incluida).\nPuedes usar mqtt explorer para averiguarlo o verlo en el addon de congatudo > settings > mqtt\n\nHasta la primera barra \"/\" está abajo del todo, es la opción que se llama \"Topic prefix\".\n\nLo que va después (\"robot\" en mi caso) de la primera barra es el \"Identifier\".\n","x":270,"y":100,"wires":[]},{"id":"ace748d133cdfa03","type":"comment","z":"68cdb83722fb413c","name":"Path to store the map - Almacenar el mapa","info":"Here the path to the map. Important check that is checked \"Create Directory If It Doesn't Exist?\".\n\nTo used this map with actionable notifications you need to store on `/media` path.\n\n--\n\nAqui la ruta al mapa. Es importante que compruebes que está marcado \"Create Directory If It Doesn't Exist?\".\n\nPara ver el mapa en las notificaciones, necesitas almacenar el mapa en `/media`.\n","x":640,"y":100,"wires":[]},{"id":"932a6df3e920f0fb","type":"comment","z":"68cdb83722fb413c","name":"Save Map as file","info":"You should change:\n- \"valetudo\" for your vaccum topic.\n- \"robot\" for your vacuum identifier.\n","x":130,"y":60,"wires":[]},{"id":"1a868008115d7360","type":"base64","z":"68cdb83722fb413c","name":"","action":"","property":"payload","x":860,"y":200,"wires":[["22de8811fba8cde6"]]},{"id":"22de8811fba8cde6","type":"change","z":"68cdb83722fb413c","name":"","rules":[{"t":"set","p":"vacuum_current_map","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":200,"wires":[[]]},{"id":"a0efc2dff11d94d6","type":"mqtt-broker","name":"Home Assistant MQTT","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}] | |
image: "/media/local/vacuum/current_map.png" | |
actions: | |
- action: "ACCEPT_VACUUM_PENDING_MAP" | |
title: "Accept" | |
actiovationMode: "background" | |
icon: "mdi:map-check-outline" | |
activationMode: "background" | |
authenticationRequired: true | |
destructive: no | |
- action: "ACCEPT_VACUUM_PENDING_MAP" | |
title: "Dismiss" | |
activationMode: "background" | |
authenticationRequired: false | |
destructive: true | |
- action: "URI" | |
title: "Execute manually on App" | |
uri: "/config/script/dashboard" | |
- alias: 'Vacuum: Last Clean Area' | |
description: 'Update vacuum last clean area' | |
trigger: | |
- platform: state | |
entity_id: sensor.vacuum_current_clean_area | |
- platform: state | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
to: cleaning | |
for: | |
hours: 0 | |
minutes: 0 | |
seconds: 2 | |
#entity_id: sensor.vacuum_current_clean_area | |
condition: | |
- condition: or | |
conditions: | |
- condition: numeric_state | |
entity_id: sensor.vacuum_current_clean_area | |
above: '0' | |
- condition: state | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
state: cleaning | |
action: | |
- service: input_number.set_value | |
data_template: | |
entity_id: input_number.vacuum_last_clean_area | |
value: >- | |
{{ states("sensor.vacuum_current_clean_area") | float(default=0) }} | |
mode: single | |
- alias: 'Vacuum: Update last Clean Duration' | |
description: 'Update vacuum last clean duration time' | |
trigger: | |
- platform: state | |
entity_id: sensor.vacuum_current_clean_duration | |
- platform: state | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
to: cleaning | |
for: | |
hours: 0 | |
minutes: 0 | |
seconds: 2 | |
condition: | |
- condition: or | |
conditions: | |
- condition: numeric_state | |
entity_id: sensor.vacuum_current_clean_duration | |
above: '0' | |
- condition: state | |
# Change for your vacuum entity | |
entity_id: vacuum.robot | |
state: cleaning | |
action: | |
- service: input_number.set_value | |
data_template: | |
entity_id: input_number.vacuum_last_clean_duration | |
value: >- | |
{{ int(states("sensor.vacuum_current_clean_duration"),0) }} | |
mode: single |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment