Get sensor values with MQTT into Domoticz [Solved]
Moderator: leecollings
-
- Posts: 235
- Joined: Wednesday 17 February 2016 22:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Germany
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello FireWizard,
answer to your pre post for now I'm not sure if it's necessary to use state because I could also work with target temperature. I use this already with my zwave wall thermostats. I use dzvents scripts when a window is open. I just change the target temperature below real temperature that turn valve off.
The command for change target temperature works in a console, but my problem still is what do I have to do to bring the value of idx 422 to my WLAN thermometer.
Cheers
answer to your pre post for now I'm not sure if it's necessary to use state because I could also work with target temperature. I use this already with my zwave wall thermostats. I use dzvents scripts when a window is open. I just change the target temperature below real temperature that turn valve off.
The command for change target temperature works in a console, but my problem still is what do I have to do to bring the value of idx 422 to my WLAN thermometer.
Cheers
- FireWizard
- Posts: 1769
- 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]
Good evening @sailmich,
However, you have expressed the wish also to receive the "State".
If you can tell me the type of virtual sensor/switch and IDX, I can add that to the flow easily.
The next step is to add the flow FROM Domoticz TO the WLAN Thermostat.
This flow is independent from the other flow, but based on the same principle.
The first node is a MQTT output node (Do not forget to change it to your values, currently connected to 'localhost')
The topic is domoticz/out. This node receives the messages from all your Domoticz devices. This is not what we want, as we want only the messages from the Thermostat device, IDX 422. Therefore we have after the MQTT Output node a filter, which filters idx 422.
This is a "Switch" node. After this node we will see only the messages from the Domoticz Thermostat Setpoint.
Well, and then we have a "Function" node that picks the Setpoint and sends it to a MQTT Input node.
Do not forget to change it to your values, currently connected to 'localhost'.
You will find the complete flow below.
Awaiting your response.
Regards
So, if the flow FROM the WLAN Thermostat TO Domoticz works, we do not touch it anymore.That work!
However, you have expressed the wish also to receive the "State".
If you can tell me the type of virtual sensor/switch and IDX, I can add that to the flow easily.
The next step is to add the flow FROM Domoticz TO the WLAN Thermostat.
This flow is independent from the other flow, but based on the same principle.
The first node is a MQTT output node (Do not forget to change it to your values, currently connected to 'localhost')
The topic is domoticz/out. This node receives the messages from all your Domoticz devices. This is not what we want, as we want only the messages from the Thermostat device, IDX 422. Therefore we have after the MQTT Output node a filter, which filters idx 422.
This is a "Switch" node. After this node we will see only the messages from the Domoticz Thermostat Setpoint.
Well, and then we have a "Function" node that picks the Setpoint and sends it to a MQTT Input node.
Do not forget to change it to your values, currently connected to 'localhost'.
You will find the complete flow below.
Code: Select all
[{"id":"b4d932de.06a13","type":"mqtt in","z":"68896a5a.1b56e4","name":"","topic":"domoticz/out","qos":"0","datatype":"json","broker":"f9f13036.e28b58","x":130,"y":320,"wires":[["afea5dd3.506a48"]]},{"id":"6b11673a.1a3b8","type":"debug","z":"68896a5a.1b56e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":260,"wires":[]},{"id":"afea5dd3.506a48","type":"switch","z":"68896a5a.1b56e4","name":"Filter Thermostat","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"422","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":320,"wires":[["d0807f15.a49ab8"]]},{"id":"551ade66.9e8db","type":"mqtt out","z":"68896a5a.1b56e4","name":"To WLAN Thermostat","topic":"","qos":"","retain":"","broker":"f9f13036.e28b58","x":780,"y":320,"wires":[]},{"id":"d0807f15.a49ab8","type":"function","z":"68896a5a.1b56e4","name":"","func":"msg.topic = \"thermostat_wz/cmnd/things/thermostat/properties/targetTemperature\";\nmsg.payload = msg.payload.svalue1;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":320,"wires":[["6b11673a.1a3b8","551ade66.9e8db"]]},{"id":"f9f13036.e28b58","type":"mqtt-broker","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":""}]
Regards
-
- Posts: 235
- Joined: Wednesday 17 February 2016 22:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Germany
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello @FireWizard,
perfect flow and explanation! For state I believe I have to use a selector switch.
Cheers
perfect flow and explanation! For state I believe I have to use a selector switch.
Cheers
- FireWizard
- Posts: 1769
- 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]
@sailmich
And you want to send these data to your WLAN Thermostat?
I thought, it was the intention to receive it FROM the thermostat.
Regards
You can do that, of course.For state I believe I have to use a selector switch
And you want to send these data to your WLAN Thermostat?
I thought, it was the intention to receive it FROM the thermostat.
Regards
-
- Posts: 235
- Joined: Wednesday 17 February 2016 22:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Germany
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello @FireWizard,
beside to receive the state from thermostat it might be also cool to send new state from domoticz device to WLAN thermostat. If I can do so, I might use changing state when a window is open/closed.
With your input I tried to create a flow to change the state of my selector 328.
192.xxx.xxx.xx:6219/json.htm?type=command¶m=switchlight&idx=328&switchcmd=Set%20Level&level=10 set my my selector to heat. When put 0 inside to off and with 30 to eco. So it's working from a browser.
This is my flow
As you can see my domoticz selector get the value according to the log, but in real no change on my selector. In addition I get this error message. I assume there are mistakes in my function nodes.
I'm interesting in your comments!
Cheers
beside to receive the state from thermostat it might be also cool to send new state from domoticz device to WLAN thermostat. If I can do so, I might use changing state when a window is open/closed.
With your input I tried to create a flow to change the state of my selector 328.
192.xxx.xxx.xx:6219/json.htm?type=command¶m=switchlight&idx=328&switchcmd=Set%20Level&level=10 set my my selector to heat. When put 0 inside to off and with 30 to eco. So it's working from a browser.
This is my flow
Code: Select all
[{"id":"cf6d6748.c998e8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"19cc2bd0.28650c","type":"debug","z":"cf6d6748.c998e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":100,"wires":[]},{"id":"41ceb942.33e438","type":"mqtt in","z":"cf6d6748.c998e8","name":"State_WZ","topic":"thermostat_wz/stat/things/thermostat/properties","qos":"2","datatype":"json","broker":"ae93a774.7f606","x":80,"y":200,"wires":[["d467fedb.ba1f6","ff8d15b1.4dd928"]]},{"id":"d467fedb.ba1f6","type":"switch","z":"cf6d6748.c998e8","name":"stateheating","property":"payload.state","propertyType":"msg","rules":[{"t":"eq","v":"heating","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":200,"wires":[["25a5a97f.1ed63e"]]},{"id":"ff8d15b1.4dd928","type":"switch","z":"cf6d6748.c998e8","name":"stateoff","property":"payload.state","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":340,"y":240,"wires":[["d455412b.993f18"]]},{"id":"25a5a97f.1ed63e","type":"function","z":"cf6d6748.c998e8","name":"","func":"msg.payload = {\"command\":\"switchlight\",\"idx\":328,\"switchcmd\":\"Set%20Level\",\"level\":10};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":550,"y":200,"wires":[["19cc2bd0.28650c","843eb2af.e64d7"]]},{"id":"d455412b.993f18","type":"function","z":"cf6d6748.c998e8","name":"","func":"msg.payload = {\"command\":\"switchlight\",\"idx\":328,\"switchcmd\":\"Set20%Level\",\"level\":0};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":240,"wires":[["2d5b1341.e181bc","843eb2af.e64d7"]]},{"id":"2d5b1341.e181bc","type":"debug","z":"cf6d6748.c998e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":320,"wires":[]},{"id":"843eb2af.e64d7","type":"mqtt out","z":"cf6d6748.c998e8","name":"domoticz/in","topic":"","qos":"","retain":"","broker":"ae93a774.7f606","x":820,"y":200,"wires":[]},{"id":"ae93a774.7f606","type":"mqtt-broker","name":"MQTTRpi","broker":"192.xxx.xxx.xx","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
I'm interesting in your comments!
Cheers
- FireWizard
- Posts: 1769
- 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 @sailmich,
You wrote:
This should not be a problem.
As you might have see, we can send a lot of things:
Or any other mode you want to try, like eco or auto, (replace it at the end)
With regards, to the flow, you sent, I will come back later today. (Some visitors are arriving.)
Regards
You wrote:
beside to receive the state from thermostat it might be also cool to send new state from domoticz device to WLAN thermostat. If I can do so, I might use changing state when a window is open/closed.
This should not be a problem.
As you might have see, we can send a lot of things:
So if you can try from the commandline the command, you want to send:# set device on
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/properties/deviceOn -m "true"
# set device to heating
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/properties/mode -m "heat"
# set target temperature
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/properties/targetTemperature -m "23.5"
# set target temperature (json)
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/properties -m '{"targetTemperature":23.00}'
# set target temperature and mode (json)
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/properties -m '{"targetTemperature":22.00,"mode":heat}'
# set device to auto (target temperature controlled by MCU-Scheduler)
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/properties/mode -m "auto"
# just request properties
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/properties -n
# request properties and show answer directly
mosquitto_rr -h mqtt -t home/test/cmnd/things/thermostat/properties -n -e home/test/stat/things/thermostat/properties
# Change Schedules (here: weekday schedules)
mosquitto_pub -h mqtt -t home/test/cmnd/things/thermostat/schedules -m \
'{"w1h":"06:00","w1t":20.00,"w2h":"08:00","w2t":15.00,"w3h":"11:30","w3t":15.00,"w4h":"13:30","w4t":15.00,"w5h":"17:00","w5t":23.00,"w6h":"23:00","w6t":15.00}'
# disable MQTT logging
mosquitto_pub -h mqtt -t home/test/cmnd/things/logging/properties/logLevel -m "silent"
# set to level trace (available: silent|fatal|error|warning|notice|trace|verbose)
mosquitto_pub -h mqtt -t home/test/cmnd/things/logging/properties/logLevel -m "trace"
# show logs
mosquitto_sub -h mqtt -v -t "home/test/tele/log/#"
# send MCU command by MQTT
mosquitto_pub -t "home/test/cmnd/things/thermostat/mcucommand" -m "55 aa 00 1c 00 08 01 14 09 0c 10 30 0f 06"
Code: Select all
mosquitto_pub -h mqtt -t thermostat_wz/cmnd/things/thermostat/properties/mode -m "heat"
With regards, to the flow, you sent, I will come back later today. (Some visitors are arriving.)
Regards
- FireWizard
- Posts: 1769
- 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 @@sailmich,
You have send me a nice puzzle, which was very easy at the end. It is always the same.
Actually there were 3 errors in your flow.
The error "Type Error: Cannot read property 'toString' of undefined" (as shown in your screenshot) was not caused by the new Function, you created, but it pointed to another Function node, that was working fine previously.
If you hoover with your mouse over the error you will see that another Function node is indicated.
It took me some time, with a lot of testing and trying to find that this has been caused by a missing topic in the MQTT Output node.
Also it was not included in your newly created "Function" node.
So, if you use a separate MQTT Output node take care that it has a topic, either configured in the node itself or sent by the previous node.
I inserted it in the node itself. The topic should be "domoticz/in" (without quotes) It was inserted in the Name, but not in the Topic field.
The next error I saw immediately, but that did no harm.
See the screenshot. In your first command was a typo. You used "Set20%Level". This should be "Set%20Level". The other Function node was okay.
When I corrected these 2 mistakes the "TypeError: etc" was gone, but it did not communicate with a selector switch.
The commands you used, are for http and not for mqtt.
For MQTT you should use:
For Off:
and for Level 10:
Test this first and then we continue.
Regards
You have send me a nice puzzle, which was very easy at the end. It is always the same.

Actually there were 3 errors in your flow.
The error "Type Error: Cannot read property 'toString' of undefined" (as shown in your screenshot) was not caused by the new Function, you created, but it pointed to another Function node, that was working fine previously.
If you hoover with your mouse over the error you will see that another Function node is indicated.
It took me some time, with a lot of testing and trying to find that this has been caused by a missing topic in the MQTT Output node.
Also it was not included in your newly created "Function" node.
So, if you use a separate MQTT Output node take care that it has a topic, either configured in the node itself or sent by the previous node.
I inserted it in the node itself. The topic should be "domoticz/in" (without quotes) It was inserted in the Name, but not in the Topic field.
The next error I saw immediately, but that did no harm.
See the screenshot. In your first command was a typo. You used "Set20%Level". This should be "Set%20Level". The other Function node was okay.
When I corrected these 2 mistakes the "TypeError: etc" was gone, but it did not communicate with a selector switch.
The commands you used, are for http and not for mqtt.
For MQTT you should use:
For Off:
Code: Select all
msg.payload = {"command":"udevice","idx":328,"nvalue":0,"svalue":"0"};
return msg;
Code: Select all
msg.payload = {"command":"udevice","idx":328,"nvalue":1,"svalue":"10"};
return msg;
Regards
- FireWizard
- Posts: 1769
- 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, @sailmich,
I just simplified the flows and merged the last one with the previous one.
Have a look and let me know.
Regards
I just simplified the flows and merged the last one with the previous one.
Have a look and let me know.
Code: Select all
[{"id":"c4018042.b8c4a","type":"debug","z":"68896a5a.1b56e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":140,"wires":[]},{"id":"7460aa1d.674a04","type":"mqtt in","z":"68896a5a.1b56e4","name":"From WLAN thermostat","topic":"thermostat_wz/stat/things/thermostat/properties","qos":"0","datatype":"json","broker":"f9f13036.e28b58","x":660,"y":200,"wires":[["c4018042.b8c4a","3cbe710b.9dc30e"]]},{"id":"3cbe710b.9dc30e","type":"function","z":"68896a5a.1b56e4","name":"","func":"msg1 = {};\nmsg2 = {};\nmsg3 = {};\n\nmsg1.payload = {\"command\":\"udevice\",\"idx\":325,\"nvalue\":0,\"svalue\":msg.payload.temperature.toString()};\nmsg2.payload = {\"command\":\"udevice\",\"idx\":422,\"nvalue\":0,\"svalue\":msg.payload.targetTemperature.toString()};\n\nswitch (msg.payload.state) {\n\n case \"off\":\n msg3.payload = {\"command\":\"udevice\",\"idx\":328,\"nvalue\":0,\"svalue\":\"0\"};\n break;\n \n case \"heating\":\n msg3.payload = {\"command\":\"udevice\",\"idx\":328,\"nvalue\":1,\"svalue\":\"10\"};\n break;\n}\n\nreturn [[msg1,msg2,msg3]];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":880,"y":200,"wires":[["64940c6b.232acc","baa0bd5f.a0bf18"]]},{"id":"64940c6b.232acc","type":"debug","z":"68896a5a.1b56e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":140,"wires":[]},{"id":"baa0bd5f.a0bf18","type":"mqtt out","z":"68896a5a.1b56e4","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"f9f13036.e28b58","x":1070,"y":200,"wires":[]},{"id":"f9f13036.e28b58","type":"mqtt-broker","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":""}]
-
- Posts: 235
- Joined: Wednesday 17 February 2016 22:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Germany
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hello @FireWizard,
I will try to understand what you did since my last post. I obvisually misunderstood the mqtt domoticz wiki. So I use json format.
I'll give feedback to you as soon as I tried the code.
Cheers
I will try to understand what you did since my last post. I obvisually misunderstood the mqtt domoticz wiki. So I use json format.
I'll give feedback to you as soon as I tried the code.
Cheers
-
- Posts: 235
- Joined: Wednesday 17 February 2016 22:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Germany
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
@FireWizard,
thank you very much! Your flow is perfect, now I have an idea and two good samples to start with. I'm sure I will try to change/add some features to your flow.
I hope I can come back to you when I can't find solutions.
Stay healthy
Cheers
thank you very much! Your flow is perfect, now I have an idea and two good samples to start with. I'm sure I will try to change/add some features to your flow.
I hope I can come back to you when I can't find solutions.
Stay healthy
Cheers
- FireWizard
- Posts: 1769
- 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]
@sailmich
If you have questions or want to have things checked let me know.
Thanks and regards
If you have questions or want to have things checked let me know.
Thanks and regards
-
- Posts: 8
- Joined: Friday 01 April 2022 8:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2023.1
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Great work @FireWizard regarding the mqtt flows! I imported your code for the growatt inverter and commented some devices out. However I get a strange spike in Domoticz at the end of the day which is exact the sum of the values generated. What am I doing wrong?
I made a virtual sensor:

Strange spike

Any thoughts?
Code: Select all
var msg1 = {}; // pvstatus, Inverter run state
var msg2 = {}; // pv1watt, PV1 input watt (0.1W)
var msg3 = {}; // pv2watt, PV2 input watt (0.1W)
var msg4 = {}; // pvpowerin, Actual input power (0.1W)
var msg5 = {}; // pvpowerout, Actual output power (0.1W)
var msg6 = {}; // pvfrequentie, Grid frequency (0.01Hz)
var msg7 = {}; // pvgridvoltage, Three/single phase grid voltage (0.1V)
var msg8 = {}; // pvenergytoday, Today generated energy (0.1KWH)
var msg9 = {}; // pvenergytotal, Total generated energy (0.1KWH)
var msg10 = {}; // pv1voltage, PV1 voltage (0.1V)
var msg11 = {}; // pv2voltage, PV2 voltage (0.1V)
var msg12 = {}; // pv1current, PV1 input current (0.1A)
var msg13 = {}; // pv2current, PV2 input current (0.1A)
var msg14 = {}; // pvtemperature, Inverter temperature (0.1C)
var msg15 = {}; // pvipmtemperature, The inside IPM in inverter temperature (0.1C), be aware not available in all inverters!
var msg16 = {}; // combined values
// switch (msg.payload.values.pvstatus) {
// case 0 :
// msg1.payload = {"command":"udevice","idx":1001,"nvalue":0,"svalue": "Waiting"};
// break
//
// case 1 :
// msg1.payload = {"command":"udevice","idx":1001,"nvalue":1,"svalue": "Normal"};
// break
//
// case 2 :
// msg1.payload = {"command":"udevice","idx":1001,"nvalue":2,"svalue": "Fault"};
// break
// }
// msg2.payload = {"command":"udevice","idx":1002,"nvalue":0,"svalue":((msg.payload.values.pv1watt) / 10).toString()};
// msg3.payload = {"command":"udevice","idx":1003,"nvalue":0,"svalue":((msg.payload.values.pv2watt) / 10).toString()};
// msg4.payload = {"command":"udevice","idx":1004,"nvalue":0,"svalue":((msg.payload.values.pvpowerin) / 10).toString()};
// msg5.payload = {"command":"udevice","idx":1005,"nvalue":0,"svalue":((msg.payload.values.pvpowerout) / 10).toString()};
// msg6.payload = {"command":"udevice","idx":1006,"nvalue":0,"svalue":((msg.payload.values.pvfrequentie) / 100).toString()};
// msg7.payload = {"command":"udevice","idx":1007,"nvalue":0,"svalue":((msg.payload.values.pvgridvoltage) / 10).toString()};
// msg8.payload = {"command":"udevice","idx":1008,"nvalue":0,"svalue":((msg.payload.values.pvenergytoday) / 10).toString()};
// msg9.payload = {"command":"udevice","idx":1009,"nvalue":0,"svalue":((msg.payload.values.pvenergytotal) / 10).toString()};
// msg10.payload = {"command":"udevice","idx":1010,"nvalue":0,"svalue":((msg.payload.values.pv1voltage) / 10).toString()};
// msg11.payload = {"command":"udevice","idx":1011,"nvalue":0,"svalue":((msg.payload.values.pv2voltage) / 10).toString()};
// msg12.payload = {"command":"udevice","idx":1012,"nvalue":0,"svalue":((msg.payload.values.pv1current) / 10).toString()};
// msg13.payload = {"command":"udevice","idx":1013,"nvalue":0,"svalue":((msg.payload.values.pv2current) / 10).toString()};
msg14.payload = {"command":"udevice","idx":250,"nvalue":0,"svalue":((msg.payload.values.pvtemperature) / 10).toString()};
// msg15.payload = {"command":"udevice","idx":1015,"nvalue":0,"svalue":((msg.payload.values.pvipmtemperature) / 10).toString()};
msg16.payload = { "command": "udevice", "idx": 249, "nvalue": 0, "svalue": ((msg.payload.values.pvpowerout) / 10).toString() + ";" + ((msg.payload.values.pvenergytoday) * 100).toString() };
return [[msg14,msg16]];
// return [[msg1,msg2,msg3,msg4,msg5,msg6,msg7,ms8,msg9,msg10,msg11,msg12,msg13,msg14,msg15,msg16]];

Strange spike

Any thoughts?
-
- Posts: 8
- Joined: Friday 01 April 2022 8:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2023.1
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Hmmzz, I think I found the solution in viewtopic.php?t=35958 . Change the virtual device "energy read" to "computed"instead "from device". We'll see if it works tonight.
-
- Posts: 196
- Joined: Wednesday 31 May 2017 16:06
- Target OS: NAS (Synology & others)
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
Since a few weeks, some flows in Node-RED, based on MQTT and JSON from different sources give TypeErrors. Some do not work any more. Exact cause is not known to me. Maybe it happened because of updating Node-Red to v.3.0.2.
I will start with one flow that gives no data in Domoticz and gives this error in Node_RED:

This is an export of the flow:
and this is the output of the source, a Growatt inverter, it sends its data every 5 minutes to the broker:
I hope to get a hint why it gives errors..
When I put the cursor on the declaration of msg, it says: Cannot find name 'msg1. Did you mean 'msg10'? A quick fix does not help me further.
I hope to get a hint why it gives errors..
Thanks in advance
I will start with one flow that gives no data in Domoticz and gives this error in Node_RED:

Code: Select all
TypeError: Cannot read properties of undefined (reading 'toString')
Code: Select all
[{"id":"936b12da.8ecb78","type":"tab","label":"MQTT Growatt naar Domoticz","disabled":false,"info":""},{"id":"f01b6ff0.ce4878","type":"mqtt in","z":"936b12da.8ecb78","name":"Growatt in","topic":"energy/growatt","qos":"0","datatype":"auto-detect","broker":"7fb3e06.2d91f2","nl":false,"rap":false,"inputs":0,"x":80,"y":120,"wires":[["5042148d.6e8f34"]]},{"id":"5042148d.6e8f34","type":"function","z":"936b12da.8ecb78","name":"Conversie MQTT naar JSON voor Syno","func":"// @ts-nocheck\nmsg1 = {};\nmsg2 = {};\nmsg3 = {};\nmsg4 = {};\nmsg5 = {};\nmsg6 = {};\nmsg7 = {};\nmsg8 = {};\nmsg9 = {};\nmsg10 = {};\nif (msg.payload.pvstatus == \"1\") {\n msg1.payload = {\"command\":\"udevice\",\"idx\":1261,\"nvalue\":1,\"svalue\":msg.payload.pvstatus}\n} else {\n msg1.payload = {\"command\":\"udevice\",\"idx\":1261,\"nvalue\":4,\"svalue\":msg.payload.pvstatus}\n}\nmsg2.payload = {\"command\":\"udevice\",\"idx\":1262,\"nvalue\":0,\"svalue\":msg.payload.pv1watt.toString()};\nmsg3.payload = {\"command\":\"udevice\",\"idx\":1263,\"nvalue\":0,\"svalue\":msg.payload.pv1voltage.toString()};\nmsg4.payload = {\"command\":\"udevice\",\"idx\":1264,\"nvalue\":0,\"svalue\":msg.payload.pv1current.toString()};\nmsg5.payload = {\"command\":\"udevice\",\"idx\":1265,\"nvalue\":0,\"svalue\":msg.payload.pvfrequentie.toString()};\nmsg6.payload = {\"command\":\"udevice\",\"idx\":1266,\"nvalue\":0,\"svalue\":msg.payload.pvgridvoltage.toString()};\nmsg7.payload = {\"command\":\"udevice\",\"idx\":1267,\"nvalue\":0,\"svalue\":msg.payload.pvgridcurrent.toString()};\nmsg8.payload = {\"command\":\"udevice\",\"idx\":1268,\"nvalue\":0,\"svalue\":msg.payload.pvgridpower.toString()};\nmsg9.payload = {\"command\":\"udevice\",\"idx\":1269,\"nvalue\":0,\"svalue\":msg.payload.pvtemperature.toString()};\nmsg10.payload = {\"command\":\"udevice\",\"idx\":1276,\"nvalue\":0,\"svalue\":msg.payload.pvitemperature.toString()};\nreturn [[msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,msg10]];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":120,"wires":[["6bed263.b6565d8","733eede6.d10984"]]},{"id":"6bed263.b6565d8","type":"debug","z":"936b12da.8ecb78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":200,"wires":[]},{"id":"733eede6.d10984","type":"mqtt out","z":"936b12da.8ecb78","name":"To Domoticz op Syno","topic":"domoticz/in","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7fb3e06.2d91f2","x":660,"y":120,"wires":[]},{"id":"7fb3e06.2d91f2","type":"mqtt-broker","name":"","broker":"192.168.1.18","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Code: Select all
{"device": "FPH1B0200D", "time": "2023-09-09T16:53:30", "buffered": "no", "values": {"datalogserial": "XGD2A11695", "pvserial": "FPH1B0200D", "pvstatus": 1, "pvpowerin": 4870, "pv1voltage": 1214, "pv1current": 41, "pv1watt": 4870, "pv2voltage": 0, "pv2current": 0, "pv2watt": 0, "pvpowerout": 4777, "pvfrequentie": 4997, "pvgridvoltage": 2314, "pvgridcurrent": 21, "pvgridpower": 4761, "pvgridvoltage2": 0, "pvgridcurrent2": 0, "pvgridpower2": 0, "pvgridvoltage3": 0, "pvgridcurrent3": 0, "pvgridpower3": 0, "totworktime": 67271838, "pvenergytoday": 85, "pvenergytotal": 36075, "epvtotal": 36503, "epv1today": 86, "epv1total": 36503, "epv2today": 0, "epv2total": 0, "pvtemperature": 470, "pvipmtemperature": 519}}
When I put the cursor on the declaration of msg, it says: Cannot find name 'msg1. Did you mean 'msg10'? A quick fix does not help me further.
I hope to get a hint why it gives errors..
Thanks in advance
Synology with Domoticz build (V2024.7) in Docker
- FireWizard
- Posts: 1769
- 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 @PieterS,
See PM
See PM
-
- Posts: 196
- Joined: Wednesday 31 May 2017 16:06
- Target OS: NAS (Synology & others)
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Get sensor values with MQTT into Domoticz [Solved]
@Firewizard:
You made my day! Thanks a lot!
You made my day! Thanks a lot!

Synology with Domoticz build (V2024.7) in Docker
Who is online
Users browsing this forum: No registered users and 0 guests