Get sensor values with MQTT into Domoticz [Solved]
Moderator: leecollings
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hi @Stiv32
OK, you answered a small part of the question.
1. Have you installed Node Red?
2. Which of the values do you want to use in Domoticz or all?
3. What are the values for pvstatus? (Solar inverter state) Is it a boolean (only 0 or 1)?
4. What are pv1watt and pv2watt? Expressed in W. Does it need a divider??
Same question for pvpowerin (Solar inverter input power) and pvpowerout (Solar inverter output power)
Probably all expressed in W. Does it need a divider?
5. pvfrequentie is in Hz (divided by 100)
6. pvgridvoltage, expressed in V (divided by 10)
7. pvenergytoday (Solar inverter total energy today) in kWh. Does it need a divider?
8. pvenergytotal (Solar inverter total energy) in kWh. Does it need a divider?
9. pv1voltage and pv2voltage in V (divided by 10)
10 pv1current and pv2current in A. Does it need a divider?
11. pvtemperature in degrees Celsius (divided by 10) Is this the outdoor (solar panel) temperature
12, pvipmtemerature in degrees Celsius (divided by 10) Is this the inverter temperature? It looks indoor
If you can answer this, I can support you.
Regards
OK, you answered a small part of the question.
1. Have you installed Node Red?
2. Which of the values do you want to use in Domoticz or all?
3. What are the values for pvstatus? (Solar inverter state) Is it a boolean (only 0 or 1)?
4. What are pv1watt and pv2watt? Expressed in W. Does it need a divider??
Same question for pvpowerin (Solar inverter input power) and pvpowerout (Solar inverter output power)
Probably all expressed in W. Does it need a divider?
5. pvfrequentie is in Hz (divided by 100)
6. pvgridvoltage, expressed in V (divided by 10)
7. pvenergytoday (Solar inverter total energy today) in kWh. Does it need a divider?
8. pvenergytotal (Solar inverter total energy) in kWh. Does it need a divider?
9. pv1voltage and pv2voltage in V (divided by 10)
10 pv1current and pv2current in A. Does it need a divider?
11. pvtemperature in degrees Celsius (divided by 10) Is this the outdoor (solar panel) temperature
12, pvipmtemerature in degrees Celsius (divided by 10) Is this the inverter temperature? It looks indoor
If you can answer this, I can support you.
Regards
-
- Posts: 10
- Joined: Sunday 08 September 2019 7:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
1. Have you installed Node Red?
Yes
2. Which of the values do you want to use in Domoticz or all?
Not all - pvenergytoday(divide by 10),pvgridvoltage(divide by 10),
3. What are the values for pvstatus? (Solar inverter state) Is it a boolean (only 0 or 1)?
yes - only 0 ant 1 (on/off)
4. What are pv1watt and pv2watt? Expressed in W. Does it need a divider??
the power of pv strings - divide by 10
Same question for pvpowerin (Solar inverter input power) and pvpowerout (Solar inverter output power)
Probably all expressed in W. Does it need a divider?
- yes by 10 - only pvpowerout
5. pvfrequentie is in Hz (divided by 100)
yes
6. pvgridvoltage, expressed in V (divided by 10)
yes
7. pvenergytoday (Solar inverter total energy today) in kWh. Does it need a divider?
yes - need by 10
8. pvenergytotal (Solar inverter total energy) in kWh. Does it need a divider?
yes by 10
9. pv1voltage and pv2voltage in V (divided by 10)
yes
10 pv1current and pv2current in A. Does it need a divider?
yes - need - by 10
11. pvtemperature in degrees Celsius (divided by 10) Is this the outdoor (solar panel) temperature
inverter temp - need divide by 10
12, pvipmtemerature in degrees Celsius (divided by 10) Is this the inverter temperature? It looks indoor
not needed - internal circut temp.
Yes
2. Which of the values do you want to use in Domoticz or all?
Not all - pvenergytoday(divide by 10),pvgridvoltage(divide by 10),
3. What are the values for pvstatus? (Solar inverter state) Is it a boolean (only 0 or 1)?
yes - only 0 ant 1 (on/off)
4. What are pv1watt and pv2watt? Expressed in W. Does it need a divider??
the power of pv strings - divide by 10
Same question for pvpowerin (Solar inverter input power) and pvpowerout (Solar inverter output power)
Probably all expressed in W. Does it need a divider?
- yes by 10 - only pvpowerout
5. pvfrequentie is in Hz (divided by 100)
yes
6. pvgridvoltage, expressed in V (divided by 10)
yes
7. pvenergytoday (Solar inverter total energy today) in kWh. Does it need a divider?
yes - need by 10
8. pvenergytotal (Solar inverter total energy) in kWh. Does it need a divider?
yes by 10
9. pv1voltage and pv2voltage in V (divided by 10)
yes
10 pv1current and pv2current in A. Does it need a divider?
yes - need - by 10
11. pvtemperature in degrees Celsius (divided by 10) Is this the outdoor (solar panel) temperature
inverter temp - need divide by 10
12, pvipmtemerature in degrees Celsius (divided by 10) Is this the inverter temperature? It looks indoor
not needed - internal circut temp.
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello @Stiv32
Thank you for the link, this one is very useful.
As you have already Node Red installed and up and running, I ask you to go to the worksheet (http://IP address:1880) and drag and drop a MQTT input node on the worksheet. Do the same with a "Debug" node and connect these two nodes together.
Configure the "MQTT In " node as follows:
If you have installed the MQTT broker (Mosquitto) on the same device as Node Red you can configure the MQTT node as follows:
For the server, you may insert your local IP address, localhost or 127.0.0.1. The port, you should leave, as default, 1883.
If you have not secured your MQTT broker, with a user name and password, you can leave all other settings as default, otherwise you should fill in your username/password under the "Security" tab.
You can give the server a name, in this case I called it 'localhost'.
The topic should be energy/growatt. Do not use a leading forward slash before 'energy'.
QoS, you can leave for the moment to 0
The output should be 'a parsed JSON object' and the name is up to you.
If you go to the "Debug"pane (CTRL-g d), you should see the same (except the values) as shown in the picture of my post October 13, 19:52h.
Can you confirm this?
Regards
Thank you for the link, this one is very useful.
As you have already Node Red installed and up and running, I ask you to go to the worksheet (http://IP address:1880) and drag and drop a MQTT input node on the worksheet. Do the same with a "Debug" node and connect these two nodes together.
Configure the "MQTT In " node as follows:
If you have installed the MQTT broker (Mosquitto) on the same device as Node Red you can configure the MQTT node as follows:
For the server, you may insert your local IP address, localhost or 127.0.0.1. The port, you should leave, as default, 1883.
If you have not secured your MQTT broker, with a user name and password, you can leave all other settings as default, otherwise you should fill in your username/password under the "Security" tab.
You can give the server a name, in this case I called it 'localhost'.
The topic should be energy/growatt. Do not use a leading forward slash before 'energy'.
QoS, you can leave for the moment to 0
The output should be 'a parsed JSON object' and the name is up to you.
If you go to the "Debug"pane (CTRL-g d), you should see the same (except the values) as shown in the picture of my post October 13, 19:52h.
Can you confirm this?
Regards
-
- Posts: 10
- Joined: Sunday 08 September 2019 7:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Yes - i try write funcion:
var msg1 ={};
var msg2 ={};
var msg3 ={};
var msg4 ={};
var msg5 ={};
var msg6 ={};
var msg7 ={};
var msg8 ={};
var msg9 ={};
var msg10 ={};
var msg11 ={};
var msg12 ={};
var msg13 ={};
var msg14 ={};
var msg15 ={};
msg1.payload = {"command":"udevice","idx":1004,"nvalue":0,"svalue": msg.payload.pvstatus};
msg2.payload = {"command":"udevice","idx":1005,"nvalue":0,"svalue": msg.payload.pv1watt};
msg3.payload = {"command":"udevice","idx":1006,"nvalue":0,"svalue": msg.payload.pv2watt};
msg4.payload = {"command":"udevice","idx":1004,"nvalue":0,"svalue": msg.payload.pvpowerin};
msg5.payload = {"command":"udevice","idx":1005,"nvalue":0,"svalue": msg.payload.pvpowerout};
msg6.payload = {"command":"udevice","idx":1006,"nvalue":0,"svalue": msg.payload.pvfrequentie};
msg7.payload = {"command":"udevice","idx":1007,"nvalue":0,"svalue": msg.payload.pvgridvoltage};
msg8.payload = {"command":"udevice","idx":1008,"nvalue":0,"svalue": msg.payload.pvenergytoday};
msg9.payload = {"command":"udevice","idx":1009,"nvalue":0,"svalue": msg.payload.pvenergytotal};
msg10.payload = {"command":"udevice","idx":1010,"nvalue":0,"svalue": msg.payload.pv1voltage};
msg11.payload = {"command":"udevice","idx":1011,"nvalue":0,"svalue": msg.payload.pv2voltage};
msg12.payload = {"command":"udevice","idx":1012,"nvalue":0,"svalue": msg.payload.pv1current};
msg13.payload = {"command":"udevice","idx":1013,"nvalue":0,"svalue": msg.payload.pv2current};
msg14.payload = {"command":"udevice","idx":1014,"nvalue":0,"svalue": msg.payload.pvtemperature};
msg15.payload = {"command":"udevice","idx":1014,"nvalue":0,"svalue": msg.payload.pvipmtemperature};
return [[msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,msg10,msg11,msg12,msg13,msg14,msg15]];
-
- Posts: 10
- Joined: Sunday 08 September 2019 7:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Domoticz idx numbers are only for testing
Here output debug - no values
Here output debug - no values
Node-RED
Deploy
14.10.2020, 15:36:10node: 84a689fc.d03c7energy/growatt : msg.payload : Object
{ device: "6FZI9080D7", time: "2020-10-14T15:36:06", buffered: "no", values: object }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1004, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1005, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1006, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1004, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1005, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1006, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1007, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1008, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1009, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1010, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1011, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1012, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5
msg.payload : Object
{ command: "udevice", idx: 1013, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1014, nvalue: 0 }
14.10.2020, 15:36:10node: a113198c.ab3a5msg.payload : Object
{ command: "udevice", idx: 1014, nvalue: 0 }
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hi @Stiv32,,
Hi, you are on track, but not completely there.
I suggest, you create the following virtual hardware: Dummy (does nothing, use for virtual switches only) and create 15 virtual sensors under it as follows:
Give the sensors the name you like and note down their IDX numbers. You will need that later.
1. For pvstatus: 1 "Alert" Sensor
2. For pv1watt, pv2watt, pvpowerin and pvpowerout: 4 "Usage" Sensors
3. For pvfrequentie: "Custom" Sensor (on the x-axis fill in Hz).
4. For pvgridvoltage, pv1voltage and pv2voltage: 3 "Voltage" Sensors
5. For pvenergytoday and pvenergytotal: 2 "Custom" Sensors (on the x-axis fill in kWh).
6. For pv1current and pv2current: 2 "Ampere" Sensors
7. For pvtemperature and pvipmtemperature: 2 "Temperature" Sensors.
That makes 15 virtual Sensors. You can omit the ones, you don't want to use.
This will be the flow.
You will have to replace the IDX numbers 1001 - 1015 for the IDX numbers, you wrote down, when created the virtual sensors.
The flow is included below:
Any sensor, you do not want to use, you can comment out the corresponding message (2 places) and omit it from the return.
Actually the only thing that caused that no result has been presented was the path to the data.
You used msg.payload.pvstatus and that should be msg.payload.values.pv1watt, etc.
Looking forward for the result
Regards
Hi, you are on track, but not completely there.
I suggest, you create the following virtual hardware: Dummy (does nothing, use for virtual switches only) and create 15 virtual sensors under it as follows:
Give the sensors the name you like and note down their IDX numbers. You will need that later.
1. For pvstatus: 1 "Alert" Sensor
2. For pv1watt, pv2watt, pvpowerin and pvpowerout: 4 "Usage" Sensors
3. For pvfrequentie: "Custom" Sensor (on the x-axis fill in Hz).
4. For pvgridvoltage, pv1voltage and pv2voltage: 3 "Voltage" Sensors
5. For pvenergytoday and pvenergytotal: 2 "Custom" Sensors (on the x-axis fill in kWh).
6. For pv1current and pv2current: 2 "Ampere" Sensors
7. For pvtemperature and pvipmtemperature: 2 "Temperature" Sensors.
That makes 15 virtual Sensors. You can omit the ones, you don't want to use.
This will be the flow.
You will have to replace the IDX numbers 1001 - 1015 for the IDX numbers, you wrote down, when created the virtual sensors.
The flow is included below:
Code: Select all
[{"id":"1f6fae81.f09fe1","type":"debug","z":"79ac4ad4.26563c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":370,"y":220,"wires":[]},{"id":"a0aec7c7.7eb038","type":"mqtt in","z":"79ac4ad4.26563c","name":"MQTT In","topic":"energy/growatt","qos":"0","datatype":"json","broker":"f9f13036.e28b58","x":180,"y":280,"wires":[["1f6fae81.f09fe1","4f7c10a1.d16a5"]]},{"id":"4f7c10a1.d16a5","type":"function","z":"79ac4ad4.26563c","name":"","func":"var msg1 = {}; // pvstatus, Inverter run state\nvar msg2 = {}; // pv1watt, PV1 input watt (0.1W)\nvar msg3 = {}; // pv2watt, PV2 input watt (0.1W)\nvar msg4 = {}; // pvpowerin, Actual input power (0.1W)\nvar msg5 = {}; // pvpowerout, Actual output power (0.1W)\nvar msg6 = {}; // pvfrequentie, Grid frequency (0.01Hz)\nvar msg7 = {}; // pvgridvoltage, Three/single phase grid voltage (0.1V)\nvar msg8 = {}; // pvenergytoday, Today generated energy (0.1KWH)\nvar msg9 = {}; // pvenergytotal, Total generated energy (0.1KWH)\nvar msg10 = {}; // pv1voltage, PV1 voltage (0.1V)\nvar msg11 = {}; // pv2voltage, PV2 voltage (0.1V)\nvar msg12 = {}; // pv1current, PV1 input current (0.1A)\nvar msg13 = {}; // pv2current, PV2 input current (0.1A)\nvar msg14 = {}; // pvtemperature, Inverter temperature (0.1C)\nvar msg15 = {}; // pvipmtemperature, The inside IPM in inverter temperature (0.1C), be aware not available in all inverters!\n\nswitch (msg.payload.values.pvstatus) {\n case 0 :\n msg1.payload = {\"command\":\"udevice\",\"idx\":1001,\"nvalue\":0,\"svalue\": \"Waiting\"};\n break\n\n case 1 :\n msg1.payload = {\"command\":\"udevice\",\"idx\":1001,\"nvalue\":1,\"svalue\": \"Normal\"};\n break\n\n case 2 :\n msg1.payload = {\"command\":\"udevice\",\"idx\":1001,\"nvalue\":2,\"svalue\": \"Fault\"};\n break\n}\n\nmsg2.payload = {\"command\":\"udevice\",\"idx\":1002,\"nvalue\":0,\"svalue\":((msg.payload.values.pv1watt) / 10).toString()};\nmsg3.payload = {\"command\":\"udevice\",\"idx\":1003,\"nvalue\":0,\"svalue\":((msg.payload.values.pv2watt) / 10).toString()};\nmsg4.payload = {\"command\":\"udevice\",\"idx\":1004,\"nvalue\":0,\"svalue\":((msg.payload.values.pvpowerin) / 10).toString()};\nmsg5.payload = {\"command\":\"udevice\",\"idx\":1005,\"nvalue\":0,\"svalue\":((msg.payload.values.pvpowerout) / 10).toString()};\nmsg6.payload = {\"command\":\"udevice\",\"idx\":1006,\"nvalue\":0,\"svalue\":((msg.payload.values.pvfrequentie) / 100).toString()};\nmsg7.payload = {\"command\":\"udevice\",\"idx\":1007,\"nvalue\":0,\"svalue\":((msg.payload.values.pvgridvoltage) / 10).toString()};\nmsg8.payload = {\"command\":\"udevice\",\"idx\":1008,\"nvalue\":0,\"svalue\":((msg.payload.values.pvenergytoday) / 10).toString()};\nmsg9.payload = {\"command\":\"udevice\",\"idx\":1009,\"nvalue\":0,\"svalue\":((msg.payload.values.pvenergytotal) / 10).toString()};\nmsg10.payload = {\"command\":\"udevice\",\"idx\":1010,\"nvalue\":0,\"svalue\":((msg.payload.values.pv1voltage) / 10).toString()};\nmsg11.payload = {\"command\":\"udevice\",\"idx\":1011,\"nvalue\":0,\"svalue\":((msg.payload.values.pv2voltage) / 10).toString()};\nmsg12.payload = {\"command\":\"udevice\",\"idx\":1012,\"nvalue\":0,\"svalue\":((msg.payload.values.pv1current) / 10).toString()};\nmsg13.payload = {\"command\":\"udevice\",\"idx\":1013,\"nvalue\":0,\"svalue\":((msg.payload.values.pv2current) / 10).toString()};\nmsg14.payload = {\"command\":\"udevice\",\"idx\":1014,\"nvalue\":0,\"svalue\":((msg.payload.values.pvtemperature) / 10).toString()};\nmsg15.payload = {\"command\":\"udevice\",\"idx\":1015,\"nvalue\":0,\"svalue\":((msg.payload.values.pvipmtemperature) / 10).toString()};\n\nreturn [[msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,msg10,msg11,msg12,msg13,msg14,msg15]];\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":280,"wires":[["b2f06144.0b9f5","440bf20b.c27ab4"]]},{"id":"b2f06144.0b9f5","type":"debug","z":"79ac4ad4.26563c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":340,"wires":[]},{"id":"440bf20b.c27ab4","type":"mqtt out","z":"79ac4ad4.26563c","name":"MQTT to Domoticz","topic":"domoticz/in","qos":"0","retain":"","broker":"f9f13036.e28b58","x":570,"y":280,"wires":[]},{"id":"f9f13036.e28b58","type":"mqtt-broker","z":"","name":"localhost","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Any sensor, you do not want to use, you can comment out the corresponding message (2 places) and omit it from the return.
Actually the only thing that caused that no result has been presented was the path to the data.
You used msg.payload.pvstatus and that should be msg.payload.values.pv1watt, etc.
Looking forward for the result
Regards
-
- Posts: 10
- Joined: Sunday 08 September 2019 7:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Thank you very much, one question, is it possible to use the pvpowerout and pvenergytoday values in one counter - Electic (instant + counter).
Today I have to complete the test (inverter finished work) - but everything looks very good already and many thanks in advance for your help
Today I have to complete the test (inverter finished work) - but everything looks very good already and many thanks in advance for your help
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hi, @Stiv32,
You asked:
Yes, that is possible.
You can find the following at: https://piandmore.wordpress.com/2019/02 ... -domoticz/
Electric
The electric sensor will show the current usage of electricity in Watt and the cumulative usage in kWh. You can add digits after the decimal if needed.
{"command":"udevice", "idx":1234, "svalue":"us;cu"}
where us is usage in Watt and cu is cumulative usage in Wh (even though it is displayed in kWh)
To do so: Create a virtual Sensor of type Electric (Instant + Counter)
Do the configuration as below:
To send the data to Domoticz, you have to change the command to:
You can replace two of the lines by this one, e.g comment out msg5 and msg8. Remove these two from the "return" line.
Declare a new msg, e.g. msg16 and add the line below. Add it also in the "return" line.
Regards
You asked:
is it possible to use the pvpowerout and pvenergytoday values in one counter - Electic (instant + counter).
Yes, that is possible.
You can find the following at: https://piandmore.wordpress.com/2019/02 ... -domoticz/
Electric
The electric sensor will show the current usage of electricity in Watt and the cumulative usage in kWh. You can add digits after the decimal if needed.
{"command":"udevice", "idx":1234, "svalue":"us;cu"}
where us is usage in Watt and cu is cumulative usage in Wh (even though it is displayed in kWh)
To do so: Create a virtual Sensor of type Electric (Instant + Counter)
Do the configuration as below:
To send the data to Domoticz, you have to change the command to:
Code: Select all
msg16.payload = {"command":"udevice","idx":13,"nvalue":0,"svalue":((msg.payload.values.pvpowerout) / 10).toString() + ";" + ((msg.payload.values.pvenergytoday) * 100).toString()};
return msg16
Declare a new msg, e.g. msg16 and add the line below. Add it also in the "return" line.
Regards
Last edited by FireWizard on Thursday 15 October 2020 21:04, edited 1 time in total.
-
- Posts: 10
- Joined: Sunday 08 September 2019 7:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello, one more big thank you to FireWizard - with his great help, we managed to run a thorough monitoring of the PV Growatt Inverter - all possible parameters. Software used: https://github.com/johanmeijer/grott and the above translation to Domoticz by Node Red

- Attachments
-
- Growatt.PNG (161.85 KiB) Viewed 4549 times
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hi, @Stiv
That looks good. The only thing is that you have several sensors with a red bar.
This is caused by a sensor time-out.You can solve that by increasing this time-out.
Go to: Setup > Settings > Other > Sensor Timeout
E.g for 1 day ( = 24h) you have to insert 24 x 60 (minutes) = 1440
Regards
That looks good. The only thing is that you have several sensors with a red bar.
This is caused by a sensor time-out.You can solve that by increasing this time-out.
Go to: Setup > Settings > Other > Sensor Timeout
E.g for 1 day ( = 24h) you have to insert 24 x 60 (minutes) = 1440
Regards
-
- Posts: 10
- Joined: Sunday 08 September 2019 7:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
After changing the timeout it looks better, thanks again.
-
- Posts: 3
- Joined: Sunday 10 September 2017 15:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Nice! Well done.
Is it oke when I link to this topic from my Grott Github pages (wiki)?
Regards,
Johan
Is it oke when I link to this topic from my Grott Github pages (wiki)?
Regards,
Johan
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hi @johanm,
I don't think, that there is any legal objection to link to this topic.
However, this topic started with a post of @McMellow about the iSpindle, followed by requests for a Wiki, and ended with the Growatt inverter..
For clearity you should mention that.
But I suggest you contact the board administrator about this.
Regards
I don't think, that there is any legal objection to link to this topic.
However, this topic started with a post of @McMellow about the iSpindle, followed by requests for a Wiki, and ended with the Growatt inverter..
For clearity you should mention that.
But I suggest you contact the board administrator about this.
Regards
-
- Posts: 68
- Joined: Wednesday 03 February 2016 19:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
I don't wanna steal the topic but i have a simular issue.
I have an ESP32 with OPENMQQTgateway with read out the xiaomi flower sensor with bluetooth.
topic mqtt in: home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/C47C8D66476D
With debug i get:
{"id":"C4:7C:8D:66:47:6D","name":"Flower care","rssi":-87,"distance":18.07764,"model":"HHCCJCY01HHCC","moi":40}
moi is the moisture level i need
sometimes i get more info, {"id":"C4:7C:8D:66:47:6D","name":"Flower care","rssi":-91,"distance":25.51913,"model":"HHCCJCY01HHCC","tem":20.3,"tempc":20.3,"tempf":68.54}
With the function:
var msg1 ={};
var msg2 ={};
msg1.payload = {"command":"udevice","idx":230,"nvalue":0,"svalue": msg.payload.moi};
msg2.payload = {"command":"udevice","idx":229,"nvalue":0,"svalue": msg.payload.tempc};
return [[msg1,msg2]];
i get the folowing debug from nodered:
{"command":"udevice","idx":229,"nvalue":0,"svalue":20.4}
and sometimes:
{"command":"udevice","idx":230,"nvalue":0,"svalue":40}
i made a dummy hardware and tried temperature/percentage/custom sensor but the sensors don't get updated.
Domoticz log:
2020-10-25 15:45:58.054 Error: MQTT: unknown idx received! (idx 0)
2020-10-25 15:47:03.797 Error: MQTT: Invalid data received!
2020-10-25 15:51:29.060 Error: MQTT: Invalid data received!
2020-10-25 15:52:40.796 Error: MQTT: Invalid data received!
2020-10-25 15:53:44.105 Error: MQTT: Invalid data received!
2020-10-25 15:54:49.966 Error: MQTT: Invalid data received!
2020-10-25 15:55:50.062 Error: MQTT: Invalid data received!
i looked at https://piandmore.wordpress.com/2019/02 ... -domoticz/ but my knowdledge i too low.
I can see that when no sensor value is detected it sends, nvalue:0, so its updated to 0, its just not updating svalue
Can someone explain how to get the sensor values in domoticz?
THanks!!!
I have an ESP32 with OPENMQQTgateway with read out the xiaomi flower sensor with bluetooth.
topic mqtt in: home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/C47C8D66476D
With debug i get:
{"id":"C4:7C:8D:66:47:6D","name":"Flower care","rssi":-87,"distance":18.07764,"model":"HHCCJCY01HHCC","moi":40}
moi is the moisture level i need
sometimes i get more info, {"id":"C4:7C:8D:66:47:6D","name":"Flower care","rssi":-91,"distance":25.51913,"model":"HHCCJCY01HHCC","tem":20.3,"tempc":20.3,"tempf":68.54}
With the function:
var msg1 ={};
var msg2 ={};
msg1.payload = {"command":"udevice","idx":230,"nvalue":0,"svalue": msg.payload.moi};
msg2.payload = {"command":"udevice","idx":229,"nvalue":0,"svalue": msg.payload.tempc};
return [[msg1,msg2]];
i get the folowing debug from nodered:
{"command":"udevice","idx":229,"nvalue":0,"svalue":20.4}
and sometimes:
{"command":"udevice","idx":230,"nvalue":0,"svalue":40}
i made a dummy hardware and tried temperature/percentage/custom sensor but the sensors don't get updated.
Domoticz log:
2020-10-25 15:45:58.054 Error: MQTT: unknown idx received! (idx 0)
2020-10-25 15:47:03.797 Error: MQTT: Invalid data received!
2020-10-25 15:51:29.060 Error: MQTT: Invalid data received!
2020-10-25 15:52:40.796 Error: MQTT: Invalid data received!
2020-10-25 15:53:44.105 Error: MQTT: Invalid data received!
2020-10-25 15:54:49.966 Error: MQTT: Invalid data received!
2020-10-25 15:55:50.062 Error: MQTT: Invalid data received!
i looked at https://piandmore.wordpress.com/2019/02 ... -domoticz/ but my knowdledge i too low.
I can see that when no sensor value is detected it sends, nvalue:0, so its updated to 0, its just not updating svalue
Can someone explain how to get the sensor values in domoticz?
THanks!!!
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello,@joostnl
I see 2 issues in your application.
1,
You said:
This is indicated in the upper picture.
Sometimes (but not always!!!!) you get more info. You get extra temperature information.
The temperature, temperature in Celsius (is the same as temperature) and the temperature in Fahrenheit.
This is reflected in the lower picture.
As you can see the "moi" and the "tem" are in different messages. So, if you want to send these to Domoticz in a single message, you will have to merge these first. That is complicated, because the first message has to wait on the second. When will the second arrive?
So the best solution is not to merge and to send the messages independent.
2
Both temperature, percentage and also the custom sensor require a format, like {"command":"udevice", "idx":1234, "svalue":"3.45"}.
See: https://piandmore.wordpress.com/tag/domoticz/
As you also can see, the value after "svalue" : is between " " ("3.45"), which means that it is a string.
Remember that all values after svalue should be strings, like all values after nvalue should be numerical values.
In the upper picture you see the value as a numerical value (blue, without " ") and the lower picture you see it as a string value ( red, with " ").
So, in order to create a message, that Domoticz understands, you have to convert the number to a string.
The function to do this is toString().
So the message in the function node will become:
and similar:
As the above is for a single solution, we have to solve also issue one.
Have a look to the flow below:
The two Inject nodes act as your input from the Plant sensor via MQTT.
Only payloads with "moi" and "temp" will pass to the output, with the correct IDX. Everything else is blocked.
Play with it and implement it.
Regards
I see 2 issues in your application.
1,
You said:
The first stream gives you the "moi" (moisture level).With debug i get:
{"id":"C4:7C:8D:66:47:6D","name":"Flower care","rssi":-87,"distance":18.07764,"model":"HHCCJCY01HHCC","moi":40}
moi is the moisture level i need
sometimes i get more info, {"id":"C4:7C:8D:66:47:6D","name":"Flower care","rssi":-91,"distance":25.51913,"model":"HHCCJCY01HHCC","tem":20.3,"tempc":20.3,"tempf":68.54}
This is indicated in the upper picture.
Sometimes (but not always!!!!) you get more info. You get extra temperature information.
The temperature, temperature in Celsius (is the same as temperature) and the temperature in Fahrenheit.
This is reflected in the lower picture.
As you can see the "moi" and the "tem" are in different messages. So, if you want to send these to Domoticz in a single message, you will have to merge these first. That is complicated, because the first message has to wait on the second. When will the second arrive?
So the best solution is not to merge and to send the messages independent.
2
Both temperature, percentage and also the custom sensor require a format, like {"command":"udevice", "idx":1234, "svalue":"3.45"}.
See: https://piandmore.wordpress.com/tag/domoticz/
As you also can see, the value after "svalue" : is between " " ("3.45"), which means that it is a string.
Remember that all values after svalue should be strings, like all values after nvalue should be numerical values.
In the upper picture you see the value as a numerical value (blue, without " ") and the lower picture you see it as a string value ( red, with " ").
So, in order to create a message, that Domoticz understands, you have to convert the number to a string.
The function to do this is toString().
So the message in the function node will become:
Code: Select all
msg.payload = {"command":"udevice","idx":229,"nvalue":0,"svalue": msg.payload.tempc.toString()};
return msg;
Code: Select all
msg.payload = {"command":"udevice","idx":230,"nvalue":0,"svalue": msg.payload.moi.toString()};
return msg;
Have a look to the flow below:
The two Inject nodes act as your input from the Plant sensor via MQTT.
Only payloads with "moi" and "temp" will pass to the output, with the correct IDX. Everything else is blocked.
Code: Select all
[{"id":"80f399dc.fc0558","type":"tab","label":"Test","disabled":false,"info":""},{"id":"bb960a7a.6f0308","type":"inject","z":"80f399dc.fc0558","name":"Inject Temperature","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" {\"id\":\"C4:7C:8D:66:47:6D\",\"name\":\"Flower care\",\"rssi\":-91,\"distance\":25.51913,\"model\":\"HHCCJCY01HHCC\",\"tem\":20.3,\"tempc\":20.3,\"tempf\":68.54}","payloadType":"json","x":170,"y":160,"wires":[["baec393.44fb8c8"]]},{"id":"b89c69be.dd2cb8","type":"inject","z":"80f399dc.fc0558","name":"Inject Moi","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" {\"id\":\"C4:7C:8D:66:47:6D\",\"name\":\"Flower care\",\"rssi\":-87,\"distance\":18.07764,\"model\":\"HHCCJCY01HHCC\",\"moi\":40}","payloadType":"json","x":140,"y":240,"wires":[["baec393.44fb8c8"]]},{"id":"3f5e8c5b.a61d5c","type":"debug","z":"80f399dc.fc0558","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":220,"wires":[]},{"id":"baec393.44fb8c8","type":"function","z":"80f399dc.fc0558","name":"","func":"if (msg.payload.hasOwnProperty(\"moi\")){\n msg.payload = {\"command\":\"udevice\",\"idx\":230,\"nvalue\":0,\"svalue\": msg.payload.moi.toString()};\n return msg;\n} else if (msg.payload.hasOwnProperty(\"tem\")){\n msg.payload = {\"command\":\"udevice\",\"idx\":229,\"nvalue\":0,\"svalue\": msg.payload.tempc.toString()};\n return msg;\n} else {\n return;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":220,"wires":[["3f5e8c5b.a61d5c"]]}]
Regards
-
- Posts: 68
- Joined: Wednesday 03 February 2016 19:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
@Firewizard Your help is appreciated!
Your flow works great the domoticz sensors are being updated.
I finalized it, the injectors are only for test purpose (im new
)

I expanded your function:
tem = temperature
moi = moisture
lux = lux
fer = fertility
Final function:
Thank you!
Your flow works great the domoticz sensors are being updated.
I finalized it, the injectors are only for test purpose (im new


I expanded your function:
tem = temperature
moi = moisture
lux = lux

fer = fertility
Final function:
Code: Select all
if (msg.payload.hasOwnProperty("moi")){
msg.payload = {"command":"udevice","idx":44,"nvalue":0,"svalue": msg.payload.moi.toString()};
return msg;
} else if (msg.payload.hasOwnProperty("tem")){
msg.payload = {"command":"udevice","idx":45,"nvalue":0,"svalue": msg.payload.tempc.toString()};
return msg;
} else if (msg.payload.hasOwnProperty("lux")){
msg.payload = {"command":"udevice","idx":46,"nvalue":0,"svalue": msg.payload.lux.toString()};
return msg;
} else if (msg.payload.hasOwnProperty("fer")){
msg.payload = {"command":"udevice","idx":47,"nvalue":0,"svalue": msg.payload.fer.toString()};
return msg;
} else {
return;
}
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hi @joostnl
You wrote:
If you want, you can also remove the (green) Debug nodes.
I let them in, in order to show you the different results.
Regards
You wrote:
Indeed, they injected the same JSON object as you receive by MQTT.I finalized it, the injectors are only for test purpose (im new)
If you want, you can also remove the (green) Debug nodes.
I let them in, in order to show you the different results.
Regards
-
- Posts: 6
- Joined: Thursday 12 November 2020 12:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Slovenija
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello to all.
I also have a problem that I can't solve because I don't know much about Node Red. So I ask you for help.
I have a Solar weather station https://github.com/3KUdelta/Solar_WiFi_Weather_Station
Every 10 minutes a MQTT message is send to the MQTT-broker.
With MQTT-Explorer, I can see the messages on the MQTT-broker.
In Node Red MQTT input node I get the following values:
How can I get these values into Domoticz Virtual Sensor Type: »temp+hum+baro«
{"command":"udevice", "idx":121, "svalue":"10.1;63;1;1027;2"}
{"command":"udevice", "idx":121, "svalue":"tm;hu;lv;ba;pr"}
where tm is the temperature, hu is the humidity and lv is the environment level, ba is the pressure and pr is the prediction.
Regards
Roman
I also have a problem that I can't solve because I don't know much about Node Red. So I ask you for help.
I have a Solar weather station https://github.com/3KUdelta/Solar_WiFi_Weather_Station
Every 10 minutes a MQTT message is send to the MQTT-broker.
With MQTT-Explorer, I can see the messages on the MQTT-broker.
Code: Select all
home
weather
solarweatherstation
tempc = 10.1
humi = 63
abshpa = 992
relhpa = 1027
battv = 4.01
dewpointc = 3.3
heatindexc = 10.1
accuracy = 94
spreadc = 6.7
zambrettisays = Lepo vreme
trendinwords = stabilen
trend = -0.05
In Node Red MQTT input node I get the following values:
Code: Select all
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/tempc : msg.payload : string[3]
"9.9"
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/humi : msg.payload : string[3]
" 64"
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/abshpa : msg.payload : string[3]
"992"
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/relhpa : msg.payload : string[4]
"1027"
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/battv : msg.payload : string[4]
"4.01"
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/dewpointc : msg.payload : string[3]
"3.3"
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/heatindexc : msg.payload : string[3]
"9.9"
12. 11. 2020 13:41:38node: e7f6fdd4.4080d
home/weather/solarweatherstation/accuracy : msg.payload : string[3]
" 94"
12. 11. 2020 13:41:39node: e7f6fdd4.4080d
home/weather/solarweatherstation/spreadc : msg.payload : string[3]
"6.6"
12. 11. 2020 13:41:39node: e7f6fdd4.4080d
home/weather/solarweatherstation/zambrettisays : msg.payload : string[10]
"Fine Weather"
12. 11. 2020 13:41:39node: e7f6fdd4.4080d
home/weather/solarweatherstation/trendinwords : msg.payload : string[8]
"steady"
12. 11. 2020 13:41:39node: e7f6fdd4.4080d
home/weather/solarweatherstation/trend : msg.payload : string[5]
"-0.05"
{"command":"udevice", "idx":121, "svalue":"10.1;63;1;1027;2"}
{"command":"udevice", "idx":121, "svalue":"tm;hu;lv;ba;pr"}
where tm is the temperature, hu is the humidity and lv is the environment level, ba is the pressure and pr is the prediction.
Regards
Roman
- FireWizard
- Posts: 1765
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello @Lipa
I see that you have already Node Red and a MQTT server running.
Can you connect a "Debug" node, directly after your MQTT Input node and publish a screenshot of the Debug node output, with the tree openen as much as possible. Click on all triangle , so that as much information is visible. There are a number of examples in this thread.
If you open de MQTT input node, insert the following in the "Topic" field: home/weather/solarweatherstation.
Are the temperature, humidity environment level, pressure and prediction the only values, you should like to see send to Domoticz?
I see, also the dewpoint, heatindex, something like trend (also in words).
The list of published MQTT is:
home/weather/solarweatherstation/tempc
home/weather/solarweatherstation/heatindexc
home/weather/solarweatherstation/dewpointc
home/weather/solarweatherstation/spreadc
home/weather/solarweatherstation/abshpa
home/weather/solarweatherstation/relhpa
home/weather/solarweatherstation/humi
home/weather/solarweatherstation/battv
home/weather/solarweatherstation/zambrettisays
home/weather/solarweatherstation/trend
home/weather/solarweatherstation/accuracy
Source: https://github.com/3KUdelta/Solar_WiFi_ ... Settings.h
It is important that the sensors for temperature, humidity and pressure are published at the same moment.
Where should environment level and prediction come from?
"Lepo vreme" means "Nice weather", but that is relative for each person
, but it is not in the Domoticz list.
Regards
I see that you have already Node Red and a MQTT server running.
Can you connect a "Debug" node, directly after your MQTT Input node and publish a screenshot of the Debug node output, with the tree openen as much as possible. Click on all triangle , so that as much information is visible. There are a number of examples in this thread.
If you open de MQTT input node, insert the following in the "Topic" field: home/weather/solarweatherstation.
Are the temperature, humidity environment level, pressure and prediction the only values, you should like to see send to Domoticz?
I see, also the dewpoint, heatindex, something like trend (also in words).
The list of published MQTT is:
home/weather/solarweatherstation/tempc
home/weather/solarweatherstation/heatindexc
home/weather/solarweatherstation/dewpointc
home/weather/solarweatherstation/spreadc
home/weather/solarweatherstation/abshpa
home/weather/solarweatherstation/relhpa
home/weather/solarweatherstation/humi
home/weather/solarweatherstation/battv
home/weather/solarweatherstation/zambrettisays
home/weather/solarweatherstation/trend
home/weather/solarweatherstation/accuracy
Source: https://github.com/3KUdelta/Solar_WiFi_ ... Settings.h
It is important that the sensors for temperature, humidity and pressure are published at the same moment.
Where should environment level and prediction come from?
"Lepo vreme" means "Nice weather", but that is relative for each person

Regards
Who is online
Users browsing this forum: No registered users and 0 guests