I get message (given new state is NULL)

Hi again guys, i have problems reading the state of my switch, i can see that works in MQTT.fx, it sends OPEN and CLOSE, but i cant get it to work in Openhab. I get this message ([WARN ] [.c.i.events.EventPublisherImpl] - given new sta te is NULL, couldn’t post update for “Switch5”.

Here is the map file

OPEN=open
CLOSED=closed
undefined=unknown
-=unknown

here are the items

/* MQTT Sensors */

Number Floor1_Temp "Floor1 Temperature 1 [%.1f �C]" <temperature> (Floor1,Temperature) {mqtt="<[mymosquitto:openhab/floor1/temperature1:state:default]"}
Number Floor1_Humidity "Floor1 Humidity 1 [%.1f %%]" <water> (Floor1,Humidity) {mqtt="<[mymosquitto:openhab/floor1/humidity1:state:default]"}
Number Floor1_Temp2 "Floor1 Temperature 2 [%.1f �C]" <temperature> (Floor1,Temperature) {mqtt="<[mymosquitto:openhab/floor1/temperature2:state:default]"}
Number Floor1_Humidity2 "Floor1 Humidity 2 [%.1f %%]" <water> (Floor1,Humidity) {mqtt="<[mymosquitto:openhab/floor1/humidity2:state:default]"}
Switch Relay1 "AC Restart relay"           <garagedoor>    (All) {mqtt=">[mymosquitto:openhab/floor1/relay1:command:ON:ON],>[mymosquitto:openhab/floor1/relay1:command:OFF:OFF]"}
Number Switch5 "AC Status [MAP(en.map):%s]"  <garagedoor> (Sensors) {mqtt="<[mymosquitto:openhab/floor1/switch5:state:default]"}

and the sitemap

sitemap default label="Main Menu"
{
        Frame label="Floor1_Temp" {
                Text item=Floor1_Temp
        }
		Frame label="Floor1_Humidity" {
                Text item=Floor1_Humidity
        }
		Frame label="Floor1_Temp2" {
                Text item=Floor1_Temp2
        }
		Frame label="Floor1_Humidity2" {
                Text item=Floor1_Humidity2
        }
		Switch item=Relay1 mappings=[OFF="OFF", ON="ON"] 
		Text item=Switch5
		Chart item=Floor1_Temp period=D
		Chart item=Floor1_Temp2 period=D
		}
        
		

Thanks

If you are publishing OPEN and CLOSED, then you want to use a Contact item (or maybe a String item, if there are other states). It looks like you might be using a Number item, which will result in the message you saw, since it’s not a number coming from your MQTT publisher. And if you are actually publishing open and closed (lowercase), then you want your map file to at least contain:

open=OPEN
closed=CLOSED

(yours seems to have some keys and values reversed?)

Thanks it works now! The Contact item fixed it . Im starting to realize the coding sense in Openhab and hope to improve my skills :slight_smile: .

Have a nice day

1 Like