Mqtt: receiving update says "given new state is NULL"

I’m having some problems receiving an update from MqTT as a switch. Am i doing something wrong? I know if i change it from SWITCH to STRING it works but i want it to be a togable switch in the sitemap.

Item:
Switch vgu10 "Demo GU10 BUlb [%s]" {mqtt="<[openhab:smartthings/Gu10/switch:state:default]"}

Openhab Log:
2017-01-22 00:07:50.594 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'vgu10'

mosquitto_pub message:
smartthings/Gu10/switch on


I can send commands fine with the following setup:

item:
Switch vgu10 "Demo GU10 BUlb [%s]" {mqtt=">[openhab:smartthings/Gu10/switch:command:ON:on], >[openhab:smartthings/Gu10/switch:command:OFF:off]"}

openhab log:
2017-01-22 00:04:08.487 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command ON to smartthings/Gu10/switch
2017-01-22 00:04:08.491 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored ‘vgu10’ with state ‘ON’ in mapdb database
2017-01-22 00:04:08.510 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for vgu10_switch
2017-01-22 00:04:08.512 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored ‘vgu10_switch’ with state ‘on’ in mapdb database
2017-01-22 00:04:10.954 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for vgu10
2017-01-22 00:04:10.957 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored ‘vgu10’ with state ‘OFF’ in mapdb database
2017-01-22 00:04:10.957 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command OFF to smartthings/Gu10/switch
2017-01-22 00:04:10.976 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for vgu10_switch
2017-01-22 00:04:10.978 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored ‘vgu10_switch’ with state ‘off’ in mapdb database

mosquitto_pub message:
smartthings/Gu10/switch on
smartthings/Gu10/switch off

1 Like

My understanding - A switch is an output from OH. Your MQTT is setup as an input to OH, so should be a contact. At least that is the way I set everything up.

Try using all caps: “ON” and “OFF”. That error usually means that the message cannot be parsed into a format the Item understands. I’ve always used all caps for such messages so don’t know if using all lowercase is a problem but that would be the first thing I’d try.

2 Likes

I’ve been pulling my hair out on this for many hours! THANK YOU! :slight_smile:
adding a transformation map made it all work… finally. I’ll put this here so it hopefully helps someone in the future (i’m bridging my Smartthings HUB with openhab via mqtt - this allowes me to have zigbee support as well as Locks atm in OH2).

Here’s what i did to make this switch work:
(This switch item will Send ON/OFF commands and get updated from MQTT on its current state)

Item:
Switch vgu10_status "Status [%s]" {mqtt=">[openhab:smartthings/Ecosmart/switch:command:*:MAP(ONOFF_to_lower.map)], <[openhab:smartthings/Ecosmart/switch:state:MAP(onoff_to_UPPER.map)]"}

onoff_to_UPPER.map

on=ON
off=OFF

ONOFF_to_lower.map:

ON=on
OFF=off
6 Likes