MQTT on another server

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
bluepi

MQTT on another server

Post by bluepi »

Just started to play around with MQTT which I installed on another Raspberry Pi Server so I could create a series of rules for the outside to DMZ.

I want to now tie this into Domoticz. At the moment I am just using MQTT to track phone locations and update stats on battery and lon/lat

Now how can I get this data into into a dummy switch... At the moment its just formated in the form from the device {_type,:lon:12.345,lat:-54.66,etc,etc,bat:12,etc,etc}

Can I make a json call from the MQTT server to the Domoticz server or should I pass the MQTT and send it out to MQTT on domoticz server and set that up? or can I set domoticz up as a client MQTT and so it pulls the data directly? A bit new to this and how domoticz gets its data if its not running the mqtt service.

I cannot find examples where data is pushed to Domoticz from another MQTT server or similar...Or what the best method is.

Thank you for any help.
kylegordon
Posts: 26
Joined: Thursday 31 October 2013 23:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: MQTT on another server

Post by kylegordon »

MQTT doesn't really make any calls. It's just a messaging system.

What you could use is node-red (provided on the Domoticz SD Card image) and https://github.com/hardillb/node-red-node-geofence to interpret Owntracks MQTT messages. That's what I'm using at the moment to toggle some switch states. When the node-red-node-geofence node emits a msg.location.isat == Home message, then I have node-red emit a msg.payload containing {'idx':1, 'svalue1':1} or similar on the domoticz/in topic.
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
bluepi

Re: MQTT on another server

Post by bluepi »

Thank you for your reply

I have red-node setup and running on another raspberry pi which I can allow domoticz to talk to. I am using Owntracks as a test app at the moment but unsure of how to get domoticz to take advantage of it. Can I pass a MQTT message out from one server to domoticz's MQTT.

All I want is to update a variable or ideally a switch with location values and log positions or last position. I did wonder if a simple method would be to make a JSON call with just the lon/lat... Which is simple(ish) for a variable but I am unsure if this is possible for a switch.

I am not so much after Geofencing more location tracking/logging.
kylegordon
Posts: 26
Joined: Thursday 31 October 2013 23:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: MQTT on another server

Post by kylegordon »

Mosquitto (an MQTT broker/server - I think it's what's provided on the Domoticz SD image) can do a thing called bridging, but I doubt that's what you want. You'd be best configuring your other Domoticz servers to talk to a central Mosquitto broker (maybe on your main Domoticz server), instead of trying to pass messages between multiple MQTT servers.

As for where to send the data... I'm not sure either. From what I can tell Domoticz doesn't have any notion of 'location' or equivalent. For that reason, I configured node-red to simply turn on a virtual switch when. I'm still working on this too, so it may change...

Copy and paste this into node-red as an example...

Code: Select all

[{"id":"66a92c76.9956d4","type":"mqtt-broker","broker":"mqtt.vpn.glasgownet.com","port":"1883","clientid":""},{"id":"fed804b.f0127f8","type":"mqtt in","z":"1b6aed19.e49513","name":"KyleG Owntracks","topic":"mqttitude/galaxys2","broker":"66a92c76.9956d4","x":107,"y":308,"wires":[["620487ca.9dfb78"]]},{"id":"38c9a584.c7365a","type":"mqtt out","z":"1b6aed19.e49513","name":"domoticz/in","topic":"domoticz/in","qos":"","retain":"","broker":"66a92c76.9956d4","x":918,"y":389,"wires":[]},{"id":"a0a89597.5f5768","type":"geofence","z":"1b6aed19.e49513","name":"Home","mode":"circle","inside":"true","rad":88.99011032254676,"points":[],"centre":{"latitude":1.2345,"longitude":-1.2345},"x":458,"y":264,"wires":[["f36d500a.0c92b"]]},{"id":"620487ca.9dfb78","type":"function","z":"1b6aed19.e49513","name":"Lat/Long","func":"msg.location = JSON.parse(msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"x":295,"y":308,"wires":[["a0a89597.5f5768","4b9fb36f.b4604c"]]},{"id":"f36d500a.0c92b","type":"function","z":"1b6aed19.e49513","name":"Location selector","func":"// Home == 10\n// Work == 20\n\nif ( msg.location.isat == \"Home\") {\n    msg.payload = '{\"idx\":183,\"svalue1\":10}';\n}\n\nif ( msg.location.isat == \"Work\") {\n    msg.payload = '{\"idx\":183,\"svalue1\":20}';\n}\n    \n\nreturn msg;","outputs":1,"noerr":0,"x":681,"y":320,"wires":[["38c9a584.c7365a","45e347fe.ba1cb8","61b014f1.9e4fec"]]},{"id":"4b9fb36f.b4604c","type":"geofence","z":"1b6aed19.e49513","name":"Work","mode":"circle","inside":"true","rad":691.5530147043348,"points":[],"centre":{"latitude":4.321,"longitude":-4.321},"x":461,"y":354,"wires":[["f36d500a.0c92b"]]},{"id":"45e347fe.ba1cb8","type":"debug","z":"1b6aed19.e49513","name":"","active":true,"console":"false","complete":"location","x":920,"y":256,"wires":[]},{"id":"61b014f1.9e4fec","type":"debug","z":"1b6aed19.e49513","name":"","active":true,"console":"false","complete":"payload","x":918,"y":309,"wires":[]}]
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
bluepi

Re: MQTT on another server

Post by bluepi »

I guess I will see if Domoticz starts becoming location aware.

For the moment I might just stick with updating a variable for last know location... Thinking about this a little more I can always output from my secure machine to domoticz via https and set it to listen and format the data from there if I need to or it makes it easier to add to more processes coming in. At least if its in a variable I can process within domoticz easily enough for the moment until I see how this project pans out.

Its location tracking and last known location so a bit outside the usual fencing that people are after with location.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: MQTT on another server

Post by Derik »

that Mqtt is hard to get for me...

Please some pictures of the options ...
Is there a option to make this work like geofence with node red...

I do really not understand what MQTT is or what the best options are
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest