[SOLVED] postUpdate Switch with Off instead of OFF

All,

I bet I saw this somewhere, but i don’t find it anymore.

Currently I use a code like (fr is a string, CarDrFrRght a contact):

		if(fr == "Closed") {
			CarDrFrRght.postUpdate(CLOSED)
		}
		if(fr == "Open") {
			CarDrFrRght.postUpdate(OPEN)
		}

Shouldn’t it be possible to use:
CarDrFrRght.postUpdate(fr)

But I get:

Cannot convert 'Open' to a state type which item 'CarDrFrRght' accepts: [OpenClosedType, UnDefType].

Have tried to use something like:
ucase(fr)

Thanks - I just found the solution:
CarDrFrRght.postUpdate(fr.toUpperCase)

1 Like

I just recognized that average CPU load went from 20 up to 45-50 after the change.
Is that even thinkable or just a coincidence?

I would say it depends a bit on how often you run that code.

Good Morning :wink:

Same like the original code with 6 LOC - every 5 minutes

Although I’m having no knowledge about what this method does in the backgound I would relate that to such a change in the AVERAGE load.

You would or wouldn’t?

Sorry, wouldn’t. It’s a bit early!

:smiley:

That would have been my first guess as well.
Thanks.
I will revert back and see what happens.

EDIT:
i changed back to the previous setup, but the Cpu load is the same.
So there must be something else wrong.