#Blueprints: Combine inputs(multiple: true) to single List?

1 messages · Page 1 of 1 (latest)

north phoenix
#

I have two inputs that have their own distinct entities, for example:

  input:
    group_1:
      name: "Group 1"
      selector:
        entity:
          multiple: true
          filter:
            - domain: light
    group_2:
      name: "Group 2"
      selector:
        entity:
          multiple: true
          filter:
            - domain: light

At one point in the automation, I want to use them all together, basically equivalent to this Python example:

group_1 = [ '1','2' ]
group_2 = [ '3','4' ]
combined = group_1 + group_2 # [ '1', '2', '3', '4' ]

I tried these three ideas and (unsurprisingly) they didn't work:

wait_for_trigger:
  - trigger: state
    entity_id:
      - !input group_1
      - !input group_2

wait_for_trigger:
  - trigger: state
    entity_id: !input group_1 + group_2

wait_for_trigger:
  - trigger: state
    entity_id: !input group_1 + !input group_2

Thanks in advance for any thoughts/insight! 🫶

amber wing
#

are you trying to wait for all of group 1 and 2, or any?
If any you could just have 2 separate triggers in the wait for block
If all... I think you could combine them as a variable and then use the combined list in a single trigger

north phoenix
#

awesome, the two separate triggers will work here

#

the template definitely does not work. it's so angry about that

amber wing
north phoenix
#

do those work for entity_id in state checks?

amber wing
#

No. They don't work directly in a state trigger, you would need to use a template trigger

fathom wyvern
amber wing
fathom wyvern
#

Ah, great point. Not 100% sure..

amber wing
#

I think it needs to be something like this to watch for any changes - though this just compares the total on rather than which exact ones are on, which you could also do:

variables:
  group_1: !input group_1
  group_2: !input group_2
  prev_total: "{{ (group_1 + group_2) | select('is_state', 'on') | list | count }}"

wait_for_trigger:
  - trigger: template
    value_template: "{{ (group_1 + group_2) | select('is_state', 'on') | list | count != prev_total }}"
fathom wyvern
#

Might indeed be limited to inputs rather then variables.

#

So yeah, then I would just do

wait_for_trigger:
  - trigger: state
    entity_id: !input group_1
  - trigger: state
    entity_id: !input group_2
amber wing
#

ye

#

much easier ^^

north phoenix
#

This wasn’t said outright, but the devices I wanted to watch are buttons so I can’t just on/off them, I’d need to compare to their existing values

amber wing
#

you could do that just by monitoring the newest then: {{ ((group_1 + group_2) | map('states') | sort(reverse="true") )[0] }} - when that changes one of the buttons has updated

#

you'd need to filter out unavailable buttons

#

but again, just use two triggers in the wait_for_trigger block

north phoenix
amber wing
#

No
As I showed in the on/off example - you would have to save the current value into a variable, and then the template trigger recalculates the value and compares to that stored value, triggering when it changes

But again, for the 3rd? 4th? time just use two state triggers - template triggers are in general harder to maintain and easier to fuck up, so don't use them unless you have to and you don't, so don't.

north phoenix
north phoenix
north phoenix
north phoenix
#

It’s not clear to me where I gave the impression I wasn’t going to go the two triggers route

amber wing