I have a setup with a RFLink gateway connected to an esp8266 that sends sensor values over mqtt to my mqtt broker.
The problem is that the mqtt messages sent by the esp8266 is not in correct format for Domoticz.
I have installed node red to have the posibility to change the format of the messages sent by the esp8266.
The problem is that I have no prior programming experience. I'm able to change the topic to domotics/in. When it comes to change the payload of the messages I get stuck.
I'm grateful for help.
original message
{"topic":"rflink/Oregon_TempHygro-128B8","payload":{"TEMP":15.4,"HUM":54,"HSTATUS":0,"BAT":"OK"},"qos":0,"retain":false,"_msgid":"07ef509422ae8d64"}
altered message
{"topic":"domoticz/in","payload":{"TEMP":15.4,"HUM":54,"HSTATUS":0,"BAT":"OK"},"qos":0,"retain":false,"_msgid":"07ef509422ae8d64"}
From what I have read the format is supposed to be like this:
{"command":"udevice", "idx":1234, "svalue":"tm;hu;lv;ba;pr"}
sensor data from RFLink over MQTT to domoticz
Moderator: leecollings
-
- Posts: 13
- Joined: Wednesday 04 January 2017 17:29
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Sweden
- Contact:
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: sensor data from RFLink over MQTT to domoticz
Check this page: https://piandmore.wordpress.com/2018/12 ... t-startup/
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
- FireWizard
- Posts: 1745
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: sensor data from RFLink over MQTT to domoticz
Hello @hasselhoffer
As I do not own such a device ESP6266 with a RFLink Gateway, I have created a simulation with an "Inject" node.
Just for this kind of questions I did create a kind of model, that I recommend to read.
See: viewtopic.php?f=28&t=34300&p=263147&hil ... re#p263147
In this case you receive as data (payload):
There are a Temperature and a Humidity value present. Beside that we have also a Humidity status, which I assume, correspondents with https://www.domoticz.com/wiki/Domoticz_ ... 2Fhumidity
Also we have some info about the Battery (currently OK)
This data may be sent to Domoticz as a value. See:
https://www.domoticz.com/wiki/Domoticz_ ... y_level.29
It is unknown, what the status means at the moment and what will be sent in case the capacity is reduced to, let's say, 50%.
So for the moment I ignore that value. All other data, including the topic, in the received payload may be ignored as well.
As we have only available the temperature, humidity and humidity status and not pressure and prediction, we should use: {"command":"udevice", "idx":1234, "svalue":"tm;hu;lv"} and not {"command":"udevice", "idx":1234, "svalue":"tm;hu;lv;ba;pr"}
For the conversion to Domoticz format, we use a "Function" node, with the following content:
The flow will look as follows:
You can replace the second "Debug" node with a "MQTT Output" node. Configure that node with a topic domoticz/in, so that Domoticz will subscribe to it. Configure also the correct virtual sensor (Temperature + Humidity) and insert the corresponding IDX in the "Function" node.
The complete flow you will find below:
Regards
As I do not own such a device ESP6266 with a RFLink Gateway, I have created a simulation with an "Inject" node.
Just for this kind of questions I did create a kind of model, that I recommend to read.
See: viewtopic.php?f=28&t=34300&p=263147&hil ... re#p263147
In this case you receive as data (payload):
Let us evaluate{"topic":"rflink/Oregon_TempHygro-128B8","payload":{"TEMP":15.4,"HUM":54,"HSTATUS":0,"BAT":"OK"},"qos":0,"retain":false,"_msgid":"07ef509422ae8d64"}
There are a Temperature and a Humidity value present. Beside that we have also a Humidity status, which I assume, correspondents with https://www.domoticz.com/wiki/Domoticz_ ... 2Fhumidity
Also we have some info about the Battery (currently OK)
This data may be sent to Domoticz as a value. See:
https://www.domoticz.com/wiki/Domoticz_ ... y_level.29
It is unknown, what the status means at the moment and what will be sent in case the capacity is reduced to, let's say, 50%.
So for the moment I ignore that value. All other data, including the topic, in the received payload may be ignored as well.
As we have only available the temperature, humidity and humidity status and not pressure and prediction, we should use: {"command":"udevice", "idx":1234, "svalue":"tm;hu;lv"} and not {"command":"udevice", "idx":1234, "svalue":"tm;hu;lv;ba;pr"}
For the conversion to Domoticz format, we use a "Function" node, with the following content:
Code: Select all
msg.payload = {"command":"udevice","idx":1234,"nvalue":0,"svalue":msg.payload.TEMP + ";" + msg.payload.HUM + ";" + msg.payload.HSTATUS}
return msg;
You can replace the second "Debug" node with a "MQTT Output" node. Configure that node with a topic domoticz/in, so that Domoticz will subscribe to it. Configure also the correct virtual sensor (Temperature + Humidity) and insert the corresponding IDX in the "Function" node.
The complete flow you will find below:
Code: Select all
[{"id":"100f0d01a219a15b","type":"tab","label":"Test","disabled":false,"info":"","env":[]},{"id":"a75b5d19e50c5a5b","type":"inject","z":"100f0d01a219a15b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"rflink/Oregon_TempHygro-128B8","payload":"{\"TEMP\":15.4,\"HUM\":54,\"HSTATUS\":0,\"BAT\":\"OK\"}","payloadType":"json","x":850,"y":100,"wires":[["34f5581651d07a45","93273e4a0ac3c47a"]]},{"id":"34f5581651d07a45","type":"debug","z":"100f0d01a219a15b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1010,"y":60,"wires":[]},{"id":"93273e4a0ac3c47a","type":"function","z":"100f0d01a219a15b","name":"","func":"msg.payload = {\"command\":\"udevice\",\"idx\":1234,\"nvalue\":0,\"svalue\":msg.payload.TEMP + \";\" + msg.payload.HUM + \";\" + msg.payload.HSTATUS}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":100,"wires":[["8251db9ca3888d22"]]},{"id":"8251db9ca3888d22","type":"debug","z":"100f0d01a219a15b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1210,"y":100,"wires":[]}]
-
- Posts: 13
- Joined: Wednesday 04 January 2017 17:29
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Sweden
- Contact:
Re: sensor data from RFLink over MQTT to domoticz
Hi @FireWizard
I'm very grateful for all the help I get!
I have now tested the flow you created for me.
when I use the inject node you created my virtual sensor is updated in domoticz. When i hook up the flow with mqtt data in I seem to get som kind of error after data has passed through the function node. when I compare inject node with mqtt in they seem to differ a bit To be able to understand what you actually do in the function node,is learning javascript the way to go?
regards
Markus
I'm very grateful for all the help I get!
I have now tested the flow you created for me.
when I use the inject node you created my virtual sensor is updated in domoticz. When i hook up the flow with mqtt data in I seem to get som kind of error after data has passed through the function node. when I compare inject node with mqtt in they seem to differ a bit To be able to understand what you actually do in the function node,is learning javascript the way to go?
regards
Markus
- FireWizard
- Posts: 1745
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: sensor data from RFLink over MQTT to domoticz
Hello @hasselhoffer,
I'm really sorry, that I did not mention the configuration of the MQTT Input node.
Can you change the Output in the Configuration of the MQTT input node to "a parsed JSON object", instead of "auto-detect (string or buffer)" as follows:
You asked also:
See: https://www.youtube.com/channel/UCQaB8N ... A/featured
There are many more videos available, explaining a lot. (See the video tab in the link)
What I did in the "Function" node was not very fancy. I simple inserted the path of the different values TEMP, HUM and HStatus in the required payload for Domoticz ({"command":"udevice", "idx":1234, "svalue":"tm;hu;lv"}) You can find that path, without msg, when you hoover with your mouse over the element.
See: https://nodered.org/docs/user-guide/messages
Regards
I'm really sorry, that I did not mention the configuration of the MQTT Input node.
Can you change the Output in the Configuration of the MQTT input node to "a parsed JSON object", instead of "auto-detect (string or buffer)" as follows:
You asked also:
Of course knowing javascript is always an advantage, but as I should give a recommendation, I suggest you watch the movies, created by the developers of Node RED. This will costs you about 1 hour of your time, but you will learn so much.To be able to understand what you actually do in the function node,is learning javascript the way to go?
See: https://www.youtube.com/channel/UCQaB8N ... A/featured
There are many more videos available, explaining a lot. (See the video tab in the link)
What I did in the "Function" node was not very fancy. I simple inserted the path of the different values TEMP, HUM and HStatus in the required payload for Domoticz ({"command":"udevice", "idx":1234, "svalue":"tm;hu;lv"}) You can find that path, without msg, when you hoover with your mouse over the element.
See: https://nodered.org/docs/user-guide/messages
Regards
-
- Posts: 13
- Joined: Wednesday 04 January 2017 17:29
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Sweden
- Contact:
Re: sensor data from RFLink over MQTT to domoticz
Hi @FireWizard
Many thanks.
It works like a charm now, and I'm checking out both the user guide and the videos.
I think it is well spent time.
Regards
Markus
Many thanks.
It works like a charm now, and I'm checking out both the user guide and the videos.
I think it is well spent time.
Regards
Markus
Who is online
Users browsing this forum: No registered users and 1 guest