Current state node, how to use in to match a string?

Hi all,

I’ve been trying to use a current state node for a simple, or at least seemingly simple automation, where I want to send an alert if a string returned for a sensor contains some specific text in it, but since the sensor changes from day to day, I just want it to match a specific word in the string.

I thought using the if state in string would do the trick, but I can’t seem to make it match, no matter what I try.

Specifically, this is for a sensor that shows the Norwegian Postal services delivery days, and I want it to trigger a notification (code:

The string the sensor returns is this:

msg.payload : string[129]
"['i morgen tirsdag 7. september', 'torsdag 9. september', 'mandag 13. september', 'onsdag 15. september', 'fredag 17. september']"

My Current State node looks like this:

Shouldn’t the if state in string = I morgen evaluation there trigger on the sensor.postendeliverydays string value, or am I missing something very obvious here? I’ve tried all sorts of other matches, but it always returns false, unless I change it to not in, then it returns true. Obviously I’m doing something wrong here, but I can’t find out what. Any pointers?

The condition in for if state is expecting a comma-delimited list to check if it contains the state.

What you want to use in this cause is to set the condition to is then change the field type to Regex, .*.



Oh man, I tried to do that earlier today but probably messed up my Regex, since I am pretty much Regex illiterate. I even tried using, and got it to match, but when I copied it over from there into the node, it didn’t work which led me down the in rabbit hole, and I never got out of it again. All that was wrong was that I copied the entire Regex from there, e.g:

/i morgen/

when I should have ditched the forward slashes like you have in your example. Works as intended now!

Thanks a lot, I only spent way too much time on this :wink: