PiotrMachowski / Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor

This custom integration provides a way to present a live view of a map for Xiaomi (Roborock/Viomi/Roidmi/Dreame) vacuums without a need for rooting.
MIT License
1.13k stars 122 forks source link

Filter event trigger in update_map_extractor.yaml blueprint #462

Open mguyard opened 12 months ago

mguyard commented 12 months ago

Description

Hello,

Since today, i've tested your new update_map_extractor.yaml blueprint (previously using disable_vacuum_camera_update_when_docked.yaml).

As i can see, each time an event with an event_type state_changed is trigger, automation start. So on a normal HA installation, automation start many time in the same seconds/minutes.

Solution

To optimize this, is it possible to filter trigger event by specifying event_data for example ? As i don't really understand what you look in event, i don't know what filter to apply.

Alternatives

No response

Context

No response

PiotrMachowski commented 12 months ago

The automation is triggered, but all unnecessary triggers should be filtered by conditions specified here

Hopefully the blueprint won't be necessary soon.

marcob79 commented 11 months ago

what about is we modify image to

trigger:
  - platform: event
    event_type: state_changed
    id: state_changed
    entity_id: !input vacuum

?

because currently it get as trigger every state changes (that ok, will be filtered by condition, but anyway ....)

marcob79 commented 11 months ago

have a look at this PR

PiotrMachowski commented 11 months ago

This event trigger can't be changed in this way - it is used in browser mode:

  is_browser_mod_template_trigger: |-
    {{
      mode_to_handle in ['browser_mod_path']
      and trigger.id == 'state_changed'
      and (
          trigger.event.data.new_state != None 
          and trigger.event.data.new_state.attributes != None 
          and "pathSegments" in trigger.event.data.new_state.attributes
          and browser_mod_path == trigger.event.data.new_state.state
        or
          trigger.event.data.old_state != None 
          and trigger.event.data.old_state.attributes != None 
          and "pathSegments" in trigger.event.data.old_state.attributes
          and browser_mod_path in trigger.event.data.old_state.state
        )
    }}