Page 14 of 19

Re: [90] MQTT Support

Posted: Monday 15 February 2016 21:42
by deennoo
@nayr, thanx your job.

I test some devices this morning with Android app you références on previous post to read mqtt flow, and it works on last beta.

It's look like you have a great expérience on MQTT.

Is this possible you update the wiki with an exemple showing how to get a dummy switch toggle true MQTT and send it to a device with node red ?

I want to use MQTT but wiki MQTT & wiki flows are very technic and not really accessible.

Re: [90] MQTT Support

Posted: Monday 15 February 2016 21:58
by nayr
I have not played with Node-Red at all, well I take that back.. I followed the wiki my with my first foray into MQTT, and did not like the Node-Red component. Since then all my work with MQTT has been direct against the domoticz/in and domoticz/out.

I get the impression Node-Red is only needed to take existing MQTT clients and make them talk w/Domoticz without modification.. well all my MQTT clients are designed specifically for domoticz so they communicate natively without any Node-Red translation.

If your working on a new integration, ignore all the Node-Red crap and just use MQTT as a bi-directional JSON API.. it works much like the URL API except you send/receive the JSON via the MQTT Broker.

this is all you have to send in to set a Dimmer switch with IDX of 1 to level 50:

Code: Select all

{"command":"switchlight","idx":1,"switchcmd":"Set Level","level":50}
to set a binary switch with IDX of 1 to ON:

Code: Select all

{"command":"switchlight","idx":1,"switchcmd":"On"}
check out my node-domoticz-mqtt module, with it you can use Node JavaScript to spin out scripts/apps in much the same way as the internal Lua, Blocky and Python interpreters.

Re: [90] MQTT Support

Posted: Thursday 24 March 2016 12:13
by SchattenMann
Any chance we can get Kodi support?
I've just added Kodi to Domoticz but looks like we don't get any MQTT messages with status updates :-(
I'm happy to help in any way i can!

Re: [90] MQTT Support

Posted: Tuesday 26 April 2016 22:55
by Lyubomyr
I added a dummy humidity sensor and use this

Code: Select all

[{"id":"2543a541.b26dba","type":"mqtt-broker","broker":"127.0.0.1","port":"1883","clientid":""},{"id":"3086682d.a477a8","type":"inject","z":"7d53d511.239b3c","name":"Update Data","topic":"","payload":"{\"idx\": 161, \"nvalue\": 1, \"svalue\": \"456\" }","payloadType":"str","repeat":"1","crontab":"","once":false,"x":225,"y":363,"wires":[["e61556e0.5bd898"]]},{"id":"e61556e0.5bd898","type":"mqtt out","z":"7d53d511.239b3c","name":"Domoticz In","topic":"domoticz/in","qos":"","retain":"","broker":"2543a541.b26dba","x":435,"y":443,"wires":[]}]
But the value of the sensor is updated from the nvalue not from the svalue.

Why??

In this case value of dummy humidity is always equal 1%

Re: [90] MQTT Support

Posted: Wednesday 27 April 2016 0:40
by Lyubomyr
And another question:
Below my function for update temperature+humidity
(it is the same when I uncomment the commented line)

But when I look in the setup->Devices I see this
Hum2.png
Hum2.png (2.34 KiB) Viewed 7881 times
but not as in the non-MQTT version
Hum1.png
Hum1.png (3.55 KiB) Viewed 7881 times

Code: Select all

if (msg.nodeId == 25 & msg.payload !="\n" & msg.messageType == 1)
{
    var msg_new = {};
    msg_new.payload = {};
    
    msg_new.payload.idx = 162,
    msg_new.payload.nvalue = 0,    
        
    msg_new.payload.svalue = ""+context.global.temp+";"+context.global.hum+"";        
        
    //msg_new.payload = {"idx": 162, "nvalue": 1, "svalue": "4;1" }
return msg_new;
}

Re: [90] MQTT Support

Posted: Wednesday 27 April 2016 2:16
by Lyubomyr
And another question^

what is the difference between nvalue and svalue? Some sensors and actuators use nvalue others use svalue!

Re: [90] MQTT Support

Posted: Monday 30 May 2016 19:17
by woody4165
Hi

I'm trying MQTT support, but I don't understand how to configure it.

I'm on latest beta, and as far as I understood from the Wiki, no additional SW have to be installed.

What about the configuration of a new MQTT Hw?

Image

What I have to put into Remote Address and Port? And where I can choose username and password in my configuration?

mosquitto is running since if I do

Code: Select all

ps -ef | grep mosq && netstat -tln | grep 1883
I get results

And what about CA Filename?
I haven't found these info on the Wiki, so I'm here to ask some help.

Thanks

Re: [90] MQTT Support

Posted: Monday 30 May 2016 20:43
by woody4165
Got it working!
Just needed to make some config, I found these explanations easy and useful https://www.digitalocean.com/community/ ... -owntracks
and then put the info in the Domoticz panel.
CA is not needed, but maybe is useful for security.
I tried with a MQTT Chrome App to send something after subscribing to domoticz/in and domoticz/out and it seems to work.
I will explore more,sorry to post info request before searching more and more

Re: [90] MQTT Support

Posted: Monday 30 May 2016 20:45
by Kouseri
woody4165 wrote: What I have to put into Remote Address and Port? And where I can choose username and password in my configuration?
If MQTT server is running in a same computer with the Domoticz then you should use following:
Remote address = 127.0.0.1
Port = 1883

Of course you need to create a virtual sensors (create a Dummy device first in Hardware page) that are used receive incoming MQTT data.

Re: [90] MQTT Support

Posted: Tuesday 31 May 2016 7:57
by woody4165
What do you mean by virtual sensor that receive incoming Mqtt data?
Should I send instead mqtt message that contains what I can do with htto/json?

Re: [90] MQTT Support

Posted: Tuesday 31 May 2016 9:28
by Kouseri
woody4165 wrote:What do you mean by virtual sensor that receive incoming Mqtt data?
Should I send instead mqtt message that contains what I can do with htto/json?
I meant that you should create a virtual sensor(s) first and use the IDX(s) of the created sensor(s) in MQTT messages.

Re: [90] MQTT Support

Posted: Thursday 02 June 2016 10:56
by woody4165
Hi all

I'm having issue on let mosquito start at boot
If I run it by command line it's ok, but haven't found a way to let it start as service or during boot?
Can you help me also with some link or instructions?

Thanks

Re: [90] MQTT Support

Posted: Friday 29 July 2016 14:37
by Madgeni
Hi all -
i'm interested in the concept of event-driven notifications, but i've a stupid Q (and the forum doesn't let me search on 3 letter-words!) - if i post an update from a 3rd party h/w to MQTT on say a switch state change (on/off), do I need to then write more code to identify and obtain the IDX for this?

I think the Wiki could do with some more info in it - i get the sense there's a lot if implied knowledge in it

Re: [90] MQTT Support

Posted: Saturday 30 July 2016 14:05
by Kouseri
Madgeni wrote:Hi all -
i'm interested in the concept of event-driven notifications, but i've a stupid Q (and the forum doesn't let me search on 3 letter-words!) - if i post an update from a 3rd party h/w to MQTT on say a switch state change (on/off), do I need to then write more code to identify and obtain the IDX for this?
I have done this by adding a virtual device to the Domoticz and using a IDX associated to the virtual device in my Arduino based devices. So you don't need to write more code in order to identify and obtain the IDX. You can find my implementations from the github.

Re: [90] MQTT Support

Posted: Wednesday 03 August 2016 8:49
by Reley
Ok, call me a n00b but I am not getting MQTT to work to send data to Influxdb.
What I want to achieve:
Send gas meter (P1) data to influx so I can create cool graphics in Grafana.
The protocol from the gasmeter is not yet supported by Http-Link so I wanted to try something via MQTT.

I created the hardware device:
Image

And according to the log there is a connection:
2016-08-02 11:56:16.123 MQTT: Connecting to xxx.xxx.xxx.xxx:1883
2016-08-02 11:56:16.225 MQTT: connected to: xxx.xxx.xxx.xxx:1883
2016-08-02 11:56:16.325 MQTT: Subscribed

In Node-Red I imported the following:

Code: Select all

[{"id":"7b366043.74005","type":"mqtt-broker","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":15,"cleansession":true,"willQos":"0","birthQos":"0"},{"id":"1be38963.6067a7","type":"mqtt in","z":"ecee940b.146508","name":"Domotic Out","topic":"domoticz/out","broker":"7b366043.74005","x":120,"y":158,"wires":[["962a6069.2b9c5"]]},{"id":"962a6069.2b9c5","type":"function","z":"ecee940b.146508","name":"ToInfluxDB","func":"var date = new Date(msg.payload);\ndata=JSON.parse(msg.payload);\n\nmsg.payload = {}; //null msg obj and create new properties\n\nvar influx_obj = \"[{\";\n\n\ninflux_obj += '\"name\": \"' + data.dtype.split(\" + \").join(\"\") + '\",';\nvar columns='\"columns\": [';\n\ncolumns+='\"idx\", \"nvalue\"';\n\nvar points='\"points\": [[';\n\npoints+= data.idx + ', ' + data.nvalue;\n\nfor (ii=0; ii<10; ii++)\n{\n    var vidx = (ii+1).toString();\n    var vname = \"svalue\" + vidx;\n    if (typeof data[vname] != 'undefined') {\n        columns+=', \"' + vname + '\"';\n        var vdata=data[vname];\n        if (!isNaN(vdata)) {\n            points+=', ' + parseFloat(vdata);\n        }\n        else {\n            points+=', \"' + vdata + '\"';\n        }\n    }\n}\n\n\ncolumns+=']';\npoints+=']]';\n\ninflux_obj+=columns+\",\" + points;\n\ninflux_obj+=\"}]\";\n\nmsg.payload=influx_obj;\n\nreturn msg;","outputs":1,"noerr":0,"x":225,"y":224,"wires":[["df17cf36.7a29f","19155261.c3e15e"]]},{"id":"df17cf36.7a29f","type":"debug","z":"ecee940b.146508","name":"","active":false,"console":false,"complete":false,"x":528.0833129882812,"y":223.08331298828125,"wires":[]},{"id":"19155261.c3e15e","type":"http request","z":"ecee940b.146508","name":"TEST","method":"POST","ret":"txt","url":"http://xxx.xxx.xxx.xxx:8086/db/domoticz/series?u=root&p=root","x":333.08331298828125,"y":317.08331298828125,"wires":[["4bab87f8.cc2218"]]},{"id":"4bab87f8.cc2218","type":"debug","z":"ecee940b.146508","name":"","active":false,"console":false,"complete":false,"x":529,"y":317,"wires":[]}]
Node-Red can deploy this without issues and has connection to Domoticz
Image

But still, no info in Influx...
What am I doing wrong??

Re: [90] MQTT Support

Posted: Sunday 14 August 2016 22:39
by Twinsen
How can I publish some information on domoticz/out when a device (Temperature and Humidity) is updated?
I search on wiki but without success ...

Re: [90] MQTT Support

Posted: Monday 15 August 2016 12:24
by Kouseri
Twinsen wrote:How can I publish some information on domoticz/out when a device (Temperature and Humidity) is updated?
I search on wiki but without success ...
I'm using a lua script to publish needed events from the Domoticz. The script can be found from here.

Re: [90] MQTT Support

Posted: Monday 15 August 2016 19:43
by SweetPants
Twinsen wrote:How can I publish some information on domoticz/out when a device (Temperature and Humidity) is updated?.
On my system domoticz/out is updated every time my temp+hum sensors are updated:
{
"Battery" : 100,
"RSSI" : 12,
"dtype" : "Temp + Humidity",
"id" : "13825",
"idx" : 93,
"name" : "Badkamer",
"nvalue" : 0,
"stype" : "WTGR800",
"svalue1" : "22.5",
"svalue2" : "58",
"svalue3" : "1",
"unit" : 0
}

Re: [90] MQTT Support

Posted: Tuesday 16 August 2016 7:15
by Twinsen
Thank you for the answer.
I recheck the configuration and everything is working now

Re: [90] MQTT Support

Posted: Friday 14 October 2016 11:55
by y1ann1s
Hello
Anyone knows if I can get the list of devices through mqtt?
I am trying to build a home skill for ALexa using IoT
the send commands is pretty easy

The only thing I am missing is to get a list of all devices in MQTT