MQTT toggle option for switchcmd

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
wildfire
Posts: 13
Joined: Friday 18 September 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

MQTT toggle option for switchcmd

Post 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&param=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
SweetPants

Re: MQTT toggle option for switchcmd

Post 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
wildfire
Posts: 13
Joined: Friday 18 September 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: MQTT toggle option for switchcmd

Post 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.
SweetPants

Re: MQTT toggle option for switchcmd

Post by SweetPants »

wildfire wrote:this should be added to the MQTT wiki btw. https://www.domoticz.com/wiki/MQTT
That is the beauty of an opensource project, you can add it to the Wiki yourself. You can login with your domoticz user credentials.
jurgend
Posts: 9
Joined: Sunday 18 April 2021 13:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: MQTT toggle option for switchcmd

Post 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?
User avatar
waltervl
Posts: 5567
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: MQTT toggle option for switchcmd

Post 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&param=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?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jurgend
Posts: 9
Joined: Sunday 18 April 2021 13:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: MQTT toggle option for switchcmd

Post 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&param=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
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests