Page 1 of 1

MQTT help

Posted: Wednesday 25 May 2016 10:53
by parrotface
I have tried for about 12 months to get domoticz to subscribe to mqtt No Luck
Question
How do I create a dummy MQTT device - I can create a device but not a MQTT device.
setup > hardware > MQTT Client gateway with Lan interface
Then how do I create a Virtual sensor ? NO Button only in Dummy but wll dummy talk to MQTT
I can sen json code to sensor - 192.168.1.121:8080/json.htm?type=command&param=udevice&idx=18&nvalue=0&svalue=TEXTroger this works

How do I do the same thing from Mosquitto command line and from a python script

In Python I have tried
message = '{"command": "switchlight", "idx": 11, "switchcmd": "On"}'
publish.single("domoticz/in", message, hostname="192.168.1.120")

Thanks any help or pointer would be helpful
I have a load of ESP8266 which I can control with mosquitto command line and now trying to use Domoticz to do the same thing
Thanks

Re: MQTT help

Posted: Wednesday 25 May 2016 20:27
by SweetPants
This also works on my system:

mosquitto_pub -h <ip MQTT broker> -u <username> -P <password> -t 'domoticz/in' -m '{"command": "switchlight", "idx": 85, "switchcmd": "On"}'

So there might be something wrong with your python script?

Re: MQTT help

Posted: Wednesday 25 May 2016 21:57
by parrotface
Thanks for you reply
I can send a json command from my browser which works, how do I send the same thing in mosquitto.

http://192.168.1.121:8080/json.htm?type ... alue=BINGO yellow

does the device I am sending to need to be MQTT and if so how do you create a MQTT dummy device
I can only create dummy devices which are not MQTT

many Thanks

Re: MQTT help

Posted: Thursday 26 May 2016 8:12
by SweetPants
parrotface wrote: how do I send the same thing in mosquitto.
read my previous post, use the mosquitto_pub cli command

Re: MQTT help

Posted: Friday 27 May 2016 10:14
by parrotface
Thanks for your help
Looks like I did not understand, I thought you had to set each device to MQTT, now found you need MQTT once and then all switches work with MQTT.
I was looking in the device list for the action when a MQTT command is received which does not show the changes untill refreshed. View the switches and you can see the chages as they happen.
Working Example - mosquitto_pub -h 192.168.1.120 -t 'domoticz/in' -m '{"command": "switchlight", "idx": 9, "switchcmd": "On"}'

Next problem
In Utility tab I have sensors which work with Json
Example 192.168.1.121:8080/json.htm?type=command&param=udevice&idx=19&nvalue=4&svalue=TEXT Alert in red
Question What is the syntax for this in mosquitto command line

Thanks for your help - Now starting to get going at long last

Re: MQTT help

Posted: Friday 27 May 2016 12:32
by SweetPants
Have you read the Wiki? https://www.domoticz.com/wiki/MQTT

Re: MQTT help

Posted: Friday 27 May 2016 16:40
by parrotface
Yes I have read Wiki
I just can figure it out. I can switch OK
I can get the following working
mosquitto_pub -h 192.168.1.120 -t 'domoticz/in' -m '{"command": "switchlight", "idx": 1, "switchcmd": "On"}'
mosquitto_pub -h 192.168.1.120 -t 'domoticz/in' -m '{"command": "getdeviceinfo", "idx": 19 }'

And this works in a webbrowser
192.168.1.121:8080/json.htm?type=command&param=udevice&idx=19&nvalue=4&svalue=TEXT Alert in red
I can't figure out the syntax for mosquitto to do the same thing

I just need a little help please
please please
thanks again

Re: MQTT help

Posted: Friday 27 May 2016 22:02
by SweetPants
I think you mean: mosquitto_pub -h 192.168.1.120 -t 'domoticz/in' -m '{"command": "udevice", "idx": 19, "svalue": "Test Test Test"}'

Re: MQTT help

Posted: Friday 27 May 2016 22:32
by parrotface
Thank you so much, That works.
I will now try and get other things working.
I feel I am moving forward again. I have Domoticz talking to 6 ESP8266 chips and now hope to monitor them.
Thanks again for all your help