Have multiple states from one sensor trigger an automation

Hi!
I’ve been trying to work out how have multiple states from one sensor trigger an automation.
Can someone tell me the best way of doing it?
I tried using the documentation example of:

      to:
        - "A"
        - "B"

which created

to: 'A,B,C,D,etc'

I wasn’t sure this was correct, as it looked like a string that contained those phrases and commas.
I also tried some other way: I’m not sure what it was, but it didn’t work

Can someone confirm to me the best way of doing this?

Thanks

I tested and confirmed that this format will trigger when the state value changes to either A or B:

  to:
    - "A"
    - "B"

What also works is a comma-delimited string which is why the Visual Editor converts it into that (more compact) format.

1 Like

In the web gui, if I type in

A, B, C, D

would that be valid?

Yes, because that’s the Visual Editor’s default format (actually, it doesn’t include spaces between each item).

1 Like

One question,
If I have symbols and spaces in the keywords, will that cause issues?
eg

A, +ABC, C/GE, BIG TEST, G

Helped by mono on Discord, needed to get this finished for testing.
‘A, +ABC, AD/FD’ should be valid.

Thanks!

I have never been able to get this to work in the visual editor… I have tried a lot of different methods, but never get it to reflect correctly in the YAML…

I just copied the example from above assuming I was doing something… But it’s still interpreted as a string of characters…

Visual editor:

Results in the YAML:

What am I doing wrong?

Did you try adding the single quotes?
This has always been finnicky and I ended up using a webhook triggered elsewhere.

Should all be valid methods.

I have tried every combination I could think of but they all resolve as a string in the YAML editor:

a, b, c, d
a,b,c,d
“a”,“b”,“c”,“d”
‘a’, ‘b’, ‘c’, ‘d’
‘a, b, c, d’
“A, b, c, d”

When I try to do it in the YAML editor and change it to the visual editor, it resolves correctly ( [“a”,“b”,“c”,“d” ] ) but throws an error… I would assume if the visual editor does it, the YAML editor would be able to convert it back, right?

I think your best bet is using the YAML editor as there you can create the list with proper YAML syntax for lists.
The visual editor seems to be better suited for less complex “to” configurations (eg, just one word/etc).

I figured that was the case. Been working around it for a while, just makes the automation more complex (multiple triggers instead of 1 YAML).

Would this be bug worthy or just something to workaround? The documentation says its possible, that’s the reason I ask.