Also, if you want to send 2 or more values to the same virtual sensor, you do not need multiple msg definitions.
You only need that, in case you want to send from the same Function node multiple messages, either to the same output or to different outputs,
Multiple messages are needed in case of multiple virtual sensors. This is not the case.
I assume that these two values are not in the same message but in two different messages with the topics Momentanverbrauch and Gesamtverbrauch.
In order to combine these 2 messages, you have to use a "Join" node. I use the msg.topic as the key/value pair. As soon as the "Join" node has received two messages it will send to the output.
The picture is self-explanatory.
1. The semicolon is part of the string and so should be concatenated and between " ".
2. Domoticz expert the Energy in Wh, If you send the data in kWH (what I assumed), you have to multiply with 1000.
Code: Select all
[{"id":"f6c7807cab872308","type":"tab","label":"iobrokerZuDomoticz","disabled":false,"info":"","env":[]},{"id":"1ed653afb7e5303b","type":"mqtt in","z":"f6c7807cab872308","name":"Strom aktuell","topic":"Momentanverbrauch","qos":"1","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":190,"y":100,"wires":[["559fb68b706cd711"]]},{"id":"c3accf01d66fafc7","type":"function","z":"f6c7807cab872308","name":"","func":"msg.payload = { \"command\": \"udevice\", \"idx\": 485, \"nvalue\": 0, \"svalue\": msg.payload.Momentanverbrauch + \";\" + (msg.payload.Gesamtverbrauch) * 1000 };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":140,"wires":[["c3ef3855cd5673a9"]]},{"id":"3ec6e831b9bc19ac","type":"mqtt out","z":"f6c7807cab872308","name":"domoticz/in","topic":"domoticz/in","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":770,"y":140,"wires":[]},{"id":"c3ef3855cd5673a9","type":"debug","z":"f6c7807cab872308","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":60,"wires":[]},{"id":"29aadd3461791c27","type":"debug","z":"f6c7807cab872308","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":60,"wires":[]},{"id":"4bf2a1da2b1f3171","type":"mqtt out","z":"f6c7807cab872308","name":"MQTT Out","topic":"Momentanverbrauch","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":390,"y":260,"wires":[]},{"id":"81dba57675f8969b","type":"inject","z":"f6c7807cab872308","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"597","payloadType":"str","x":210,"y":260,"wires":[["4bf2a1da2b1f3171"]]},{"id":"6d3e0f9c584d476f","type":"mqtt in","z":"f6c7807cab872308","name":"Strom gesamt","topic":"Gesamtverbrauch","qos":"1","datatype":"auto","broker":"f9f13036.e28b58","nl":false,"rap":true,"rh":0,"inputs":0,"x":190,"y":180,"wires":[["559fb68b706cd711"]]},{"id":"b7531d04bc3918e8","type":"mqtt out","z":"f6c7807cab872308","name":"MQTT Out","topic":"Gesamtverbrauch","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":390,"y":340,"wires":[]},{"id":"558e23349b261fdb","type":"inject","z":"f6c7807cab872308","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"11313.0046","payloadType":"str","x":210,"y":340,"wires":[["b7531d04bc3918e8"]]},{"id":"559fb68b706cd711","type":"join","z":"f6c7807cab872308","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":140,"wires":[["29aadd3461791c27","c3accf01d66fafc7"]]},{"id":"f9f13036.e28b58","type":"mqtt-broker","name":"localhost","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
Let me know, if this is what you want.