Is there an easier way to do this by first filtering only those input_select objects which have either attribute and then counting them rather then counting each individually and then adding them up?
Iâm likely overcomplicating things because the above statement âworksâ but i feel it can be optimised
Your version will match on any sub-string within 'Home,Just Left,Just Arrived'. In other words, it will match on âArrivedâ, âJustâ, âLeftâ or any other fragment.
Good to know @123 (given the list of options wouldnât have been a problem but if youâd only wanted âJust Arrivedâ and exclude âJust Leftâ I can see where it would have fallen down) - thatâs my afternoon taken care of now tightening up my config!
FWIW, I have always used a list with in (it can also be a tuple) and never a string like in your example. So I tried it on my test system like this:
{{ states.input_select | selectattr('state', 'in', 'off, None') | list }}
It worked; it reported all input_selects whose value is either âoffâ or âNoneâ. However, it also reported an input_select whose value is âNoâ because itâs a sub-string of âNoneâ. So, yes, it works but a little too well.