Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor icon indicating copy to clipboard operation
Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor copied to clipboard

Filter event trigger in update_map_extractor.yaml blueprint

Open mguyard opened this issue 1 year ago • 4 comments

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

mguyard avatar Aug 24 '23 09:08 mguyard

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

Hopefully the blueprint won't be necessary soon.

PiotrMachowski avatar Aug 24 '23 10:08 PiotrMachowski

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 avatar Sep 23 '23 08:09 marcob79

have a look at this PR

marcob79 avatar Sep 23 '23 08:09 marcob79

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
        )
    }}

PiotrMachowski avatar Sep 23 '23 11:09 PiotrMachowski