MQTT integration
Moderators: leecollings, remb0
MQTT integration
Hi guys,
I'm going crazy!
I'm starting in these days with Domoticz so I'm not a master, but I've looked all around and I can't find a way to have him to talk with MQTT.
I've created a "MQTT Client Gateway with LAN interface" and in the log I see that it connects.
I've created the dummy hardware and a virtual Switch. But how can I tell Domoticz to react to certain MQTT command that he receives?
How can I tell the switch to send a command in MQTT to switch on/off a device?
Thanks in advance!
Andrea
I'm going crazy!
I'm starting in these days with Domoticz so I'm not a master, but I've looked all around and I can't find a way to have him to talk with MQTT.
I've created a "MQTT Client Gateway with LAN interface" and in the log I see that it connects.
I've created the dummy hardware and a virtual Switch. But how can I tell Domoticz to react to certain MQTT command that he receives?
How can I tell the switch to send a command in MQTT to switch on/off a device?
Thanks in advance!
Andrea
-
- Posts: 19
- Joined: Tuesday 19 January 2016 10:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.4608
- Location: 's-Hertogenbosch
- Contact:
Re: MQTT integration
RPi Model 2: Domoticz Server (Beta)
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
Re: MQTT integration
Hi daandamhuis!
I've read that wiki and I've seen this:
But where should I put that direction?
I've also seen the examples like this one for Domoticz to MQTT:
and this one for MQTT to Domoticz:
But where do I put this code???
Thanks a lot!
I've read that wiki and I've seen this:
Code: Select all
Communication from and to Domoticz works via JSON. Default MQTT topics of the Domoticz for incoming and outcoming messages are:
domoticz/in
domoticz/out
I've also seen the examples like this one for Domoticz to MQTT:
Code: Select all
{
"idx" : 5,
"name" : "Internal Temperature",
"id" : "00080A",
"unit" : 1
"dtype" : "Temp",
"stype" : "TFA 30.3133",
"nvalue" : 0,
"svalue1" : "41.2",
"Battery" : 100,
"RSSI" : 12,
}
Code: Select all
{
"idx" : 7,
"nvalue" : 0,
"svalue" : "90;2975.00"
}
Thanks a lot!
- nayr
- Posts: 354
- Joined: Tuesday 11 November 2014 18:42
- Target OS: Linux
- Domoticz version: github
- Location: Denver, CO - USA
- Contact:
Re: MQTT integration
use a mqtt client library to connect to Mosquitto and subscribe to domoticz/out..
check out my node-domoticz-mqtt module, all the code is written you just have to make it do something.
check out my node-domoticz-mqtt module, all the code is written you just have to make it do something.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Re: MQTT integration
But how do I subscribe to domoticz in/out?
Sorry for the silly question but...where do I see your module?
Sorry for the silly question but...where do I see your module?
- nayr
- Posts: 354
- Joined: Tuesday 11 November 2014 18:42
- Target OS: Linux
- Domoticz version: github
- Location: Denver, CO - USA
- Contact:
Re: MQTT integration
thats part of the MQTT protocol, you have to write your own client to to implement the protocol.. most popular programing languages have MQTT Client libraries that have most of the protocol work done for you..
https://www.npmjs.com/package/node-domoticz-mqtt
this is for implementing MQTT with JavaScript, it was written against Domoticz's JSON API so you dont even have to make the json.. just call the functions you need.
https://www.npmjs.com/package/node-domoticz-mqtt
this is for implementing MQTT with JavaScript, it was written against Domoticz's JSON API so you dont even have to make the json.. just call the functions you need.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Re: MQTT integration
Nayr, thanks again for your patience answering me, but I really don't know where to use that code!
-
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: MQTT integration
What do you want to achieve using MQTT
Re: MQTT integration
Hi Pepijn,
I want to change the state of some switch when receiving certain messages and send some messages when the switches are pressed
I want to change the state of some switch when receiving certain messages and send some messages when the switches are pressed
-
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
MQTT integration
Domoticz only allows Domoticz/in and Domoticz/out topics with specific message formats as described above. So there are 2 options:
1) your device or application should publish (and subscribe) messages according the Domoticz standard
2) you use something in the middle that translates your messages to Domoticz and back. I use Node-RED for this matter, it's part of the Domoticz SD card
1) your device or application should publish (and subscribe) messages according the Domoticz standard
2) you use something in the middle that translates your messages to Domoticz and back. I use Node-RED for this matter, it's part of the Domoticz SD card
Re: MQTT integration
For that purpose I've installed nodered on the Raspberry Pi that manage the relays
-
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: MQTT integration
And you build a flow to do this translation?
Re: MQTT integration
Well...I still have to do that (read the GPIO status and send it, and react on messages coming from Domoticz), but first I need to send those messages from Domoticz and be able to use the one that nodered will send, and this is an obscure part for me!
-
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: MQTT integration
You also have to build a flow for this as well. There are some samples on the wiki but some basic knowledge on node-red is really needed. So yo might start reading on nodered.org
Re: MQTT integration
I'm doing that, but I need info on the Domoticz side to use that flow and to send something back
-
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: MQTT integration
This is described in the wiki https://www.domoticz.com/wiki/MQTT
To set a switch in Domoticz publish a message to MQTT to the domoticz/in topic with the following message payload:
Domoticz will publish every device update to domoticz/out so you have to filter the messages you need and translate them to the destination message format,
To set a switch in Domoticz publish a message to MQTT to the domoticz/in topic with the following message payload:
Code: Select all
{"command": "switchlight", "idx": 2450, "switchcmd": "On", "level": 100 }
Re: MQTT integration
But how do I tell Domoticz to listen on port 1883? And how do I tell Domoticz the IP where to send the send the updates?
-
- Posts: 251
- Joined: Friday 12 July 2013 13:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: MQTT integration
Add the MQTT hardware on the device settings
Re: MQTT integration
You mean the "MQTT Client Gateway with LAN interface" on the Hardware section?
Because i don't see any setting in the device section
Because i don't see any setting in the device section
Re: MQTT integration
I got Domoticz to talk to Node-RED (i still have to "translate" the message passed to turn on/off GPIO)
and right now I got Node-RED to talk to Domoticz too!!!
Thanks!
and right now I got Node-RED to talk to Domoticz too!!!
Thanks!
Who is online
Users browsing this forum: No registered users and 1 guest