MQTT receive state but don't send command to sonoff switch

Hi there,

if set up MQTT binding in my OH2 to work with Sonoff switch (flashed firmware).
Seems to work so far, means I can switch on the Sonoff with Mosquitto client via:

mosquitto_pub -h localhost -t outside/LED/cmnd/POWER -m 1

or MQTT.fx windows application.

Unfortunately that it not working with my item:

Switch sonoff_light "LED Schalter" <light>
{ mqtt=">[mosquitto:outside/LED/cmnd/POWER:command:ON:1],
        >[mosquitto:outside/LED/cmnd/POWER:command:OFF:0],
        <[mosquitto:outside/LED/stat/POWER:state:default]" }
// Wifi Signal Strength
Number wifi "LED wifi: [%d %%]" (gRSSI)
{ mqtt="<[mosquitto:outside/LED/tele/STATE:state:JSONPATH($.Wifi.RSSI)]" }
//Status
String mqtt "LED Status: [%s]"
{ mqtt="<[mosquitto:outside/LED/tele/LWT:state:default]" }

The mqtt.cfg look like:

mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhab
mosquitto.user=admin
mosquitto.pwd=xxxxx
mosquitto.retain=false
mosquitto.async=true

The strange thing is that I receive all the states but sadly no reaction on the switch command.

Any idea?

regards, Nico

That is how it looks in the sitemap:

Please specify “no reaction on the switch command”: both ways or just one direction?
What’s in the logs?

1 Like

Which Firmware ?

Can this two lines not just be replaced by this one?

mqtt=">[mosquitto:outside/LED/cmnd/POWER:command:*:default]

Have you read this?


If you do it like described it works.

If I switch the Item on the sitemaps I can see just no reaction. Neither at the sonoff or in any logs. The mqtt binding is already in debug logging mode.

Hi,
Firmeware is:
SonOTA
|Program Version|5.9.1|
|Build Date & Time|2017-11-13T21:43:41|
|Core/SDK Version|2_3_0/1.5.3(aec24ac9)|

Yes, I have tried this as well before but same (no) result

mqtt=">[mosquitto:outside/LED/cmnd/POWER:command:*:default]

regards, Nico

There should be an entry for the switch to change! Is it not in the events.log?
And please look also for an entry like “connection with broker mosquitto…” after an oh2 start or change in mqtt.cfg - It should either indicate an established connection or a failed one.