MQTT binding tell me the given command is null

I’m getting the above error, and I think it’s probably because it can’t map my text to a number. My item looks like this:

Number Alarm_State “Alarm State [MAP(alarmmode.map):%s]” { mqtt="<[localbroker:/AlarmMode:command:MAP(alarmmode.map)], >[localbroker:/AlarmModeSet:command:*:MAP(alarmmode.map)]"}

alarmmode.map looks like this:

Disarm mode=0
Away mode=1
Home mode=2

but this gives me this error when I add a message to the queue:

2016-01-16 17:44:57.904 [WARN ] [t.i.s.MapTransformationService] - Could not find a mapping for ‘Disarm mode’ in the file ‘alarmmode.map’.
2016-01-16 17:44:57.904 [WARN ] [.c.i.events.EventPublisherImpl] - given command is NULL, couldn’t post command to ‘Alarm_State’

When I make alarmmode.map look like this (which I think is probably the correct way):

0=Disarm mode
1=Away mode
2=Home mode

I still get the same error:

2016-01-16 17:47:16.197 [WARN ] [t.i.s.MapTransformationService] - Could not find a mapping for ‘Disarm mode’ in the file ‘alarmmode.map’.
2016-01-16 17:47:16.198 [WARN ] [.c.i.events.EventPublisherImpl] - given command is NULL, couldn’t post command to ‘Alarm_State’

Changing the state will only add a message to the queue if I use the second type of map (number->text).

Also whats the difference between state and command? I know I can use either as part of the binding, and I’ve guessed command is what I need, but I don’t know what the difference is.

Ta

Ross

You are using the same map file in the label and in the binding. So when you String comes in it maps the state to the Number but then in the label you are trying to map the number back to the Sting. If you want this behavior your map file needs to map the values in both directions. E.g.

Disarm\ mode=0
0=Disarm\ mode

Note that I escaped the spaces. That is required as well.

My understanding is that using “state” is the equivalent to calling postUpdate and command is the equivalent to calling sendCommand.

2 Likes

Thank you so much - that was it! :slightly_smiling:

I think you answer almost all of my questions - I really appreciate all the help you give, you make a real difference to people getting started on this project. Seriously Thanks.

3 Likes