Page 1 of 1
MQTT toggle option for switchcmd
Posted: Sunday 05 March 2017 23:14
by wildfire
HI,
i have bin searching all night for a solution to toggle a switch like the http version of this:
Code: Select all
/json.htm?type=command¶m=switchlight&idx=1&switchcmd=Toggle
to mqtt like this
Code: Select all
{"command": "switchlight", "idx": 1, "switchcmd": "Toggle"}
but this is not working
Code: Select all
{"command": "switchlight", "idx": 1, "switchcmd": "On"}
works but i need to be able to toggle.
can anyone help out with this?
thanks
Re: MQTT toggle option for switchcmd
Posted: Monday 06 March 2017 20:39
by SweetPants
Works for me on V3.6862 and V3.6874 using: {"command": "switchlight", "idx": 85, "switchcmd": "Toggle"}
Please update to latest Beta first as the forum rules state
Edit: This was implemented in build d20eb34167bef6a1cc7dcd6da57e0742ec8fb98a
Re: MQTT toggle option for switchcmd
Posted: Tuesday 07 March 2017 20:35
by wildfire
ok,
i had my input channel mixed up.
this should be added to the MQTT wiki btw.
https://www.domoticz.com/wiki/MQTT
Thanks for the fast reply.
Re: MQTT toggle option for switchcmd
Posted: Wednesday 08 March 2017 23:49
by SweetPants
That is the beauty of an opensource project, you can add it to the Wiki yourself. You can login with your domoticz user credentials.
Re: MQTT toggle option for switchcmd
Posted: Thursday 02 September 2021 19:43
by jurgend
Hi, when the switchcmd: "toggle" is used for my light bulb it does not change te stat in Domoticz.
The light does perform the command but when I toggle a light that was on to off, the light goes off but the icon stays on and no log entry was placed in the device.
Is that normal behavior?
Can I set the correct status after the toggle was performed?
Re: MQTT toggle option for switchcmd
Posted: Thursday 02 September 2021 22:53
by waltervl
jurgend wrote: ↑Thursday 02 September 2021 19:43
Hi, when the switchcmd: "toggle" is used for my light bulb it does not change te stat in Domoticz.
The light does perform the command but when I toggle a light that was on to off, the light goes off but the icon stays on and no log entry was placed in the device.
Is that normal behavior?
Can I set the correct status after the toggle was performed?
If I try this with the http api call eg
Code: Select all
http://192.1xxx.xxx.xxx:8080/json.htm?type=command¶m=switchlight&idx=93&switchcmd=Toggle
then my lamp and my device widget switches on/off as expected.
You have to use "Toggle" not "toggle" the command is case sensitive.
Can you try this api call on your device and see if the device widget is toggling along?
If it still fails can you post the complete MQTT payload you are sending?
Re: MQTT toggle option for switchcmd
Posted: Friday 03 September 2021 7:51
by jurgend
waltervl wrote: ↑Thursday 02 September 2021 22:53
jurgend wrote: ↑Thursday 02 September 2021 19:43
Hi, when the switchcmd: "toggle" is used for my light bulb it does not change te stat in Domoticz.
The light does perform the command but when I toggle a light that was on to off, the light goes off but the icon stays on and no log entry was placed in the device.
Is that normal behavior?
Can I set the correct status after the toggle was performed?
If I try this with the http api call eg
Code: Select all
http://192.1xxx.xxx.xxx:8080/json.htm?type=command¶m=switchlight&idx=93&switchcmd=Toggle
then my lamp and my device widget switches on/off as expected.
You have to use "Toggle" not "toggle" the command is case sensitive.
Can you try this api call on your device and see if the device widget is toggling along?
If it still fails can you post the complete MQTT payload you are sending?
When I use the URL the lamp toggles correctly, but when I Toggle it via a Sonoff RM433 remote, it does not.
Will check all my settings again, thx for your help