Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to scan map only when vacuum not in dock #77

Closed
pplucky opened this issue Jan 30, 2021 · 3 comments
Closed

Add possibility to scan map only when vacuum not in dock #77

pplucky opened this issue Jan 30, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@pplucky
Copy link

pplucky commented Jan 30, 2021

Hello.

First of all, thanks a lot for this great component, it was definitely missing in my setup for a long time.

Still then, having to define a larger scan_interval just for the sake of not consuming too many machine resources is a bit overkill. It is actually too much to do it every 5 seconds (even from the perspective of checking Xiaomi Cloud, I suppose), when most probably no map changes occurred.

I don't see much advantage in having it updating every 5 seconds when most the time the vacuum is docked and there are no changes in the map. Even if you'd like it to update in specific situations, you can always run service home assistant_update_entity, right?

Would it be an option to add a possibility to scan map only when vacuum is not in dock? I think that would be a much more lighter approach in all senses.

Thanks for letting me know if I can somehow help in turning this into a reality.

@PiotrMachowski PiotrMachowski self-assigned this Jan 30, 2021
@PiotrMachowski PiotrMachowski added the enhancement New feature or request label Jan 30, 2021
@pplucky
Copy link
Author

pplucky commented Feb 2, 2021

FYI for anyone else that may be interested, as a workaround I added the following automation and script to allow keeping auto-update off in the custom integration configuration, updating automatically the map (every 5 seconds), but only while vacuum is not docked (via automation) and allow manual update if needed (via script).

automation:
### Update vacuum map only when vacuum not in dock ###
  - alias: 'Update vacuum map while not docked'
    trigger:
      - platform: state
        entity_id: vacuum.aspirador
        from: 'docked'
### Avoid automation being triggered if vacuum is temporarily unavailable ###
    condition:
      - condition: template
        value_template: "{{ trigger.to_state.state != 'unavailable' and trigger.to_state.state != 'unknown' }}"
    action:
      - alias: Keep updating map until vacuum returns to dock
        repeat:
### Until vacuum is back in dock, update map every 5 seconds ###
          sequence:
            - service: homeassistant.update_entity
              data:
                entity_id: camera.mapa_casa
            - delay:
                seconds: 5
          until:
            - condition: state
              entity_id: vacuum.aspirador
              state: 'docked'

script:
### Manual update vacuum map ###
  update_vacuum_map:
    alias: "Update Vacuum Map"
    icon: mdi:robot-vacuum
    sequence:
      - service: homeassistant.update_entity
        data:
          entity_id: camera.mapa_casa

@licheng5625
Copy link

another way is implement turn on/off

@PiotrMachowski
Copy link
Owner

v2.0.2 added possibility to use camera.turn_on and camera.turn_off services

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants