Contact Item

Hi All,

Firstly : openHAB version: openHAB 2.3.0-1 (Release Build)

I am having trouble in getting PIR sensor to work with HABPanel. In BasicUI it does not show the status, In HABPanel, I have Dummy Widget - this only displays “States_unknown” (see below) and in the log I have the following warning
[WARN ] [] - given new state is NULL, couldn’t post update for ‘Dev_PIR’.
monitoring the MQTTBroker, I see the status of the PIR Changing as:
/ESPDEV/PIR/Switch , with a payload of 0 or 1

PS other Sensors (temperature) connected to the same ESP work just fine.

Items line is set as:
Contact Dev_PIR “PIR Sensor [MAP(]” (Dev)
{mqtt="<[MQTTBroker:/ESPDEV/PIR/Switch:state:default]"} contains:

Any Help is appreciated…

Your item should be:

Contact Dev_PIR “PIR Sensor [%s]” (Dev) { mqtt="<[MQTTBroker:/ESPDEV/PIR/Switch:state:MAP(]" }

You need to do the transformation in the binding itself to generate an state of CLOSED or OPEN
Your transformation was only in the label of the item trying to transform the state. But the state could never have been 0 or 1 as this is a Contact item.
Does that make sense?

On another note, try to avoid leading / for MQTT topics. It is not recommended by the best practice as it adds a layer to the topics starting with an empty one and can lead to errors.

Thanks for the Prompt response, Yes that has fix it.
As for the leading “/”, had came across an article stating the same - The ESP8266 with ESPEASY loaded - works that way out by default. I think with ESPEasy I just need to change the variables. (next one the list)

Yes is does, and I don’t know why the ESPEasy guys haven’t changed it. You can change it in the variable as you said.

Thanks, please mark the thread as solved.