Cant send command via MQTT to my item

Although it seemed to be quite clear and simple I stuck. My config:

item definition

Number		soffth1603_relay2	"JustRelayState [%d]"		<selfsocket>		{ mqtt="<[mosquitto:soffth1603/RelayState/State:state:default]"}
Switch		soffth1603_switch	"RelayTurnOffOn"			<selfsocket>		{ mqtt=">[mosquitto:soffth1603/RelayState/State:command:ON:1],>[mosquitto:soffth1603/RelayState/State:command:OFF:0]"}

first definition in only for testing purpose, second is crucial

part of sitemap:

	Frame label="Test" {
		Default	item=soffth1603_relay2		label="State [MAP(]"
	Frame label="MQTT control" {
		Switch	item=soffth1603_switch		label="MQTT switch"

And now - I can using phisical button on sonoff turn it on / off which cause changing value of soffth1603_relay2 in Basic UI so that part of config is correct and receiving mqtt connection is ok. Using soffth1603_switch from Basic UI I can also change soffth1603_relay2 value on Basic UI BUT it can not turning on / off my sonoff . It looks like mqtt binding dont send command to device … . Or maybe mosquitto config needs to be corrected … ?

What am I doing wrong ?

What firmware are you using with the Sonoff? Are you certain you have the right topics? Given the topic names I would guess that you need to use sonoff1603/RelayState/Command or something like that to actually command the relay.

The fact that your relay2 Item is working shows that your MQTT config is correct.

1 Like

I found it.

It is because of ESP Easy 2.0 dev12 . In my case working item’s def is:

Switch		soffth1603_switch	"Switch"			<selfsocket>		{ mqtt=">[mosquitto:soffth1603/gpio/12:command:ON:1],>[mosquitto:soffth1603/gpio/12:command:OFF:0]"}

I added to above


but it does not update the state of the switch. Still searching …


In my case (ESP Easy 2.0 dev12) right entry is:

Switch		myname_switch	"myname_label"			<icon_name>		{ mqtt=">[mosquitto:%sysname%/gpio/12:command:ON:1],>[mosquitto:%sysname%/gpio/12:command:OFF:0],<[mosquitto:%sysname%/%tskname%/%valname%:state:MAP(]"}



Of course GPIO number may differ.

1 Like