Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
MQTT Client
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: MQTT Client
Nice. Sorry, didnt see the updated text and pictures there. I will give you an message if i need som help.
Thank you both for this work!
Thank you both for this work!
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: MQTT Client
Hello sir.
I have playing around with this plugin connected with Domoticz and I have a problem.
If i turn on and off a light switch this is what Evenghost log:
As i can understand 0 is Off an 1 is On.
The problem for me is when i move this event over to the configuration window it loks like this.
There is no difference between On and Off!
I have tried to copy and paste it into new event. Then it shows the right text in configuration window.
But then evetghost doesnt catch the event when its happening!
I have playing around with this plugin connected with Domoticz and I have a problem.
If i turn on and off a light switch this is what Evenghost log:
Code: Select all
ON=
MQTT.domoticz/out/Lighting 2/30 [255, 5, 'Lighting 2', '0A13A86', 30, '', 1, 'AC', '15', 'On/Off', 11]
OFF=
MQTT.domoticz/out/Lighting 2/30 [255, 5, 'Lighting 2', '0A13A86', 30, '', 0, 'AC', '15', 'On/Off', 11]The problem for me is when i move this event over to the configuration window it loks like this.
Code: Select all
On=
MQTT.domoticz/out/Lighting 2/30
Off=
MQTT.domoticz/out/Lighting 2/30I have tried to copy and paste it into new event. Then it shows the right text in configuration window.
But then evetghost doesnt catch the event when its happening!
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: MQTT Client
I thought I fixed that in the latest version. Have you tried to download the latest from my server? Use the link below.
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: MQTT Client
I am using Paho version. Is that the wrong one?
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: MQTT Client
Yes, you are using the correct, it is only the paho version that has support domoticz
I had to improve the decoding of events for on/off switches. I did not know that the event structure could vary that way. Now it should work
New version published
"Modified decoding of Domoticz events for on/off switches"
I had to improve the decoding of events for on/off switches. I did not know that the event structure could vary that way. Now it should work
New version published
"Modified decoding of Domoticz events for on/off switches"
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: MQTT Client
Its working now.
Thank you!
Re: MQTT Client
Hej Walter, Hur mår du?krambriw wrote:Yes, you are using the correct, it is only the paho version that has support domoticz
I had to improve the decoding of events for on/off switches. I did not know that the event structure could vary that way. Now it should work
New version published
"Modified decoding of Domoticz events for on/off switches"
Tack s├Ñ mycket f├Âr MQTT plugin (OK that's the limit of my Swedish
I was wondering if you could help me out?
I got the updated MQTT working from Domoticz fine with the output as
Code: Select all
MQTT.domoticz/out/Lighting 1/3/0 [255, 12, 'Lighting 1', '65', 3, 'Switch 1', 0, 'X10', 'On/Off', 1]I.E I need to query the current state of the switch and if it's on, turn it off and vice versa.
I know bugger all about python but I am trying to learn
So if someone could explain with examples
Something like - query state of switch - write state to variable - if variable is on then switch off - if switch is off the switch on.
I hope this makes sense
Tack.
(En stor stark) That's the only other Swedish I know
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: MQTT Client
Hej,
I think you are improving your Swedish! The most important you learned already (en stor stark)
Regarding your toggle function, you cannot query the status with mqtt. The plugin provides you with status changes (events) automatically when they happen. If you would toggle on every change, the system would go into an endless spin so that won't work.
Instead you should use the API/JSON already available in Domoticz. To toggle a switch with id=99 between on/off, use this url (test it in a browser):
Here you have the full API description if you would neeed other functions
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
I think you are improving your Swedish! The most important you learned already (en stor stark)
Regarding your toggle function, you cannot query the status with mqtt. The plugin provides you with status changes (events) automatically when they happen. If you would toggle on every change, the system would go into an endless spin so that won't work.
Instead you should use the API/JSON already available in Domoticz. To toggle a switch with id=99 between on/off, use this url (test it in a browser):
Code: Select all
http://<username:password@>domoticz-ip<:port>/json.htm?type=command¶m=switchlight&idx=99&switchcmd=ToggleHere you have the full API description if you would neeed other functions
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: MQTT Client
In that case I'd recommend just using the domoticz plugin. The switch values are on, off and toggleSpeshal wrote:What I need help with is to create a toggle action based on the current state of the switch (if that makes sense?)
I.E I need to query the current state of the switch and if it's on, turn it off and vice versa.
Author of the book Mastering Python. Got Python questions? Perhaps I can help 
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: MQTT Client
Of course 
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: MQTT Client
WoLpH wrote:In that case I'd recommend just using the domoticz plugin. The switch values are on, off and toggleSpeshal wrote:What I need help with is to create a toggle action based on the current state of the switch (if that makes sense?)
I.E I need to query the current state of the switch and if it's on, turn it off and vice versa.
Thanks for that
I have the Domoticz plugin and it toggles switch 1 fine and I get the response back fine as well.
╠Â
What I need to do is find a bit of code that if Switch 1 is on then switch it off and if switch 1 is off then turn it on, if that makes sense.
Something along the lines of.....
Code: Select all
Switch1 = OnCode: Select all
MQTT.domoticz/out/Lighting 1/3/1But my python is letting me down badly as I keep getting syntax errors all over the place
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: MQTT Client
Sorry, but I cant understand why you want to make the switch go on and off in this cycle.
If I do understand you right you switch will cycle between on and off constantly!
If you tell us what you are you are going to use it for, we would probably better understand you question.
If I do understand you right you switch will cycle between on and off constantly!
If you tell us what you are you are going to use it for, we would probably better understand you question.
Re: MQTT Client
kalinkamaen wrote:Sorry, but I cant understand why you want to make the switch go on and off in this cycle.
If I do understand you right you switch will cycle between on and off constantly!
If you tell us what you are you are going to use it for, we would probably better understand you question.
I thought that might be the case.
I shall give you an example.
Say I have a light in my kitchen, it can be switched on from a light switch on the wall, it can also be controlled from Eventghost. If I control the light just from Eventghost it's fine as I have made a task that turns that light on from my tablet that toggles the light between on and off.
If my wife goes to the kitchen and uses the switch on the wall and comes back I cannot just use my kitchen light task as my tablet thinks the light is off so switches it on when it's already on, so I have to run the task twice which can be annoying
I use Autovoice so I'd like to just be able to say "Kitchen" once and if the light is off, then turn it on, and if the light is on then turn it off
I made a bit of progress this morning by adding the script.
Code: Select all
Switch1 = "On"
print Switch1Code: Select all
MQTT.domoticz/out/Lighting 1/3/1I'm probably over complicating things
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: MQTT Client
I think you are overcomplecating things a little. But i could be that I am wrong also.
So what I do understand on you writing. You have a switch on the wall <--- (Wireless, or does this switch have any connection with
domoticz/Eventghost?)
And you have a virtual switch on your tablet that you can control by voice or tablet Domoticz/Eventghost?
Is this correct?
So if you girlfriend is using wall switch, you want the virtual Eventghost/Domoticz switch to be updated?
And the same is for the other way around?
So what I do understand on you writing. You have a switch on the wall <--- (Wireless, or does this switch have any connection with
domoticz/Eventghost?)
And you have a virtual switch on your tablet that you can control by voice or tablet Domoticz/Eventghost?
Is this correct?
So if you girlfriend is using wall switch, you want the virtual Eventghost/Domoticz switch to be updated?
And the same is for the other way around?
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: MQTT Client
I have made a example of what i think could work for you! But it could be that I understand you wrong.

If you now use wall switch or voice kitchen, it will turn on roof lamp and switch both virtuell and wall switch on.
EG wil then disable on folder and enable off folder. So next time you girlfriend hits off button. She will
turn off lights reset both virtuell button and wall switch button to off, disable off folder and enable On folder.
I hope you understand. I often use this for my TV control power on and off!
You can also use EG control plugin to save configuration on both commands. So if EG restarts it will remeber state!

If you now use wall switch or voice kitchen, it will turn on roof lamp and switch both virtuell and wall switch on.
EG wil then disable on folder and enable off folder. So next time you girlfriend hits off button. She will
turn off lights reset both virtuell button and wall switch button to off, disable off folder and enable On folder.
I hope you understand. I often use this for my TV control power on and off!
You can also use EG control plugin to save configuration on both commands. So if EG restarts it will remeber state!