Page 8 of 19

Re: [90] MQTT Support

Posted: Monday 08 June 2015 18:33
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.

Re: [90] MQTT Support

Posted: Monday 08 June 2015 19:06
by gizmocuz
new mqtt library implemented.... next i will do the username/password
(that will be another day :lol: )

Re: [90] MQTT Support

Posted: Monday 08 June 2015 19:10
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

Re: [90] MQTT Support

Posted: Monday 08 June 2015 19:22
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?

Re: [90] MQTT Support

Posted: Monday 08 June 2015 19:28
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 *

Re: [90] MQTT Support

Posted: Monday 08 June 2015 19:48
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

Re: [90] MQTT Support

Posted: Monday 08 June 2015 20:16
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

Re: [90] MQTT Support

Posted: Monday 08 June 2015 20:20
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?

Re: [90] MQTT Support

Posted: Monday 08 June 2015 20:26
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

Re: [90] MQTT Support

Posted: Monday 08 June 2015 20:32
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!

Re: [90] MQTT Support

Posted: Monday 08 June 2015 20:35
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

Re: [90] MQTT Support

Posted: Monday 08 June 2015 21:37
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

Re: [90] MQTT Support

Posted: Monday 08 June 2015 22:46
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)

Re: [90] MQTT Support

Posted: Tuesday 09 June 2015 8:04
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

Re: [90] MQTT Support

Posted: Tuesday 09 June 2015 12:40
by kylegordon
Oh wow, this is fantastic :-D Thank you to all involved!

Re: [90] MQTT Support

Posted: Tuesday 09 June 2015 12:42
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"]]}]

Re: [90] MQTT Support

Posted: Thursday 11 June 2015 17:59
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 4072 times

Re: [90] MQTT Support

Posted: Thursday 11 June 2015 18:44
by roblom
Mindergas wants his value in m3 so I don't think it should be devided.

Re: [90] MQTT Support

Posted: Thursday 11 June 2015 18:46
by gizmocuz
its a pretty big value now ;) 2185074,22

Re: [90] MQTT Support

Posted: Thursday 11 June 2015 19:03
by roblom
Then the unit in the picture is already wrong, or there is a gas turbine in the backyard :-)