Trigger something for every X square meters vacuumed

Hahahaha, I love it! :joy:

I forgot to mention that Iā€™ve had a few false triggers with my latest code posted here. Sometimes XIaomi Miio times out making the sensors render as unavailable which also triggers the automation.

I had to add a few conditions like this so it would only trigger when the total_clean_area increases in value:

  trigger:
    entity_id: sensor.robocop_total_clean_area
    platform: state
  condition: 
    - condition: template
      value_template: >
        {{ trigger.from_state is not none and 
           trigger.to_state is not none and
           trigger.from_state.state not in ["unavailable"] and  
           trigger.to_state.state | float(0) > trigger.from_state.state | float(0)
        }}

Thanks @oscacrb,

I had the same issue so i used your code, thanks!
One little note,
Iā€™m dividing by 60 so it wonā€™t trigger the cleanup automaiton every time.

BTW, iā€™m currently sending myself a notification with the {{trigger.to_state.state}} and {{trigger.from_state.state}} to see what numbers are outputing (for debug purposes).

I couldnā€™t find an easier way to look for what those numbers were when i want to debug an automation.
Is there anyway to see what was the value of the ā€œtrigger.to_state.stateā€ and ā€œtrigger.from_state.stateā€ when the automation was triggered? i canā€™t see it from the debug screen.

In the automation debugger, with the first step selected open ā€œChanged Variablesā€ and look for trigger > from_state > state and to_state > state respectively.

Iā€™m awaiting delivery of my Roborock and found this thread, which is exactly what I wanted to do! :slightly_smiling_face:

@zivgin Would you mind sharing your full latest code please as your solution sounds great! (I think the script.vacuum_maintenance_trash_can is missing from above, would be great to see! (I know how to get the co-ordinates))

It stopped working for me again ):
Let me troubleshoot it and get back to you.

What part of the code do you need BTW?

Using the above code as a basis. Iā€™ve been able to get my S5 Max working, itā€™s okay, however when moving between floors has some downsidesā€¦. E.g. moving the vacuum to a different floor which isnā€™t vacuumed as much, it always needs emptying afterwards or when mopping the floors after vacuuming the below calc is not always accurate. Iā€™m thinking it needs some kind of ā€œIā€™ve emptied the binā€ variable/resetā€¦ maybe storing to/from m2 into input variables, looking at the mop attached sensor (not including m2 into bin calc when mopping) and calculating from there may work (I need to think about it some more EDIT: Iā€™ve made some changes on my dev automation which now uses a input_number helper and only addā€™s to the bin level when mop is not attached. I can also zero the value to manually update or via Alexa :slightly_smiling_face: - running it alongside the below for a few days to check it works as expected, then can post here.)

alias: Vacuum - Move Sandy to bin for emptying after 60sq
description: This sends Sandy to the dustbin to wait to be cleaned.
trigger:
  - platform: state
    entity_id: sensor.sandy_total_clean_area
condition:
  - condition: template
    value_template: >-
      {{ int(trigger.to_state.state) // 60 > int(trigger.from_state.state) // 60 }}
  - condition: template
    value_template: |-
      {{ trigger.from_state is not none and 
         trigger.to_state is not none and
         trigger.from_state.state not in ["unavailable"] and  
         trigger.to_state.state | float(0) > trigger.from_state.state | float(0)
      }}
action:
  - wait_template: |-
      {% if state_attr('vacuum.sandy', 'battery_level') == 100 %}
        true
      {% else %}
        false
      {% endif %}
    continue_on_timeout: false
  - wait_template: >-
      {% if ((now().strftime('%H:%M')) > "07:30") and ((now().strftime('%H:%M'))
      < "22:00") %}
        true
      {% else %}
        false
      {%endif%}
  - wait_template: >-
      {% if states('person.me') == 'home' or states('person.partner') == 'home' %}
        true
      {% else %}
        false
      {% endif %}
  - service: script.vacuum_dustbin
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
  - service: notify.mobile_app_iphone
    data:
      message: >-
        Sandy is waiting for you next to the dust bin, please empty the bin and
        send her back to the dock.
      title: Please clean Sandy
  - service: input_datetime.set_datetime
    target:
      entity_id: input_datetime.sandy_last_emptied
    data:
      datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
mode: single


@zivgin The changes Iā€™ve added are to wait until the battery is 100% before moving Sandy, the formatting of the calculation (it went back every time originally) and added a wait so Sandy only moves to the bin if myself or my partner are home.

Hereā€™s the other script which makes sure the correct map is loaded before moving to the bin


alias: Vacuum - Dustbin
sequence:
  - service: vacuum.send_command
    data:
      command: load_multi_map
      params: 0
    target:
      entity_id: vacuum.sandy
  - service: vacuum.send_command
    data:
      command: app_goto_target
      params:
        - 24900
        - 29660
    target:
      entity_id: vacuum.sandy
mode: single
icon: mdi:trash-can


youā€™re good. i like it.
Iā€™ve just worked on mine today and got it to work, something with the float\int formating didnā€™t work well and the values were still kept as string so the ā€œis biggerā€ equation failed.

I use helpers to keep the last time this automaton run, but when you think about it, you donā€™t need it, as you can simply check the last time the automation itself ranā€¦

Regarding the 100% battery. not sure i understand whyā€¦ if itā€™s wait for you next to the dust bin, how quickly does the battery drain while itā€™s in idle mode?
If you really want to solve the battery problem, i would go for the exact opposite approach which is:
ā€œWait for me next to the bin, until battery is lower then X (say 30%), if battery goes below X (say 30%), go back to the dock until you reach Y battery (say 60%), and then go back to the trashā€.

In that way, it will never run out of battery even if youā€™re on vacationā€¦ as it always knows to go back and charge itself when itā€™s needed.

I have roborock 5s (not max) so the ā€œwater bucketā€ or ā€œdust binā€ sensors doesnā€™t work :
if it works for you, you can simply trigger automation that updates when the dust bin had been emptied when dust bin had been removed.

I figured if the battery is fully charged, the vacuum will always be ready for the next clean, regardless of how long itā€™s left but in reality, I added it because I could more than anything! (whilst playing with the code and vaccum :slight_smile: )

Hereā€™s my v2 which uses the helper to store the value and allows the counter to be reset should I empty it after cleaning a different floor (Iā€™ll set it in a script so I can just ask Alexa to reset it when needed)

I have sensors for water_box_attached and mop_attached but whilst there is a sensor for the bin (as the vacuum speaks when itā€™s taken out) it doesnā€™t seem to be exposed as an entity for some reason!? (which looks to be an oversight?)

alias: >-
  Vacuum - Send Sandy to bin location after 60sqm of cleaning without mop
  attached
description: >-
  After each completed clean, whilst the mop is not attached, add the last
  cleaned area sqm to input_number helper, check if total sqm is 60 or over, if
  so, check/wait for battery to be fully charged, check/wait until it's after
  07:30 and before 22:00, check/wait until one of the parents are home, then
  send vacuum to the waste bin location, wait 20 seconds, then send a message to
  iPhone, reset the input_number sqm (bin) to zero and record the time/date for
  reference.
trigger:
  - platform: state
    entity_id: sensor.sandy_total_clean_area
condition:
  - condition: template
    value_template: |-
      {{ trigger.from_state is not none and 
         trigger.to_state is not none and
         trigger.from_state.state not in ["unavailable"] and  
         trigger.to_state.state | float(0) > trigger.from_state.state | float(0)
      }}
  - condition: state
    entity_id: binary_sensor.sandy_mop_attached
    state: 'off'
action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.sandy_bin_level
      value: >-
        {{ states('input_number.sandy_bin_level')|float +
        states('sensor.sandy_last_clean_area')|float }}
  - choose:
      - conditions:
          - condition: template
            value_template: |-
              {% if states.input_number.sandy_bin_level.state|float >= 60 %}
                true
              {% else %}
                false
              {% endif %}
        sequence:
          - wait_template: |-
              {% if state_attr('vacuum.sandy', 'battery_level') == 100 %}
                true
              {% else %}
                false
              {% endif %}
          - wait_template: >-
              {% if ((now().strftime('%H:%M')) > "07:30") and
              ((now().strftime('%H:%M')) < "22:00") %}
                true
              {% else %}
                false
              {%endif%}
          - wait_template: >-
              {% if states('person.me') == 'home' or states('person.partner) ==
              'home' %}
                true
              {% else %}
                false
              {% endif %}
          - service: script.vacuum_dustbin
            data: {}
          - delay:
              hours: 0
              minutes: 0
              seconds: 20
              milliseconds: 0
          - service: notify.mobile_app_iphone
            data:
              message: >-
                Sandy is waiting for you next to the dust bin, please empty the
                bin and send her back to the dock.
              title: Please clean Sandy
          - service: input_number.set_value
            data_template:
              entity_id: input_number.sandy_bin_level
              value: '{{ 0 }}'
          - service: input_datetime.set_datetime
            target:
              entity_id: input_datetime.sandy_last_emptied
            data:
              datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
    default: []
mode: single

Looks good overall.
This is mine (iā€™ve took the ā€œwaiting for battery to fill upā€ part).

alias: Alfred Notifying When he's Full After 60sq
description: This sends Alfred to the trash can to wait to be cleaned.
trigger:
  - platform: state
    entity_id: sensor.roborock_vacuum_s5_total_clean_area
condition:
  - condition: template
    value_template: |-
      {{ trigger.from_state is not none and 
                 trigger.to_state is not none and
                 trigger.from_state.state not in ["unavailable"] and  
                 (trigger.to_state.state|float /60) | int > (trigger.from_state.state|float /60 )| int
              }}
action:
  - wait_template: |-
      {% if states('vacuum.alfred') == "docked" %}
        True
      {% else %}
        False
      {% endif %}
    timeout: '3:00'
    continue_on_timeout: true
  - wait_template: |-
      {% if state_attr('vacuum.alfred', 'battery_level') > 85%}
              true
            {% else %}
              false
            {% endif %}
    timeout: '13:00'
  - wait_template: >-
      {% if ((now().strftime('%H:%M')) > "08:40") and ((now().strftime('%H:%M'))
      < "20:30") %}

      true

      {% else %}

      false

      {%endif%}
    timeout: '13:00'
  - service: script.vacuum_maintenance_trash_can
    data: {}
  - delay:
      hours: 0
      minutes: 1
      seconds: 10
      milliseconds: 0
  - service: notify.mobile_app_michal_iphone_12
    data:
      message: >-
        Alfred is waiting for you next to the trash can, please empty the bin
        and send Alfred back to the dock.
      title: Please Clean Alfred
  - service: input_datetime.set_datetime
    target:
      entity_id: input_datetime.alfred_last_emptied
    data:
      date: '{{ now().strftime("%d/%m/%y") }}'
      time: '{{ now().strftime("%H:%M:%S") }}'
mode: single

Thanks a lot for all the good information in this thread. Iā€™ve set up a similar automation in Node-Red. At the end of each clean, the vacuum will check to see if total area cleaned has increased by a multiple of 60M2. If it has, and one of us is home during daylight hours, and the battery level is greater than 20%, it parks next to our bin and the person at home is notified. If we donā€™t empty it and then send it home within 3 hours, it returns itself to dock.
If nobody was home when it finished cleaning, it will check to see if someone is home once a minute, and if someone arrives home during daylight hours, it will head back to the dustbin, once again for a max of 3 hours.
If it finished a clean outside of daylight hours, it will go back to the dock, and when motion is detected in our living room the next morning, it will return to the rubbish bin. If we fail to empty it, weā€™re again notified.

Obviously many parts of the flow will be useless to others, but for anyone whoā€™s interested, youā€™ll be able to see how every step was achieved. Iā€™m relatively new to Node-Red, so there will definitely be cleaner ways of achieving things but iā€™ve tested the flow and Iā€™m happy with it so far.

[{"id":"04b5da70ea694834","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"916c267050e49453","type":"api-current-state","z":"04b5da70ea694834","name":"Total cleaned area","server":"8a644e13.f9644","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.roborock_s6_maxv_total_clean_area","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"Area_Before_Clean","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":280,"wires":[["29c3b0b992071e91"]]},{"id":"7a0b8f486105cf01","type":"server-state-changed","z":"04b5da70ea694834","name":"Vacuum starts cleaning","server":"8a644e13.f9644","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"vacuum.roborock_s6_maxv","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"cleaning","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":280,"wires":[["916c267050e49453"],[]]},{"id":"3ec8e251ad25cb40","type":"api-current-state","z":"04b5da70ea694834","name":"Total cleaned area","server":"8a644e13.f9644","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.roborock_s6_maxv_total_clean_area","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"Area_After_Clean","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":360,"wires":[["29c3b0b992071e91"]]},{"id":"29c3b0b992071e91","type":"join","z":"04b5da70ea694834","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":320,"wires":[["ce607065b439e352"]]},{"id":"ce607065b439e352","type":"function","z":"04b5da70ea694834","name":"SET METER CHECK HERE (60)","func":"msg.payload = ((msg.payload.Area_After_Clean / 60 - msg.payload.Area_Before_Clean / 60).toFixed(0));\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":320,"wires":[["fca6da530fa30692","3e1508894b84b3f3"]]},{"id":"d27c362bad60c134","type":"server-state-changed","z":"04b5da70ea694834","name":"Vacuum finishes cleaning","server":"8a644e13.f9644","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"vacuum.roborock_s6_maxv","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"returning","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":360,"wires":[["3ec8e251ad25cb40"],[]]},{"id":"fca6da530fa30692","type":"switch","z":"04b5da70ea694834","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1010,"y":320,"wires":[["e7ee9f587c2c2f1f"],["dba1bed3dca0de1e"]]},{"id":"dba1bed3dca0de1e","type":"api-current-state","z":"04b5da70ea694834","name":"Person 1 home?","server":"8a644e13.f9644","version":3,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","entity_id":"person.jordan","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":610,"y":420,"wires":[["062088199e55c657"],["548496f9be459152"]]},{"id":"548496f9be459152","type":"api-current-state","z":"04b5da70ea694834","name":"Person 2 home?","server":"8a644e13.f9644","version":3,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","entity_id":"person.lauren","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":510,"y":540,"wires":[["644632fe2380b5ee"],["6d408ce7c2f042ea"]]},{"id":"db4ab86588fc2b9a","type":"api-call-service","z":"04b5da70ea694834","name":"Go to bin","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"xiaomi_miio","service":"vacuum_goto","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"{\"x_coord\":\"34634\",\"y_coord\":\"28777\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1420,"y":260,"wires":[["05037953ba416f17","3da490e7f4d15300","72cc97e3ea5dd4f8","9a6ac0fb60ce699b"]]},{"id":"05037953ba416f17","type":"api-current-state","z":"04b5da70ea694834","name":"Is TV on?","server":"8a644e13.f9644","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"media_player.lg_webos_tv","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":260,"wires":[["ee812168fab914fd"],[]]},{"id":"3da490e7f4d15300","type":"api-current-state","z":"04b5da70ea694834","name":"desktop being used?","server":"8a644e13.f9644","version":3,"outputs":2,"halt_if":"PowerOn","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.desktop_monitorpowerstate","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1620,"y":300,"wires":[["4608fb28b259b21f"],[]]},{"id":"ee812168fab914fd","type":"api-call-service","z":"04b5da70ea694834","name":"","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"notify","service":"television","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Vacuum needs emptying.\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1840,"y":260,"wires":[[]]},{"id":"4608fb28b259b21f","type":"api-call-service","z":"04b5da70ea694834","name":"","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"notify","service":"desktop","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Vacuum needs emptying\",\"title\":\"\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1840,"y":300,"wires":[[]]},{"id":"72cc97e3ea5dd4f8","type":"change","z":"04b5da70ea694834","name":"Set msg","rules":[{"t":"set","p":"message","pt":"msg","to":"Vaccum needs emptying.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1580,"y":220,"wires":[["0e85a496a9e11d57"]]},{"id":"0e85a496a9e11d57","type":"api-call-service","z":"04b5da70ea694834","name":"notify.","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_oneplus_6t_bbe","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{message}}\",\"data\":{\"actions\":[{\"action\":\"{{action1}}\",\"title\":\"{{actionTitle1}}\",\"icon\":\"sfsymbols:bell\"},{\"action\":\"{{action2}}\",\"title\":\"{{actionTitle2}}\"}],\"ttl\":0,\"priority\":\"high\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1810,"y":220,"wires":[[]]},{"id":"d236f921f6fbec5f","type":"api-current-state","z":"04b5da70ea694834","name":"Is TV on?","server":"8a644e13.f9644","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"media_player.lg_webos_tv","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1560,"y":540,"wires":[["0267012b1f03bf20"],[]]},{"id":"0267012b1f03bf20","type":"api-call-service","z":"04b5da70ea694834","name":"","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"notify","service":"television","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Vaccum needs emptying\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1720,"y":540,"wires":[[]]},{"id":"ae9cc91a5b6518c8","type":"change","z":"04b5da70ea694834","name":"Set msg","rules":[{"t":"set","p":"message","pt":"msg","to":"Vaccum needs emptying.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1560,"y":500,"wires":[["89a513f3750d920c"]]},{"id":"89a513f3750d920c","type":"api-call-service","z":"04b5da70ea694834","name":"notify.","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_loz21fe","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{message}}\",\"data\":{\"actions\":[{\"action\":\"{{action1}}\",\"title\":\"{{actionTitle1}}\",\"icon\":\"sfsymbols:bell\"},{\"action\":\"{{action2}}\",\"title\":\"{{actionTitle2}}\"}],\"ttl\":0,\"priority\":\"high\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1690,"y":500,"wires":[[]]},{"id":"351276abca7c4ba2","type":"api-call-service","z":"04b5da70ea694834","name":"Go to bin","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"xiaomi_miio","service":"vacuum_goto","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"{\"x_coord\":\"34634\",\"y_coord\":\"28777\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1380,"y":540,"wires":[["ae9cc91a5b6518c8","d236f921f6fbec5f","31f81969e12bccbb"]]},{"id":"f7618b52c42f6419","type":"switch","z":"04b5da70ea694834","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":700,"wires":[["7160ec99feea984e"],["cf9820c2c6eec420"]]},{"id":"6d408ce7c2f042ea","type":"ha-get-entities","z":"04b5da70ea694834","name":"How many people home?","server":"8a644e13.f9644","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"person","valueType":"str"},{"property":"state","logic":"is","value":"home","valueType":"str"}],"output_type":"count","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":250,"y":700,"wires":[["f7618b52c42f6419"]]},{"id":"cfd35ffce5862f2c","type":"api-call-service","z":"04b5da70ea694834","name":"Go to bin","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"xiaomi_miio","service":"vacuum_goto","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"{\"x_coord\":\"34634\",\"y_coord\":\"28777\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1400,"y":700,"wires":[["4e85ffba5a31a649"]]},{"id":"cf9820c2c6eec420","type":"delay","z":"04b5da70ea694834","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":260,"y":800,"wires":[["6d408ce7c2f042ea"]]},{"id":"7160ec99feea984e","type":"time-range-switch","z":"04b5da70ea694834","name":"","lat":"","lon":"","startTime":"07:00","endTime":"20:00","startOffset":0,"endOffset":0,"x":640,"y":700,"wires":[["42dc51c86da4a329"],["febfbe98250e14a5"]]},{"id":"febfbe98250e14a5","type":"ha-wait-until","z":"04b5da70ea694834","name":"Motion in living room","server":"8a644e13.f9644","version":2,"outputs":1,"entityId":"binary_sensor.zone_zone_02_open","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"0","timeoutType":"num","timeoutUnits":"seconds","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":340,"y":960,"wires":[["4bd1e8d33daf18b6"]]},{"id":"4bd1e8d33daf18b6","type":"time-range-switch","z":"04b5da70ea694834","name":"","lat":"","lon":"","startTime":"05:00","endTime":"12:00","startOffset":0,"endOffset":0,"x":560,"y":900,"wires":[["0d45455f42b2a985"],["febfbe98250e14a5"]]},{"id":"394f9fbe43ed3603","type":"api-call-service","z":"04b5da70ea694834","name":"Go to bin","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"xiaomi_miio","service":"vacuum_goto","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"{\"x_coord\":\"34634\",\"y_coord\":\"28777\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1240,"y":920,"wires":[["ed5e0a531bd9148c"]]},{"id":"9a6ac0fb60ce699b","type":"ha-wait-until","z":"04b5da70ea694834","name":"Not returned after 3 hrs?","server":"8a644e13.f9644","version":2,"outputs":2,"entityId":"vacuum.roborock_s6_maxv","entityIdFilterType":"exact","property":"state","comparator":"is","value":"returning","valueType":"str","timeout":"3","timeoutType":"num","timeoutUnits":"hours","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":1570,"y":360,"wires":[[],["df4147cd7693e4d3"]]},{"id":"df4147cd7693e4d3","type":"api-call-service","z":"04b5da70ea694834","name":"Return to base","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"vacuum","service":"return_to_base","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1820,"y":360,"wires":[[]]},{"id":"7713901732acd9aa","type":"api-call-service","z":"04b5da70ea694834","name":"Return to base","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"vacuum","service":"return_to_base","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1880,"y":600,"wires":[[]]},{"id":"31f81969e12bccbb","type":"ha-wait-until","z":"04b5da70ea694834","name":"Not returned after 3 hrs?","server":"8a644e13.f9644","version":2,"outputs":2,"entityId":"vacuum.roborock_s6_maxv","entityIdFilterType":"exact","property":"state","comparator":"is","value":"returning","valueType":"str","timeout":"3","timeoutType":"num","timeoutUnits":"hours","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":1630,"y":600,"wires":[[],["7713901732acd9aa"]]},{"id":"3e97b3ae0de58085","type":"api-call-service","z":"04b5da70ea694834","name":"Return to base","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"vacuum","service":"return_to_base","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1840,"y":700,"wires":[[]]},{"id":"4e85ffba5a31a649","type":"ha-wait-until","z":"04b5da70ea694834","name":"Not returned after 3 hrs?","server":"8a644e13.f9644","version":2,"outputs":2,"entityId":"vacuum.roborock_s6_maxv","entityIdFilterType":"exact","property":"state","comparator":"is","value":"returning","valueType":"str","timeout":"3","timeoutType":"num","timeoutUnits":"hours","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":1610,"y":700,"wires":[[],["3e97b3ae0de58085"]]},{"id":"74197e14982a878d","type":"api-call-service","z":"04b5da70ea694834","name":"Return to base","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"vacuum","service":"return_to_base","areaId":[],"deviceId":["3ab0d503fda3b4b41f5fc06dcfadc1ba"],"entityId":["vacuum.roborock_s6_maxv"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1660,"y":920,"wires":[["bbecf4f263c962a1"]]},{"id":"ed5e0a531bd9148c","type":"ha-wait-until","z":"04b5da70ea694834","name":"Not returned after 3 hrs?","server":"8a644e13.f9644","version":2,"outputs":2,"entityId":"vacuum.roborock_s6_maxv","entityIdFilterType":"exact","property":"state","comparator":"is","value":"returning","valueType":"str","timeout":"3","timeoutType":"num","timeoutUnits":"hours","checkCurrentState":true,"blockInputOverrides":true,"outputProperties":[],"entityLocation":"data","entityLocationType":"none","x":1430,"y":920,"wires":[[],["74197e14982a878d"]]},{"id":"bbecf4f263c962a1","type":"change","z":"04b5da70ea694834","name":"Set msg","rules":[{"t":"set","p":"message","pt":"msg","to":"Vacuum is sick of your bullshit. Empty it when you get the chance.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1640,"y":1040,"wires":[["1b0a032939757419","65896a1ab0e09928"]]},{"id":"1b0a032939757419","type":"api-call-service","z":"04b5da70ea694834","name":"notify.","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_oneplus_6t_bbe","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{message}}\",\"data\":{\"actions\":[{\"action\":\"{{action1}}\",\"title\":\"{{actionTitle1}}\",\"icon\":\"sfsymbols:bell\"},{\"action\":\"{{action2}}\",\"title\":\"{{actionTitle2}}\"}],\"ttl\":0,\"priority\":\"high\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1810,"y":1000,"wires":[[]]},{"id":"65896a1ab0e09928","type":"api-call-service","z":"04b5da70ea694834","name":"notify","server":"8a644e13.f9644","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_loz21fe","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{message}}\",\"data\":{\"actions\":[{\"action\":\"{{action1}}\",\"title\":\"{{actionTitle1}}\",\"icon\":\"sfsymbols:bell\"},{\"action\":\"{{action2}}\",\"title\":\"{{actionTitle2}}\"}],\"ttl\":0,\"priority\":\"high\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1810,"y":1080,"wires":[[]]},{"id":"692f211c01a3b3ac","type":"function","z":"04b5da70ea694834","name":"Get batt lvl attr","func":"msg.payload = msg.data.attributes.battery_level;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1180,"y":420,"wires":[["033ad1d9c7271ecf"]]},{"id":"647c6dca4b14988a","type":"api-current-state","z":"04b5da70ea694834","name":"current_state","server":"8a644e13.f9644","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"vacuum.roborock_s6_maxv","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1000,"y":420,"wires":[["692f211c01a3b3ac"]]},{"id":"033ad1d9c7271ecf","type":"switch","z":"04b5da70ea694834","name":">=20","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"20","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1330,"y":420,"wires":[["db4ab86588fc2b9a"]]},{"id":"b2d5dd5fcc931589","type":"function","z":"04b5da70ea694834","name":"Get batt lvl attr","func":"msg.payload = msg.data.attributes.battery_level;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":540,"wires":[["8f0f3930106140e7"]]},{"id":"42e754e83e5cfb40","type":"api-current-state","z":"04b5da70ea694834","name":"current_state","server":"8a644e13.f9644","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"vacuum.roborock_s6_maxv","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":900,"y":540,"wires":[["b2d5dd5fcc931589"]]},{"id":"8f0f3930106140e7","type":"switch","z":"04b5da70ea694834","name":">=20","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"20","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1230,"y":540,"wires":[["351276abca7c4ba2"]]},{"id":"4a84b2518d1f8dde","type":"function","z":"04b5da70ea694834","name":"Get batt lvl attr","func":"msg.payload = msg.data.attributes.battery_level;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":700,"wires":[["ebd88eccdc3904dc"]]},{"id":"42dc51c86da4a329","type":"api-current-state","z":"04b5da70ea694834","name":"current_state","server":"8a644e13.f9644","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"vacuum.roborock_s6_maxv","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":900,"y":700,"wires":[["4a84b2518d1f8dde"]]},{"id":"ebd88eccdc3904dc","type":"switch","z":"04b5da70ea694834","name":">=20","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"20","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1230,"y":700,"wires":[["cfd35ffce5862f2c"]]},{"id":"edfbf7524756338a","type":"function","z":"04b5da70ea694834","name":"Get batt lvl attr","func":"msg.payload = msg.data.attributes.battery_level;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":960,"y":920,"wires":[["dc65189d466d46e1"]]},{"id":"0d45455f42b2a985","type":"api-current-state","z":"04b5da70ea694834","name":"current_state","server":"8a644e13.f9644","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"vacuum.roborock_s6_maxv","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":780,"y":920,"wires":[["edfbf7524756338a"]]},{"id":"dc65189d466d46e1","type":"switch","z":"04b5da70ea694834","name":">=20","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"20","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1110,"y":920,"wires":[["394f9fbe43ed3603"]]},{"id":"64aa2eae48eef1d0","type":"inject","z":"04b5da70ea694834","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":120,"wires":[["916c267050e49453"]]},{"id":"26839cd6e58b013b","type":"inject","z":"04b5da70ea694834","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":500,"wires":[["3ec8e251ad25cb40"]]},{"id":"3e1508894b84b3f3","type":"debug","z":"04b5da70ea694834","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":840,"y":240,"wires":[]},{"id":"e7ee9f587c2c2f1f","type":"nooperation","z":"04b5da70ea694834","name":"DO NOTHING","x":1200,"y":80,"wires":[[]]},{"id":"062088199e55c657","type":"time-range-switch","z":"04b5da70ea694834","name":"","lat":"","lon":"","startTime":"07:00","endTime":"20:00","startOffset":0,"endOffset":0,"x":820,"y":420,"wires":[["647c6dca4b14988a"],["febfbe98250e14a5"]]},{"id":"644632fe2380b5ee","type":"time-range-switch","z":"04b5da70ea694834","name":"","lat":"","lon":"","startTime":"07:00","endTime":"20:00","startOffset":0,"endOffset":0,"x":720,"y":540,"wires":[["42e754e83e5cfb40"],["febfbe98250e14a5"]]},{"id":"8a644e13.f9644","type":"server","name":"Home Assistant","addon":true}]
2 Likes

Hey guys,

Iā€™m now encountering a problem with my automation. The vacuum is correctly heading to the trash can when area cleaned has increased by X meters. I empty the dustbin, and press the home button on the vacuum itself. It then immediately re-triggers the automation, and parks itself back at the trashcan. Essentially sending it to dock is ending a cleanā€¦

Is there a simple way around this that Iā€™m not seeing?

Got it! Iā€™ve used a trigger node to check if total clean count has increased by 1 when the vacuum finishes cleaning. If it has, then the vacuum has literally finished a clean, and it parks at the trash can. When I press the home button, the total clean count has not increased by one, therefor the vacuum returns to dock correctly.