Page 8 of 17
Re: MQTT Client
Posted: Sat Oct 08, 2016 8:13 pm
by kalinkamaen
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!
Re: MQTT Client
Posted: Fri Oct 14, 2016 3:52 pm
by kalinkamaen
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:
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]
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.
Code: Select all
On=
MQTT.domoticz/out/Lighting 2/30
Off=
MQTT.domoticz/out/Lighting 2/30
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!
Re: MQTT Client
Posted: Fri Oct 14, 2016 9:02 pm
by krambriw
I thought I fixed that in the latest version. Have you tried to download the latest from my server? Use the link below.
Re: MQTT Client
Posted: Fri Oct 14, 2016 9:15 pm
by kalinkamaen
I am using Paho version. Is that the wrong one?
Re: MQTT Client
Posted: Sat Oct 15, 2016 4:45 am
by krambriw
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"
Re: MQTT Client
Posted: Sat Oct 15, 2016 8:30 am
by kalinkamaen
Its working now.

Thank you!
Re: MQTT Client
Posted: Sat Oct 15, 2016 5:06 pm
by Speshal
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"
Hej Walter, Hur mår du?
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]
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.
I know bugger all about python but I am trying to learn
So if someone could explain with examples

on how I would go about that it would be awesome.
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
Re: MQTT Client
Posted: Sat Oct 15, 2016 5:46 pm
by krambriw
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):
Code: Select all
http://<username:password@>domoticz-ip<:port>/json.htm?type=command¶m=switchlight&idx=99&switchcmd=Toggle
Here you have the full API description if you would neeed other functions
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
Re: MQTT Client
Posted: Sat Oct 15, 2016 8:47 pm
by WoLpH
Speshal 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.
In that case I'd recommend just using the domoticz plugin. The switch values are on, off and toggle

Re: MQTT Client
Posted: Sun Oct 16, 2016 5:01 am
by krambriw
Of course

Re: MQTT Client
Posted: Sun Oct 16, 2016 5:50 am
by Speshal
WoLpH wrote:Speshal 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.
In that case I'd recommend just using the domoticz plugin. The switch values are on, off and toggle

Thanks for that

I maybe didn't explain myself too well
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.....
when the following is received.
Then I need to work out a way of saying - If Switch1 = On then switch Off and if Switch1 = Off then switch On
But my python is letting me down badly as I keep getting syntax errors all over the place

Re: MQTT Client
Posted: Sun Oct 16, 2016 7:50 am
by kalinkamaen
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.
Re: MQTT Client
Posted: Sun Oct 16, 2016 11:56 am
by Speshal
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

As it stands, I look a bit silly as I have to say "Kitchen" twice!
I made a bit of progress this morning by adding the script.
to
I was then thinking I could use jump to execute the task but that's as far as I got.
I'm probably over complicating things

Re: MQTT Client
Posted: Sun Oct 16, 2016 12:18 pm
by kalinkamaen
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?
Re: MQTT Client
Posted: Sun Oct 16, 2016 12:53 pm
by kalinkamaen
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!