Core: Vacuum vacuum.return_to_base not working with switch template

Created on 28 Feb 2020  路  16Comments  路  Source: home-assistant/core

The problem

I have a Xiaomi Vacuum S50. It has been working fine for more than a year with my switch template. I created this template because I wanted to expose it on HomeKit as well.

It used to work fine in the sense that turning the switch on would start the vacuum and turning it off will stop the vacuum and send it to the base. However now when I turn the switch off, the vacuum just pauses/stops instead of going back to the base as well. I have the latest firmware on the vacuum.

I鈥檝e checked on the integrations page and this is the correct command for turning it off and send it to the base, however the expected result is not the same as it used to be.

Environment

Home Assistant 0.106.1 through Hassio
arch | x86_64
dev | false
docker | true
hassio | true
os_name | Linux
python_version | 3.7.6
timezone | Europe/Madrid
version | 0.106.1
virtualenv | false

  • Home Assistant release with the issue: 0.106.1
  • Last working Home Assistant release (if known): can't remember
  • Operating environment (Hass.io/Docker/Windows/etc.): Hassio
  • Integration causing this issue: Vacuum
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/vacuum

Problem-relevant configuration.yaml

- platform: template
    switches:
      limpiador_vacuum:
        friendly_name: Limpiador
        value_template: "{{ is_state('vacuum.limpiador', 'cleaning') }}"
        turn_on:
          service: vacuum.start
          entity_id: vacuum.limpiador
        turn_off:
          service: vacuum.return_to_base
          entity_id: vacuum.limpiador
xiaomi_miio

Most helpful comment

I fixed this temporarily by this script:

dock_xiaomi:
  alias: Dock Xiaomi
  sequence:
  - data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.stop
  - delay:
      seconds: 1
  - data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.return_to_base

All 16 comments

What happens when you use just a service call vacuum.return_to_base instead of the switch template? Do you get any errors in the logs when you call that?

Hey there @rytilahti, @syssi, mind taking a look at this issue as its been labeled with a integration (xiaomi_miio) you are listed as a codeowner for? Thanks!

What happens when you use just a service call vacuum.return_to_base instead of the switch template? Do you get any errors in the logs when you call that?

Thanks for your reply!. I've tried what you suggested and I called the service directly:
If the vacuum is running and I call the service the robot will "pause", same behaviour as from the switch. While the robot is paused, If then I call the service again it will go to the base.

I've tried enabling debug logs but I'm not getting anything there

Confirming the issue, this started happening after upgrading to FW 3.5.7_002008.

Calling return_to_base will execute the following method in the backend library: https://github.com/rytilahti/python-miio/blob/master/miio/vacuum.py#L92 . The previous behavior was (iirc) that returning did not work if there was no pause.

As for how to fix it, I'm not sure. Considering that calling the service second will make it return, maybe the new firmware requires a short pause between the commands?

I fixed this temporarily by this script:

dock_xiaomi:
  alias: Dock Xiaomi
  sequence:
  - data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.stop
  - delay:
      seconds: 1
  - data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
    service: vacuum.return_to_base

Also have this issue. Takes two hits of the return to base service call to actually return the vacuum to base.

me to, does somebody know how to implement this second action and the delay in to a template switch?

  • platform: template
    switches:
    homekit_vacuum_downstairs:
    friendly_name: "Roomba Downstairs"
    value_template: '{{ is_state("vacuum.roomba_downstairs", "cleaning") }}'
    turn_on:
    - service: vacuum.start
    data:
    entity_id: vacuum.roomba_downstairs
    turn_off:
    - service: vacuum.return_to_base
    data:
    entity_id: vacuum.roomba_downstairs

@JurajNyiri thanks for that, but I'm not entirely sure how to implement that?. Is your HA config up somewhere so I can take a look? thank you!

@jaddel This worked for me with a template switch:

    roomba_switch:
        friendly_name: "Roomba"
        value_template: '{{ is_state("vacuum.roomba", "on") }}'
        turn_on:
          service: vacuum.turn_on
          data:
            entity_id: vacuum.roomba
        turn_off:
        - service: vacuum.stop
          data:
            entity_id: vacuum.roomba
        - delay:
            seconds: 1
        - service: vacuum.return_to_base
          data:
            entity_id: vacuum.roomba

Ideally this sequence should be built into the integration for return to base.

tanks a lot!

The Roomba integration update fixed this for the Roomba (at least through the exposed HomeKit switch), but the Roborock vacuums remain affected. Any hope of adding the pause to the code @rytilahti?

Any News?

Had the same issue and solved it with inserting a delay.

The workaround didn鈥檛 work today, got this instead:

2020-10-25 16:44:18 ERROR (MainThread) [homeassistant.components.xiaomi_miio.vacuum] Unable to return home: {'code': -10003, 'message': 'action locked'}

Hey @rytilahti, @syssi, maybe some help with the main issue?

@melyux your most recent error sounds to be a completely separate problem, that json payload is coming directly from the device.

Regarding to the original issue, I'm not sure if anyone has tried to modify the code to use stop instead of pause to see if that helps? The code is here https://github.com/rytilahti/python-miio/blob/c4ab5e6f63df67e2b30cb0ec8160e85e1df8e63d/miio/vacuum.py#L136 - the change would be replacing the call to app_pause with app_stop. (another possibility could be adding a short delay of half a second or so there).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gio76 picture Gio76  路  223Comments

aguilaair picture aguilaair  路  162Comments

ariel-madril picture ariel-madril  路  451Comments

soldag picture soldag  路  143Comments

nodkan picture nodkan  路  161Comments