Sensor - Validation error - State is not a string

Hello guys,

This might be a nodered only issue, but as it is generated on a sensor node, I thought it would be better to put it here.

I’m trying to update an HA sensor through messages I receive from a websocket.
I already use it to update binary_sensors for some lights. Here I would like to do the same for some blinds (store in French).
image

The “debug 27” data is:
image

But the sensor node genarate this error:
ValidationError: "state" must be one of [string, boolean, number]

The sensor configuration is:

I tried many things, but as far as I see, the “moving” attribute is a string.
I don’t understand why I get this error.

Any hint would be much appreciated!

Thank you very much in advance.

Tim

Looks to be a bug please report it so it can be tracked.

The current workaround is to use a change node before the sensor node and move payload to p and use p.state.moving in the state field.

This error is because the sensor node accepts msg.payload.state as an override to the config and that property is an object.

1 Like

Dear @Kermit,

Thank you for your help.

I did what you suggest and it did the trick.
Still, I also tried to specify another attribute as boolean but it kept using ‘state’ anyway.
It made me feel as if the sensor was only partially working/developed.

Anyway, it works, and I have now all my blinds status un HA :blush:

Tim