Multiple payloads

Well set it to 11 then and you will get all 11, which is what you want.

I'm sorry but I have an unexpected emergency. I will come back tomorrow .

With this flow and 1 in Join I recover the index of each tariff.
I would like for each tariff to have the index in a "Change"

That is a completely different question. In that case you don't need the change node or the join node. All you need do is to feed the green node into a switch node configured like
image
and so on.

Are you sure that is what you want to do though? What are you going to do with the data?

I then want to use the ActiveElectricalEnergy value of each tariff (I'm going to use 6 of the 11) to feed InfluxDB as I did when I had a single tariff using this type of flow.

How then in the payload to keep only ActiveElectricalEnergy (without the tariff)?

[{"id":"b3700c8b9d618eab","type":"tab","label":"Conso Elec","disabled":false,"info":""},{"id":"55b365a34be0688a","type":"debug","z":"b3700c8b9d618eab","name":"Energie","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1180,"y":20,"wires":[]},{"id":"888de18ff31f3238","type":"inject","z":"b3700c8b9d618eab","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":110,"y":100,"wires":[["2bf4fb1af822dd2a"]]},{"id":"2bf4fb1af822dd2a","type":"api-current-state","z":"b3700c8b9d618eab","name":"","server":"5fe64ecfc725358d","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.compteur_elec","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":370,"y":100,"wires":[["cdbf6cd3da19a719"]]},{"id":"07f068ed13d535d2","type":"influxdb out","z":"b3700c8b9d618eab","influxdb":"a2f2ec32c3680a14","name":"influxdb index_elec","measurement":"index_elec","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1110,"y":80,"wires":[]},{"id":"686311ae3e490d08","type":"inject","z":"b3700c8b9d618eab","name":"Read Index","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"index_Wh","payloadType":"flow","x":110,"y":160,"wires":[[]]},{"id":"cdbf6cd3da19a719","type":"debug","z":"b3700c8b9d618eab","name":"Show index","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":100,"wires":[]},{"id":"a9b4f4d37f55f52c","type":"function","z":"b3700c8b9d618eab","name":"","func":"var elec_start_hour = flow.get(\"index_wh_start_hour\");\nvar elec_end_hour= flow.get(\"index_wh_end_hour\");\nmsg.payload = [elec_end_hour,elec_start_hour];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":460,"wires":[["eb6a902123a8ec20"]]},{"id":"870a2db649da8946","type":"switch","z":"b3700c8b9d618eab","name":"period select","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"hour","vt":"str"},{"t":"eq","v":"day","vt":"str"},{"t":"eq","v":"month","vt":"str"},{"t":"eq","v":"year","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":470,"y":240,"wires":[["b703365e32845e28"],["9302f0b3a07bce15"],["106564ace53e6aeb"],["11811e8916931410"]]},{"id":"b703365e32845e28","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_start_hour","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":220,"wires":[["dd77727158779cfe"]]},{"id":"73f037d7e7e81835","type":"debug","z":"b3700c8b9d618eab","name":"Conso Elec hour","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1290,"y":420,"wires":[]},{"id":"c6badfdfc5ac2461","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_end_hour","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":460,"wires":[["a9b4f4d37f55f52c"]]},{"id":"88c4135e0bae3f59","type":"inject","z":"b3700c8b9d618eab","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":90,"y":460,"wires":[["c6badfdfc5ac2461","7251e85f0e36713e","bced3906f8003b4e","234fc03395ef3449"]]},{"id":"f731ea52b9de927d","type":"function","z":"b3700c8b9d618eab","name":"transforme en nombre + format pour influx","func":"var conso_elec = parseFloat(msg.payload);\nmsg.payload = [];\nfields = {\"value\":conso_elec};\ntags =  {\"entity\":\"conso_elec_hour\"};\nmsg.payload = [fields,tags];\nreturn msg;","outputs":1,"noerr":4,"initialize":"","finalize":"","libs":[],"x":960,"y":460,"wires":[["e859df79083e6d6d","73f037d7e7e81835"]]},{"id":"e859df79083e6d6d","type":"influxdb out","z":"b3700c8b9d618eab","influxdb":"a2f2ec32c3680a14","name":"Influxdb Conso Wh hour","measurement":"conso_elec","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1310,"y":460,"wires":[]},{"id":"dd77727158779cfe","type":"debug","z":"b3700c8b9d618eab","name":"Index start hour","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1060,"y":220,"wires":[]},{"id":"cd4d44f702725ece","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":140,"wires":[[]]},{"id":"bced3906f8003b4e","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_end_month","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":640,"wires":[["52c457cee5a7a1ce"]]},{"id":"52c457cee5a7a1ce","type":"function","z":"b3700c8b9d618eab","name":"","func":"var elec_start_month = flow.get(\"index_wh_start_month\");\nvar elec_end_month = flow.get(\"index_wh_end_month\");\nmsg.payload = [elec_end_month,elec_start_month];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":640,"wires":[["3377505202438d5a"]]},{"id":"106564ace53e6aeb","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_start_month","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":300,"wires":[["e86d9dd9d3d3e6cc"]]},{"id":"7251e85f0e36713e","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_end_day","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":560,"wires":[["5f4057581945bb17"]]},{"id":"5f4057581945bb17","type":"function","z":"b3700c8b9d618eab","name":"","func":"var elec_start_day = flow.get(\"index_wh_start_day\");\nvar elec_end_day = flow.get(\"index_wh_end_day\");\nmsg.payload = [elec_end_day,elec_start_day];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":560,"wires":[["48f8c026257b58a0"]]},{"id":"4bf2e1d6e85b69f2","type":"function","z":"b3700c8b9d618eab","name":"transforme en nombre + format pour influx","func":"var conso_elec = parseFloat(msg.payload);\nmsg.payload = [];\nfields = {\"value\":conso_elec};\ntags =  {\"entity\":\"conso_elec_day\"};\nmsg.payload = [fields,tags];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":560,"wires":[["83713e5aef04c58b","bfbbb6521bba021e"]]},{"id":"9302f0b3a07bce15","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_start_day","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":260,"wires":[["8a451485f3c7bbd1"]]},{"id":"8a451485f3c7bbd1","type":"debug","z":"b3700c8b9d618eab","name":"Index start day","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1060,"y":260,"wires":[]},{"id":"83713e5aef04c58b","type":"debug","z":"b3700c8b9d618eab","name":"Conso Elec day","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1280,"y":520,"wires":[]},{"id":"e86d9dd9d3d3e6cc","type":"debug","z":"b3700c8b9d618eab","name":"Index start month","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1070,"y":300,"wires":[]},{"id":"11811e8916931410","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_start_year","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":360,"wires":[["86fe69af410c89b2"]]},{"id":"86fe69af410c89b2","type":"debug","z":"b3700c8b9d618eab","name":"Index start year","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1060,"y":360,"wires":[]},{"id":"234fc03395ef3449","type":"change","z":"b3700c8b9d618eab","name":"","rules":[{"t":"set","p":"index_wh_end_year","pt":"flow","to":"index_wh","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":800,"wires":[["040eb0455ecb8099"]]},{"id":"040eb0455ecb8099","type":"function","z":"b3700c8b9d618eab","name":"","func":"var elec_start_year = flow.get(\"index_wh_start_year\");\nvar elec_end_year = flow.get(\"index_wh_end_year\");\nmsg.payload = [elec_end_year,elec_start_year];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":800,"wires":[["cc9bbcb2cb5fac82"]]},{"id":"88be785424ea462d","type":"inject","z":"b3700c8b9d618eab","name":"Manual init","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":360,"wires":[["b703365e32845e28","9302f0b3a07bce15","106564ace53e6aeb","11811e8916931410"]]},{"id":"bfbbb6521bba021e","type":"influxdb out","z":"b3700c8b9d618eab","influxdb":"a2f2ec32c3680a14","name":"Influxdb Conso Wh day","measurement":"conso_elec","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1310,"y":560,"wires":[]},{"id":"cad128a236d0f153","type":"function","z":"b3700c8b9d618eab","name":"transforme en nombre + format pour influx","func":"var conso_elec3 = parseFloat(msg.payload);\nvar date = new Date();\nvar month = date.getMonth() + 1;\nvar year = date.getFullYear();\nvar tag_date = month+\"-\"+year;\nmsg.payload = [];\nfields = {\"value\":conso_elec3};\ntags =  {\"entity\":\"conso_month\", \"month\":tag_date};\nmsg.payload = [fields,tags];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":640,"wires":[["6a9e3f292065b6cd","c8a5328307de0d28"]]},{"id":"c8a5328307de0d28","type":"debug","z":"b3700c8b9d618eab","name":"Conso Elec month","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1310,"y":620,"wires":[]},{"id":"6a9e3f292065b6cd","type":"influxdb out","z":"b3700c8b9d618eab","influxdb":"a2f2ec32c3680a14","name":"Influxdb Conso Wh month","measurement":"conso_elec3","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1330,"y":660,"wires":[]},{"id":"668b2d6dc64f6203","type":"function","z":"b3700c8b9d618eab","name":"transforme en nombre + format pour influx","func":"var conso_elec3 = parseFloat(msg.payload);\nvar date = new Date();\nvar year = date.getFullYear();\nmsg.payload = [];\nfields = {\"value\":conso_elec3};\ntags =  {\"entity\":\"conso_year\", \"year\":year};\nmsg.payload = [fields,tags];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":800,"wires":[["30b8e96ce9d4809c","4a484007d178c732"]]},{"id":"30b8e96ce9d4809c","type":"influxdb out","z":"b3700c8b9d618eab","influxdb":"a2f2ec32c3680a14","name":"Influxdb Conso Wh year","measurement":"conso_elec3","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1310,"y":840,"wires":[]},{"id":"4a484007d178c732","type":"debug","z":"b3700c8b9d618eab","name":"Conso Elec year","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1280,"y":800,"wires":[]},{"id":"0ef07a0a65ccc217","type":"inject","z":"b3700c8b9d618eab","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"600","payloadType":"num","x":730,"y":720,"wires":[["e4516c1e292b5a39"]]},{"id":"e4516c1e292b5a39","type":"function","z":"b3700c8b9d618eab","name":"","func":"var conso_elec3 = parseFloat(msg.payload);\nvar month = '3'\nvar year = '2019'\nvar tag_date = month+\"-\"+year;\nmsg.payload = [];\nfields = {\"value\":conso_elec3};\ntags =  {\"entity\":\"conso_month\", \"month\":tag_date};\nmsg.payload = [fields,tags];\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":720,"wires":[["a3eb75a5f80b4871","6a9e3f292065b6cd"]]},{"id":"a3eb75a5f80b4871","type":"debug","z":"b3700c8b9d618eab","name":"Historique mois","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1400,"y":720,"wires":[]},{"id":"32cdd745c31b336e","type":"knxUltimate","z":"b3700c8b9d618eab","server":"e91643e.d9013c","topic":"9/7/0","outputtopic":"","dpt":"13.010","initialread":0,"notifyreadrequest":false,"notifyresponse":false,"notifywrite":true,"notifyreadrequestalsorespondtobus":false,"notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized":"0","listenallga":false,"name":"9/7/0 Index compteur Elec","outputtype":"write","outputRBE":false,"inputRBE":false,"formatmultiplyvalue":1,"formatnegativevalue":"leave","formatdecimalsvalue":999,"passthrough":"no","x":670,"y":20,"wires":[["55b365a34be0688a","07f068ed13d535d2","cd4d44f702725ece"]]},{"id":"eb6a902123a8ec20","type":"calculator","z":"b3700c8b9d618eab","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sub","constant":"","round":false,"decimals":"0","x":720,"y":460,"wires":[["f731ea52b9de927d"]]},{"id":"3377505202438d5a","type":"calculator","z":"b3700c8b9d618eab","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sub","constant":"","round":false,"decimals":"0","x":750,"y":600,"wires":[["cad128a236d0f153"]]},{"id":"48f8c026257b58a0","type":"calculator","z":"b3700c8b9d618eab","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sub","constant":"","round":false,"decimals":"0","x":720,"y":560,"wires":[["4bf2e1d6e85b69f2"]]},{"id":"cc9bbcb2cb5fac82","type":"calculator","z":"b3700c8b9d618eab","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"sub","constant":"","round":false,"decimals":"0","x":720,"y":800,"wires":[["668b2d6dc64f6203"]]},{"id":"9998949a9c1b37e2","type":"cronplus","z":"b3700c8b9d618eab","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"hour","topic":"hour","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0  * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"day","topic":"day","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 0 * * ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"month","topic":"month","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 0 1 * ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"year","topic":"year","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 0 1 1 ? *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":220,"y":240,"wires":[["870a2db649da8946"]]},{"id":"5fe64ecfc725358d","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"a2f2ec32c3680a14","type":"influxdb","hostname":"a0d7b954-influxdb","port":"8086","protocol":"http","database":"nodereddb","name":"influx db addon","usetls":false,"tls":"","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true},{"id":"e91643e.d9013c","type":"knxUltimate-config","host":"192.168.1.100","port":"3671","physAddr":"15.15.22","hostProtocol":"TunnelUDP","suppressACKRequest":false,"csv":"","KNXEthInterface":"Auto","KNXEthInterfaceManuallyInput":"","statusDisplayLastUpdate":true,"statusDisplayDeviceNameWhenALL":true,"statusDisplayDataPoint":false,"stopETSImportIfNoDatapoint":"skip","loglevel":"error","name":"Passerelle IP-KNX","localEchoInTunneling":true,"delaybetweentelegrams":"40","delaybetweentelegramsfurtherdelayREAD":"1","ignoreTelegramsWithRepeatedFlag":false}]

Use a Change node.

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.
Pay particular attention to the section Working with Messages which should help you to understand.

Again, I think you don't need to split the messages up. Show us an example of the message that you want to send to Influxdb. Are you using the tariff as an influx Tag?

1 Like

When I subscribed to the single tariff, I had the value of the consumption index and I subtracted it every hour, day, month and year in order to store the consumption for the period in question in the database.
The new subscription offers pricing that varies according to the color of the day (blue, white, or red) and for each day there is a peak period (6 a.m. to 10 p.m.) and an off-peak period (10 p.m. to 6 a.m. ). I don't want to store everything in the database, but only the consumption during off-peak hours and during peak hours (whether the day is blue, white or red).
I would therefore like to have the "ActiveElectricalEnergy" consumption for tariffs 5, 6 and 7 (off-peak hours) and calculate the sum over the period considered; the same for tariffs 8, 9 and 10 (peak hours)

Here is the formatting before sending the message in InfluxDB
NR-235-92

To isolate the value of ActiveElectricalEnergy I set a "Change" this way but it doesn't work.
NR-235-91

OK, you can use the Switch node setting I suggested earlier to separate the messages by tariff.
Think about what you want to do with ActiveElectricalEnergy. I think you want to move that into msg.payload. So in the Change node use
Move msg.payload.ActiveElectricalEnergy To msg.payload

1 Like

It's ok, I recovered the index for each tariff.
Thanks a lot for the help!
I will follow your advice and watch the Node-RED Essentials videos before continuing my project.
Thanks again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.