#Zigbee2mqtt 'event' based automation, replacing 'action' based Blueprint - is there a smarter way?

1 messages · Page 1 of 1 (latest)

grand apex
#

I've been using a blueprint for my Opple switch that looks like screenshot 3. Im not very versed in modifying blueprints, so after implementing legacy off switches in Z2M i tried to create a new automation and screenshots 1 and 2 present what if figured out to handle all single and double actions for all 6 switches.
My question is: is there a more efficient way to do that?

#

@fast crypt youve said on the Z2M dsc that you could help

fast crypt
#

Aye, let me grab a live example

#
id: 'office_dial_action'
initial_state: 'on'
alias: 'Office dial action'
trigger:
  - platform: state
    entity_id: event.office_dial_moes_action
    to: ~
    id: event
action:
  - choose:
      - condition: template
        value_template: >-
          {{ trigger.to_state.attributes.event_type == 'toggle' }}
      - condition: state
        entity_id: media_player.office
        state: 'playing'
      sequence:
      - service: media_player.media_pause
        data:
          entity_id: media_player.office
      - condition: template
        value_template: >-
          {{ trigger.to_state.attributes.event_type == 'toggle' }}
      sequence:
      - service: media_player.media_play
        data:
          entity_id: media_player.office
#

Basically, trigger on every state change of the event entity - since the state is the time it last did something

#

Then use a template to check the event_type attribute

#

It'll be easier to answer your specific question if you share the YAML of your automation

grand apex
dusky girderBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

fast crypt
#

A code share site would help a lot there

#
... (82 lines left)
``` makes that less than handy 😄
#

(just about to dive into a meeting, I'll be back later)

grand apex
#

ive tried setting event as a trigger for the automation but dont seem to be able to

fast crypt
#

You do have event. entities from Z2M? You have to enable that option

grand apex
#

ohh i see

fast crypt
#

After that, you could probably use #1284966664357810196 to "simplify" the automation. Whether that'll really simplify it, or just reduce the lines of YAML...

#

Using variables to select the target for the light/cover action will reduce the "duplicate" blocks of YAML, but make it harder to follow the logic

grand apex
#

yea the event. entity was the missing piece here, now everything's clear