Change a val into a number

#1

Hello i try to change the Season names into a Number but didn't work.
So maybe some have an Idea. Thank you for any kind of help.

image

0 Likes

#2

More context will be needed to understand what you're asking here.

0 Likes

#3

Your image suggests that msg.payload.val = 'WINTER' what do you want to change this into?

You could do change text to a number in a change node

for example

Change msg.payload.val
search for WINTER
replace with 1

0 Likes

#4

I'm sorry today is not my Day. I'm getting via Openhab the season Name ( "WINTER" )
But I wanna change "WINTER" into 1, SPRING in 2, Summer in 3, Autumn in 4.
Just into a number. I tried it with a function and a change.

image

0 Likes

#5

Try a change node with a configuration like this:

It looks like your message may be a JSON string rather than an object, so you may need to pop a JSON node in before the change node to break out the val property.

0 Likes

#6

Thank you very much it works. Have a great day. :grinning:

0 Likes