[90] MQTT Support

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: [90] MQTT Support

Post by gizmocuz »

Not at the moment, but i will implement this.

Also the current mqtt client implementation is a bit buggy i found out, working on a new one as we speak.
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: [90] MQTT Support

Post by gizmocuz »

new mqtt library implemented.... next i will do the username/password
(that will be another day :lol: )
Quality outlives Quantity!
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

gizmocuz wrote:new mqtt library implemented....
I get this when compiling?

/home/pi/domoticz/hardware/MQTT.cpp:216:1: error: expected unqualified-id before ‘<<’ token
<<<<<<< .mine
^
/home/pi/domoticz/hardware/MQTT.cpp:225:36: error: ‘MQTTAsync_successData’ has not been declared
void mqtt_onConnect(void* context, MQTTAsync_successData* response)
^
/home/pi/domoticz/hardware/MQTT.cpp: In function ‘void mqtt_onConnect(void*, int*)’:
/home/pi/domoticz/hardware/MQTT.cpp:227:36: error: ‘m_mqtt_mutex’ was not declared in this scope
boost::lock_guard<boost::mutex> l(m_mqtt_mutex);
^
/home/pi/domoticz/hardware/MQTT.cpp:229:11: error: ‘class MQTT’ has no member named ‘OnConnect’
pClient->OnConnect();
^
/home/pi/domoticz/hardware/MQTT.cpp: At global scope:
/home/pi/domoticz/hardware/MQTT.cpp:232:1: error: expected unqualified-id before ‘==’ token
=======
^
make[2]: *** [CMakeFiles/domoticz.dir/hardware/MQTT.cpp.o] Error 1
make[1]: *** [CMakeFiles/domoticz.dir/all] Error 2
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by maxtrash »

chrille wrote:Hi,
I am a new domoticz user and would really like to try the MQTT support, as my current setup is based on MQTT. [...]
can you share a little on how you have implemented your current setup?
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: [90] MQTT Support

Post by gizmocuz »

SweetPants wrote:
gizmocuz wrote:new mqtt library implemented....
I get this when compiling?

...

looks like you have an update conflict

issue

svn revert -R MQTT/*
svn revert -R hardware/*

or

svn revert -R *
Quality outlives Quantity!
chrille
Posts: 8
Joined: Monday 08 June 2015 15:18
Target OS: Linux
Domoticz version: Beta
Location: Horsens, Denmark
Contact:

Re: [90] MQTT Support

Post by chrille »

maxtrash wrote:can you share a little on how you have implemented your current setup?
What I have is more less bits and pieces. I have a number of ESP8266 wireless modules (with temperature, humidity, light and door sensors) that all sends to my MQTT broker. I also have a HA7net and USR-HTW devices that reports to MQTT and finally I'm building an ESP8266/MQTT based module to activate my garage door.
Currently it's tied together with mqttwarn and some scripts, that writes data to RRDtool - however I would like to add better automation than what can be done with mqttwarn and also have a better interface.

Other ideas/plans includes owntrack, more door sensors, power switches (for the espresso machines) and the doorbell. I like to have as much wireless as possible, since the WAF on most wireless stuff is better than wired, and MQTT is a great way to implement new devices without too much hazzle

- Jan
Beaglebone Black, Raspberry Pi (A and B)
Multiple ESP8266 (DIY - temperature, humidity, light, door sensors)
USR-HTW (MQTT), HA7net, 2x Kankun wifi plug (MQTT)
WH1090 weatherstation + weewx (MQTT)
Hikvision IP cameras
KD101 fire alarms
RFXTRX433e + RFlink
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

gizmocuz wrote: looks like you have an update conflict issue

svn revert -R MQTT/*
svn revert -R hardware/*

or

svn revert -R *
You are right, something went wrong with MQTT/*
Thanks
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

chrille wrote:What I have is more less bits and pieces. I have a number of ESP8266 wireless modules (with temperature, humidity, light and door sensors) that all sends to my MQTT broker.
?
- Jan
Jan, are you using NodeMcu or the native MQTT from TuanPMT?
chrille
Posts: 8
Joined: Monday 08 June 2015 15:18
Target OS: Linux
Domoticz version: Beta
Location: Horsens, Denmark
Contact:

Re: [90] MQTT Support

Post by chrille »

SweetPants wrote:Jan, are you using NodeMcu or the native MQTT from TuanPMT?
I am mostly using this russian software: http://esp8266.homes-smart.ru/ - it support at least 90% of the stuff I want to do, and new features are added all the time. For the garagedoor project I'm currently using NodeMCU but will probably switch to the HomesSmart software as well. The author charges a small fee for licenses, but it's worth it, and I save a lot of time. Most of the documentation is in russian but Google translate does a decent job

- Jan
Beaglebone Black, Raspberry Pi (A and B)
Multiple ESP8266 (DIY - temperature, humidity, light, door sensors)
USR-HTW (MQTT), HA7net, 2x Kankun wifi plug (MQTT)
WH1090 weatherstation + weewx (MQTT)
Hikvision IP cameras
KD101 fire alarms
RFXTRX433e + RFlink
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by maxtrash »

chrille wrote:
maxtrash wrote:can you share a little on how you have implemented your current setup?
What I have is more less bits and pieces. I have a number of ESP8266 wireless modules (with temperature, humidity, light and door sensors) that all sends to my MQTT broker. I also have a HA7net and USR-HTW devices that reports to MQTT and finally I'm building an ESP8266/MQTT based module to activate my garage door.
Currently it's tied together with mqttwarn and some scripts, that writes data to RRDtool - however I would like to add better automation than what can be done with mqttwarn and also have a better interface.

Other ideas/plans includes owntrack, more door sensors, power switches (for the espresso machines) and the doorbell. I like to have as much wireless as possible, since the WAF on most wireless stuff is better than wired, and MQTT is a great way to implement new devices without too much hazzle

- Jan
Didn't know about Mqttwarn, as mentioned on Jan-Piet Mens' site it seems to do similar things as can be done with Node-red. Are you going to keep using it to translate messages from and to Domoticz?
I found something called Freeswitch mentioned in the documentation, that's an interesting thing to investigate as well!
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by maxtrash »

In the mean time I decided to simplify the wiki-page to just "MQTT": http://www.domoticz.com/wiki/MQTT
I've also created a page with Node-red (example) flows: http://www.domoticz.com/wiki/Flows
One of the new examples is a mindergas.nl flow
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: [90] MQTT Support

Post by gizmocuz »

thanks!, i added the export to InfluxDB

strangely i could not copy the mindergas flow from the wiki page, i had to edit the source, and then do a copy/past
Quality outlives Quantity!
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by maxtrash »

you're right, I also couldn't just copy the influxdb flow you added. It's got to do with the tag being used. <blockquote> looked nice to me but is giving these problems. Also <code> does not work properly. <source lang=javascript> does work fine from the copying perspective, however the text is now put in one big line which makes it really inconvenient to copy. There's got to be a better tag/solution for handling this but what is it?!
(have a look at the flow page to see what I mean)
chrille
Posts: 8
Joined: Monday 08 June 2015 15:18
Target OS: Linux
Domoticz version: Beta
Location: Horsens, Denmark
Contact:

Re: [90] MQTT Support

Post by chrille »

maxtrash wrote:Didn't know about Mqttwarn, as mentioned on Jan-Piet Mens' site it seems to do similar things as can be done with Node-red. Are you going to keep using it to translate messages from and to Domoticz?
I found something called Freeswitch mentioned in the documentation, that's an interesting thing to investigate as well!
For now I need to keep mqttwarn - at least for the following reasons

- rewrite topics (since Domoticz needs everything published to domoticz/in)
- do JSON formatting - most of the data I receive today are in the form of "<device>/<sensor>: <value>"
- do some basic math (like converting pulses from my power meter into watt)

- Jan
Beaglebone Black, Raspberry Pi (A and B)
Multiple ESP8266 (DIY - temperature, humidity, light, door sensors)
USR-HTW (MQTT), HA7net, 2x Kankun wifi plug (MQTT)
WH1090 weatherstation + weewx (MQTT)
Hikvision IP cameras
KD101 fire alarms
RFXTRX433e + RFlink
kylegordon
Posts: 26
Joined: Thursday 31 October 2013 23:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: [90] MQTT Support

Post by kylegordon »

Oh wow, this is fantastic :-D Thank you to all involved!
1 x HP DL380 & KVM
1 x RPI
1 x RFXtrx433 V78
11 x LWRF Switches
1 x LIFX
2 x Echo Dots
6 x Byron PIRs
2 x Nexa PIRs
2 x Kodi
2 x ESP8266 MQTT
1 x GPIO/MQTT PIR
1 x GPIO(PWM)/MQTT LEDs
1 x GPIO(SPI)/MQTT LPD6803 LEDs
Lots of Node-Red glue
kylegordon
Posts: 26
Joined: Thursday 31 October 2013 23:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: [90] MQTT Support

Post by kylegordon »

This is the node-red flow I use to generate an average temperature from a bunch of sensors in Domoticz, and then feed it back into Domoticz. I find it useful for turning my antiquated heating system on and off, although it has absolutely no protection against hysteresis :-)

Code: Select all

[{"id":"66a92c76.9956d4","type":"mqtt-broker","broker":"homeauto.vpn.glasgownet.com","port":"1883","clientid":""},{"id":"5b5ffbeb.a4a004","type":"mqtt out","name":"House Average Temperature Domoticz","topic":"domoticz/in","qos":"","retain":"","broker":"66a92c76.9956d4","x":1074,"y":243,"z":"1b6aed19.e49513","wires":[]},{"id":"6a89d0ab.95763","type":"function","name":"JSONify","func":"msg.payload = '{\"idx\":46, \"nvalue\": 0, \"svalue\":\"' + msg.payload + ';0;0\"}';\n\nreturn msg;","outputs":1,"x":832,"y":243,"z":"1b6aed19.e49513","wires":[["5b5ffbeb.a4a004"]]},{"id":"5601543e.a9feac","type":"function","name":"Average temp","func":"numdevices = 7;\n\ntotal = parseFloat(context.global.masterbedtemp) + \nparseFloat(context.global.guestbedtemp) + \nparseFloat(context.global.geeklofttemp) + \nparseFloat(context.global.kitchentemp) +\nparseFloat(context.global.studytemp) +\nparseFloat(context.global.livingroomtemp) +\nparseFloat(context.global.bottomhallwaytemp);\n\nmsg.payload = (total / numdevices).toFixed(2);\n//msg.payload = msg.payload + 0.5;\n\nreturn msg;","outputs":1,"x":680,"y":204,"z":"1b6aed19.e49513","wires":[["6a89d0ab.95763"]]},{"id":"57bde324.a8421c","type":"function","name":"Average humidity","func":"numdevices = 6;\n\ntotal = parseFloat(context.global.masterbedhum) + \nparseFloat(context.global.guestbedhum) + \nparseFloat(context.global.geeklofthum) + \nparseFloat(context.global.studyhum) +\nparseFloat(context.global.livingroomhum) +\nparseFloat(context.global.bottomhallwayhum);\n\nmsg.payload = (total / numdevices).toFixed(2);\n//msg.payload = msg.payload + 0.5;\n\nreturn msg;","outputs":1,"x":655,"y":292,"z":"1b6aed19.e49513","wires":[[]]},{"id":"78df9949.872068","type":"function","name":"Select payloads","func":"msg.parameters = JSON.parse(msg.payload);\n//console.log(msg.parameters);\nmsg.topic = \"debug output\";\nmsg.payload = msg.parameters.svalue1;\n\nif ( msg.parameters.idx == 35) {\n  context.global.kitchentemp = msg.parameters.svalue1;\n}\n\nif ( msg.parameters.idx == 116) {\n  context.global.masterbedtemp = msg.parameters.svalue1;\n}\n\nif ( msg.parameters.idx == 117) {\n  context.global.geeklofttemp = msg.parameters.svalue1;\n}\n\nif ( msg.parameters.idx == 122) {\n  context.global.guestbedtemp = msg.parameters.svalue1;\n}\n\nif ( msg.parameters.idx == 132) {\n  context.global.livingroomtemp = msg.parameters.svalue1;\n}\n\nif ( msg.parameters.idx == 133) {\n  context.global.livingroomtemp = msg.parameters.svalue1;\n}\n\nif ( msg.parameters.idx == 134) {\n  context.global.bottomhallwaytemp = msg.parameters.svalue1;\n}\n\nreturn msg;","outputs":"2","x":442,"y":206,"z":"1b6aed19.e49513","wires":[["5601543e.a9feac"],["57bde324.a8421c"]]},{"id":"1f56f12.fe0a90f","type":"mqtt in","name":"Domoticz out","topic":"domoticz/out","broker":"66a92c76.9956d4","x":235,"y":189,"z":"1b6aed19.e49513","wires":[["78df9949.872068"]]}]
1 x HP DL380 & KVM
1 x RPI
1 x RFXtrx433 V78
11 x LWRF Switches
1 x LIFX
2 x Echo Dots
6 x Byron PIRs
2 x Nexa PIRs
2 x Kodi
2 x ESP8266 MQTT
1 x GPIO/MQTT PIR
1 x GPIO(PWM)/MQTT LEDs
1 x GPIO(SPI)/MQTT LPD6803 LEDs
Lots of Node-Red glue
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: [90] MQTT Support

Post by gizmocuz »

maxtrash wrote:In the mean time I decided to simplify the wiki-page to just "MQTT": http://www.domoticz.com/wiki/MQTT
I've also created a page with Node-red (example) flows: http://www.domoticz.com/wiki/Flows
One of the new examples is a mindergas.nl flow
question, the meter value uploaded to mindergas.nl, should this be divided by 1000 before uploading ?

because i have this value:
mindergas.png
mindergas.png (10.16 KiB) Viewed 3833 times
Quality outlives Quantity!
roblom
Posts: 402
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Re: [90] MQTT Support

Post by roblom »

Mindergas wants his value in m3 so I don't think it should be devided.
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: [90] MQTT Support

Post by gizmocuz »

its a pretty big value now ;) 2185074,22
Quality outlives Quantity!
roblom
Posts: 402
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Re: [90] MQTT Support

Post by roblom »

Then the unit in the picture is already wrong, or there is a gas turbine in the backyard :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests