Currently i got i template sensor that looks like this: {{ “ABC DEF” in state_attr(‘binary_sensor.mysensor’, ‘data’) }}
and it goes true/false usually without a fuss.
sometimes there’s an attribute called “ABC DEF GHI” that pops up on the sensor and i don’t want it to activate the sensor, since it’s not “ABC DEF”. but due to being the name being contained inside, it still activates it.
are there any ideas for the template to check only when “ABC DEF” is in the state_attr regardless if “ABC DEF GHI” is there or not?
Hi and thank you for your quick reply!
AFAIK on state_attr(‘binary_sensor.mysensor’, ‘data’)
there’s a list output with many data
should it still work?
It seems like the solution! i just got one more question
let’s say “ABC DEF” is on the ‘data’ list but there’s another data that contains “GHI” on the list (not “ABD DEF GHI”) which is irrelevant to me, meaning that i want the template sensor to still be turned on. can i use this:
{{ 'ABC DEF' in state_attr('binary_sensor.mysensor', 'data') and 'ABC DEF GHI' not in state_attr('binary_sensor.mysensor', 'data') }}
all i did is change the “GHI” to “ABC DEF GHI”
edit: my meaning of the template sensor that it will be turned on when “ABC DEF” is on the list, regardless of “ABC DEF GHI” being on the list as well while not being turned on when only “ABC DEF GHI” is only on the list. I should have explained it from the beginning, sorry about that.
How are we supposed to know this is a list?!!!
For F sake, stop with the ABC shit and give us the real sensor data. All you do is confuse things and make us waste time.
The real binary sensor is connected to an API of my country’s alarm/siren system.
My template sensor should turn on when my city is on the list
“ABC DEF” converts to my city while “ABC DEF GHI” converts to an industrial zone in my city. i don’t want to disclose names that’s why i chose this weird “ABC” method.
Yes you’re right, i should have stated it from the get go, but I’m new to HA coding so i didn’t know it shouldn’t be obvious… nothing made on purpose…
please remember to be kind
wish you well