Empty values on template

Hello,

I want to show temperature en humidity form different deivces on an floorplan. So I use a join to combine the different payloads. After that I use a function to save the values and restore them at reload. ( otherwise I have empty values).


This is the output of the join node:
image
So I have 4 different payloads.

This is the function node:

var temp1 = flow.get("tBadkamer") || undefined;
var hum1 = flow.get("hBadkamer") || undefined;
var temp2 = flow.get("tEntree") || undefined;
var hum2 = flow.get("hEntree") || undefined;
var temp3 = flow.get("tBuiten") || undefined;
var hum3 = flow.get("hBuiten") || undefined;
var temp4 = flow.get("tWoonkamer") || undefined;
var hum4 = flow.get("hWoonkamer") || undefined;

flow.set("tBadkamer",msg.payload[1].sensorDataPoints.insideTemperature.celsius);
flow.set("hBadkamer",msg.payload[1].sensorDataPoints.humidity.percentage);
msg.payload.tbadkamer = temp1
msg.payload.hbadkamer = hum1


flow.set("tEntree",msg.payload[2].sensorDataPoints.insideTemperature.celsius);
flow.set("hEntree",msg.payload[2].sensorDataPoints.humidity.percentage);
msg.payload.tentree = temp2
msg.payload.hentree = hum2
return msg


flow.set("tBuiten",msg.payload[3].devices[0].modules[0].dashboard_data.Temperature);
flow.set("hBuiten",msg.payload[3].devices[0].modules[0].dashboard_data.Humidity);
msg.payload.tbuiten = temp3
msg.payload.hbuiten = hum3
return msg

flow.set("tWoonkamer",msg.payload[0].sensorDataPoints.insideTemperature.celsius);
flow.set("hWoonkamer",msg.payload[0].sensorDataPoints.humidity.percentage);
msg.payload.twoonkamer = temp4
msg.payload.hWoonkamer = hum4
return msg

This is the template:

<style>
#THBuiten {
    left: 1300px !important;
    Top: 730px !important;
}
#THWoonkamer {
    left: 500px !important;
    Top: 310px !important;
}
#THBadkamer {
    left: 1250px !important;
    Top: 250px !important;
}
#THEntree {
    left: 30% !important;
    Top: 65% !important;
}
#valuehome {
    color: black;
    vertical-align: middle;
    text-align: right;
}
#svghome {
    text-align: -webkit-right;
}
.divTable{
	display: table;
    border-collapse: separate;
    border: 2px solid #999999;
    border-radius: 10px;
    position: absolute;
    width:100px;
    height:30px;
}
.divTableRow {
	display: table-row;
}
.divTableHeading {
	background-color: #EEE;
	display: table-header-group;
}
.divTableCell, .divTableHead {
	border: 1px solid #999999;
	display: table-cell;
	z-index: 1000;
}
.divTableBody {
	display: table-row-group;
}
</style>
<div>
<div class="divTable" id="THBuiten">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{msg.payload.tbuiten}}</div><div class="divTableCell" id="valuehome">°C</div><div class="divTableCell" id="svghome"><img src="icons/thermometer.svg" width="30" height="30"></div>
</div>
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{msg.payload.hbuiten}}</div><div class="divTableCell" id="valuehome">%</div><div class="divTableCell" id="svghome"><img src="icons/humidity.svg" width="30" height="30"></div>
</div>
</div>
</div>
</div>
<div>
<div class="divTable" id="THWoonkamer">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{msg.payload.twoonkamer}}</div><div class="divTableCell" id="valuehome">°C</div><div class="divTableCell" id="svghome"><img src="icons/thermometer.svg" width="30" height="30"></div>
</div>
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{msg.payload.hwoonkamer}}</div><div class="divTableCell" id="valuehome">%</div><div class="divTableCell" id="svghome"><img src="icons/humidity.svg" width="30" height="30"></div>
</div>
</div>
</div>
<div>
<div class="divTable" id="THBadkamer">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{flow.temp1}}</div><div class="divTableCell" id="valuehome">°C</div><div class="divTableCell" id="svghome"><img src="icons/thermometer.svg" width="30" height="30"></div>
</div>
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{flow.hum1}}</div><div class="divTableCell" id="valuehome">%</div><div class="divTableCell" id="svghome"><img src="icons/humidity.svg" width="30" height="30"></div>
</div>
</div>
</div>
</div>
<div>
<div class="divTable" id="THEntree">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{msg.payload.tentree}}</div><div class="divTableCell" id="valuehome">°C</div><div class="divTableCell" id="svghome"><img src="icons/thermometer.svg" width="30" height="30"></div>
</div>
<div class="divTableRow">
<div class="divTableCell" id="valuehome">{{msg.payload.hentree}}</div><div class="divTableCell" id="valuehome">%</div><div class="divTableCell" id="svghome"><img src="icons/humidity.svg" width="30" height="30"></div>
</div>
</div>
</div>
</div>
</div>

But I don't get any values. Anyone know why?

I was going to comment your code but there are so many issues...

  1. You havent shared your flow some some things are assumed
  2. You have multiple returns (any thing after the first return is NEVER executed)
  3. You grab value from flow and set the msg prop but you dont update the flow value at the right time (your flow.get statements will always retrieve the old value due to code ordering)
  4. you are using array mode on the join node - you can never guarantee the order of values coming from devices and thus the order of the items in the array may be mixed up.
  5. You assign new properties values to the incoming msg.payload - which is an array. You should not do this. Create a new object with properties and assign that to payload.

Recommendations

  1. Use the key/value mode in the join
  2. Either delete the flow context parts of your function OR if you need flow context, store the single joined object - but always use the values from the join node.
1 Like

Thanks for your reply. I'm not a programmer but I'm trying to learn.

There are passwords and usernames in the flow. That's why I didn't share my flow.

I did use the key/value mode in the join but there is nothing comming trough.
image

I did delete the function node but there is not any data comming trough

I don't know how to do that.

Following the recommendations from @Steve-Mcl you will have a function node that will looks more like below. I just removed the major errors, so it still needs improvements and could be rewritten in a better way.

var temp1 = flow.get("tBadkamer") || undefined;
var hum1 = flow.get("hBadkamer") || undefined;
var temp2 = flow.get("tEntree") || undefined;
var hum2 = flow.get("hEntree") || undefined;
var temp3 = flow.get("tBuiten") || undefined;
var hum3 = flow.get("hBuiten") || undefined;
var temp4 = flow.get("tWoonkamer") || undefined;
var hum4 = flow.get("hWoonkamer") || undefined;


flow.set("tWoonkamer",msg.payload[0].temperature);
flow.set("hWoonkamer",msg.payload[0].humidity);
flow.set("tBadkamer",msg.payload[1].temperature);
flow.set("hBadkamer",msg.payload[1].humidity);
flow.set("tEntree",msg.payload[2].temperature);
flow.set("hEntree",msg.payload[2].humidity);
flow.set("tBuiten",msg.payload[3].temperature);
flow.set("hBuiten",msg.payload[3].humidity);


//added
msg.payload = {};
//endadded

msg.payload.tbadkamer = temp1
msg.payload.hbadkamer = hum1
msg.payload.tentree = temp2
msg.payload.hentree = hum2
msg.payload.tbuiten = temp3
msg.payload.hbuiten = hum3
msg.payload.twoonkamer = temp4
msg.payload.hWoonkamer = hum4
return msg

Exported flows wont contain passwords. To prove this, export flow, paste to text editor, search for your private details - they should not be there.

Also, you dont have to export everything. You can select only the relevant nodes and press CTRL+E

Lastly, you could setup a mock flow that demonstrates your issue - using change nodes instead of the TADO nodes (since people will NOT have your sensors and likely wont have the TADO nodes installed)

Originally, you must have been using array mode as your code was accessing msg.payload[0].temperature and msg.payload[2].humidity etc

After you have something coming out of the join node - that looks right - add a change node after the join and set it up to SET flow.xxxxx TO msg.payload

Thanks for your input

Here is my flow. When I exported the flow it was with password and username but I removed that:

[{"id":"6e7e5b25.431034","type":"ui_template","z":"4722bed2.dd209","group":"ff37b9ad.926348","name":"TnH Begane Grond","order":1,"width":30,"height":"20","format":"<style>\n#THBuiten {\n    left: 1300px !important;\n    Top: 730px !important;\n}\n#THWoonkamer {\n    left: 500px !important;\n    Top: 310px !important;\n}\n#THBadkamer {\n    left: 1250px !important;\n    Top: 250px !important;\n}\n#THEntree {\n    left: 30% !important;\n    Top: 65% !important;\n}\n#valuehome {\n    color: black;\n    vertical-align: middle;\n    text-align: right;\n}\n#svghome {\n    text-align: -webkit-right;\n}\n.divTable{\n\tdisplay: table;\n    border-collapse: separate;\n    border: 2px solid #999999;\n    border-radius: 10px;\n    position: absolute;\n    width:100px;\n    height:30px;\n}\n.divTableRow {\n\tdisplay: table-row;\n}\n.divTableHeading {\n\tbackground-color: #EEE;\n\tdisplay: table-header-group;\n}\n.divTableCell, .divTableHead {\n\tborder: 1px solid #999999;\n\tdisplay: table-cell;\n\tz-index: 1000;\n}\n.divTableBody {\n\tdisplay: table-row-group;\n}\n</style>\n<div>\n<div class=\"divTable\" id=\"THBuiten\">\n<div class=\"divTableBody\">\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.tbuiten}}</div><div class=\"divTableCell\" id=\"valuehome\">°C</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\"></div>\n</div>\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.hbuiten}}</div><div class=\"divTableCell\" id=\"valuehome\">%</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n</div>\n</div>\n</div>\n</div>\n<div>\n<div class=\"divTable\" id=\"THWoonkamer\">\n<div class=\"divTableBody\">\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.twoonkamer}}</div><div class=\"divTableCell\" id=\"valuehome\">°C</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\"></div>\n</div>\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.hwoonkamer}}</div><div class=\"divTableCell\" id=\"valuehome\">%</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n</div>\n</div>\n</div>\n<div>\n<div class=\"divTable\" id=\"THBadkamer\">\n<div class=\"divTableBody\">\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{flow.temp1}}</div><div class=\"divTableCell\" id=\"valuehome\">°C</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\"></div>\n</div>\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{flow.hum1}}</div><div class=\"divTableCell\" id=\"valuehome\">%</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n</div>\n</div>\n</div>\n</div>\n<div>\n<div class=\"divTable\" id=\"THEntree\">\n<div class=\"divTableBody\">\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.tentree}}</div><div class=\"divTableCell\" id=\"valuehome\">°C</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\"></div>\n</div>\n<div class=\"divTableRow\">\n<div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.hentree}}</div><div class=\"divTableCell\" id=\"valuehome\">%</div><div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n</div>\n</div>\n</div>\n</div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1150,"y":1880,"wires":[[]]},{"id":"c4657994.6ecca8","type":"ui_template","z":"4722bed2.dd209","group":"ff37b9ad.926348","name":"","order":2,"width":30,"height":1,"format":"<style>\nbody {\n    background-image: url(icons/beganegrond.svg);\n    background-repeat: no-repeat;\n    background-position: center;\n    background-size: auto;\n}\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1120,"y":1820,"wires":[[]]},{"id":"c7298e00.bd08b","type":"tado","z":"4722bed2.dd209","configName":"6d8b0ebb.367a","apiCall":"getZoneState","homeId":"XXXXXX","deviceId":"","zoneId":"8","power":"on","temperature":"18","terminationType":"manual","terminationTimeout":900,"name":"Tado Badkamer","reportDate":"","presence":"HOME","geoTracking":true,"temperatureOffset":0,"windowDetection":true,"windowDetectionTimeout":900,"openWindowMode":true,"timetableId":"","x":470,"y":1880,"wires":[["bd5befe9.642c","c391d94.3f66228"]]},{"id":"502f63a3.5de02c","type":"inject","z":"4722bed2.dd209","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":1880,"wires":[["c7298e00.bd08b","9009125f.3b925","8a6ecd79.4b1e3","bca82c5b.2ae67","4ceb6db7.b967e4","6aac005b.83848","cada61ae.9ce4","43f45d4.2f4fda4","12d28b69.f0d3c5"]]},{"id":"8a6ecd79.4b1e3","type":"tado","z":"4722bed2.dd209","configName":"6d8b0ebb.367a","apiCall":"getZoneState","homeId":"XXXXXX","deviceId":"","zoneId":"7","power":"on","temperature":"18","terminationType":"manual","terminationTimeout":900,"name":"Tado Entree","reportDate":"","presence":"HOME","geoTracking":true,"temperatureOffset":0,"windowDetection":true,"windowDetectionTimeout":900,"openWindowMode":true,"timetableId":"","x":460,"y":1980,"wires":[["c78f5633.8d7978","c391d94.3f66228"]]},{"id":"bca82c5b.2ae67","type":"tado","z":"4722bed2.dd209","configName":"6d8b0ebb.367a","apiCall":"getZoneState","homeId":"XXXXXXX","deviceId":"","zoneId":"1","power":"on","temperature":"18","terminationType":"manual","terminationTimeout":900,"name":"Tado Wookamer","reportDate":"","presence":"HOME","geoTracking":true,"temperatureOffset":0,"windowDetection":true,"windowDetectionTimeout":900,"openWindowMode":true,"timetableId":"","x":470,"y":1800,"wires":[["57bbf8c.dfb9808","c391d94.3f66228"]]},{"id":"e96b6aae.a37f68","type":"debug","z":"4722bed2.dd209","name":"join","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1310,"y":2080,"wires":[]},{"id":"57bbf8c.dfb9808","type":"debug","z":"4722bed2.dd209","name":"Woonkamer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":1740,"wires":[]},{"id":"bd5befe9.642c","type":"debug","z":"4722bed2.dd209","name":"Badkamer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":1740,"wires":[]},{"id":"c78f5633.8d7978","type":"debug","z":"4722bed2.dd209","name":"Entree","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":1740,"wires":[]},{"id":"c391d94.3f66228","type":"join","z":"4722bed2.dd209","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":730,"y":1880,"wires":[["e96b6aae.a37f68","6e7e5b25.431034"]]},{"id":"12d28b69.f0d3c5","type":"get stations data","z":"4722bed2.dd209","name":"Station","creds":"6f236403.2c34dc","x":460,"y":2060,"wires":[["c391d94.3f66228"]]},{"id":"ff37b9ad.926348","type":"ui_group","z":"","name":"Begane grond","tab":"718fbdb4.4cec64","order":5,"disp":true,"width":"30","collapse":false},{"id":"6d8b0ebb.367a","type":"tado-config","z":"","name":"Tado"},{"id":"6f236403.2c34dc","type":"configNode","z":"","client_id":"XXXXXXXXXXXXXXXXXXXXXXXX","client_secret":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","username":"XXXXXXXXXXXXXXXXXXXXXXXX","password":"XXXXXXXXXXXXXXXXXXXX","device_id":"XXXXXXXXXXXXXXXXXXXXXXXXX"},{"id":"XXXXXXXXXXXXXXXXXXXXXX","type":"ui_tab","z":"","name":"test","icon":"dashboard","order":12,"disabled":false,"hidden":false}]

That's right. I changed it to key/value but there is no output. Why is there no output?

Honestly, there was so much wrong and you didnt provide sample data & you included TADO nodes (which I dont have) etc etc etc - I simply dont have the energy to fully explain all the issues. :sigh:


Use debug nodes & the copy path feature to avoid mistakes

MqnoZGT9yF


Here is a semi working demo based on snippets of information you have provided - you will need to correct it / tidy it up...

The flow...

[{"id":"6e7e5b25.431034","type":"ui_template","z":"af952aeaa20f4f97","group":"a348b0ef9d248038","name":"TnH Begane Grond","order":1,"width":"12","height":"20","format":"<style>\n    #THBuiten {\n        left: 1300px !important;\n        Top: 730px !important;\n    }\n\n    #THWoonkamer {\n        left: 500px !important;\n        Top: 310px !important;\n    }\n\n    #THBadkamer {\n        left: 1250px !important;\n        Top: 250px !important;\n    }\n\n    #THEntree {\n        left: 30% !important;\n        Top: 65% !important;\n    }\n\n    #valuehome {\n        color: black;\n        vertical-align: middle;\n        text-align: right;\n    }\n\n    #svghome {\n        text-align: -webkit-right;\n    }\n\n    .divTable {\n        display: table;\n        border-collapse: separate;\n        border: 2px solid #999999;\n        border-radius: 10px;\n        position: absolute;\n        width: 100px;\n        height: 30px;\n    }\n\n    .divTableRow {\n        display: table-row;\n    }\n\n    .divTableHeading {\n        background-color: #EEE;\n        display: table-header-group;\n    }\n\n    .divTableCell,\n    .divTableHead {\n        border: 1px solid #999999;\n        display: table-cell;\n        z-index: 1000;\n    }\n\n    .divTableBody {\n        display: table-row-group;\n    }\n</style>\n\n<div>\n    <div class=\"divTable\" id=\"THBuiten\">\n        <div class=\"divTableBody\">\n            <div class=\"divTableRow\">\n                <div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.entry.sensorDataPoints.insideTemperature.celsius}}</div>\n                <div class=\"divTableCell\" id=\"valuehome\">°C</div>\n                <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\"></div>\n            </div>\n            <div class=\"divTableRow\">\n                <div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.entry.humidity.percentage}}</div>\n                <div class=\"divTableCell\" id=\"valuehome\">%</div>\n                <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n            </div>\n        </div>\n    </div>\n</div>\n<div>\n    <div class=\"divTable\" id=\"THWoonkamer\">\n        <div class=\"divTableBody\">\n            <div class=\"divTableRow\">\n                <div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.wookamer.sensorDataPoints.insideTemperature.celsius}}</div>\n                <div class=\"divTableCell\" id=\"valuehome\">°C</div>\n                <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\"></div>\n            </div>\n            <div class=\"divTableRow\">\n                <div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.wookamer.humidity.percentage}}</div>\n                <div class=\"divTableCell\" id=\"valuehome\">%</div>\n                <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n            </div>\n        </div>\n    </div>\n    <div>\n        <div class=\"divTable\" id=\"THBadkamer\">\n            <div class=\"divTableBody\">\n                <div class=\"divTableRow\">\n                    <div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.badkamer.sensorDataPoints.insideTemperature.celsius}}</div>\n                    <div class=\"divTableCell\" id=\"valuehome\">°C</div>\n                    <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\">\n                    </div>\n                </div>\n                <div class=\"divTableRow\">\n                    <div class=\"divTableCell\" id=\"valuehome\">{{fmsg.payload.badkamer.humidity.percentage}}</div>\n                    <div class=\"divTableCell\" id=\"valuehome\">%</div>\n                    <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n                </div>\n            </div>\n        </div>\n    </div>\n    <div>\n        <div class=\"divTable\" id=\"THEntree\">\n            <div class=\"divTableBody\">\n                <div class=\"divTableRow\">\n                    <div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.entry.sensorDataPoints.insideTemperature.celsius}}</div>\n                    <div class=\"divTableCell\" id=\"valuehome\">°C</div>\n                    <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/thermometer.svg\" width=\"30\" height=\"30\">\n                    </div>\n                </div>\n                <div class=\"divTableRow\">\n                    <div class=\"divTableCell\" id=\"valuehome\">{{msg.payload.entry.humidity.percentage}}</div>\n                    <div class=\"divTableCell\" id=\"valuehome\">%</div>\n                    <div class=\"divTableCell\" id=\"svghome\"><img src=\"icons/humidity.svg\" width=\"30\" height=\"30\"></div>\n                </div>\n            </div>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2130,"y":1500,"wires":[[]]},{"id":"502f63a3.5de02c","type":"inject","z":"af952aeaa20f4f97","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":1440,"y":1520,"wires":[["c0bb39b5ad90e48e","292ca5b06ec75f45","6d3a4ea22970d3a6","8fff4443dc0dd699"]]},{"id":"e96b6aae.a37f68","type":"debug","z":"af952aeaa20f4f97","name":"join","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2090,"y":1560,"wires":[]},{"id":"c391d94.3f66228","type":"join","z":"af952aeaa20f4f97","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1930,"y":1520,"wires":[["e96b6aae.a37f68","6e7e5b25.431034"]]},{"id":"c0bb39b5ad90e48e","type":"change","z":"af952aeaa20f4f97","name":"wookamer (fake tado)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"sensorDataPoints\":{\"insideTemperature\":{\"celsius\":21.5}},\"humidity\":{\"percentage\":56}}","tot":"json"},{"t":"set","p":"topic","pt":"msg","to":"wookamer","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1680,"y":1420,"wires":[["c391d94.3f66228"]]},{"id":"292ca5b06ec75f45","type":"change","z":"af952aeaa20f4f97","name":"badkamer (fake tado)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"sensorDataPoints\":{\"insideTemperature\":{\"celsius\":20.3}},\"humidity\":{\"percentage\":36}}","tot":"json"},{"t":"set","p":"topic","pt":"msg","to":"badkamer","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1680,"y":1480,"wires":[["c391d94.3f66228"]]},{"id":"6d3a4ea22970d3a6","type":"change","z":"af952aeaa20f4f97","name":"entry (fake tado)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"sensorDataPoints\":{\"insideTemperature\":{\"celsius\":24.7}},\"humidity\":{\"percentage\":44}}","tot":"json"},{"t":"set","p":"topic","pt":"msg","to":"entry","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1660,"y":1540,"wires":[["c391d94.3f66228"]]},{"id":"8fff4443dc0dd699","type":"change","z":"af952aeaa20f4f97","name":"station_data (fake tado)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"devices\":[{\"modules\":[{\"dashboard_data\":{\"Temperature\":22.8,\"Humidity\":66}}]}]}","tot":"json"},{"t":"set","p":"topic","pt":"msg","to":"station_data","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1690,"y":1600,"wires":[["c391d94.3f66228"]]},{"id":"a348b0ef9d248038","type":"ui_group","name":"Default","tab":"3316deba5234ba30","order":1,"disp":true,"width":"12","collapse":false,"className":""},{"id":"3316deba5234ba30","type":"ui_tab","name":"test","icon":"dashboard","disabled":false,"hidden":false}]

thanks for your help.

I imported your flow and changed the nodes. But I dont get any output from the join node.

This is the output of a TADO node:

The path to my temperature and humidity values are:

msg.payload.sensorDataPoints.insideTemperature.celsius
msg.payload.sensorDataPoints.humidity.percentage

I have 3 Tado nodes and a Netatmo node. Maybe thats my problem

That suggests either...

  • 1 of the four nodes is not returning a value (check with debug nodes)
  • The tado nodes msg don't have a topic. A topic is required to identify the payload when using key/value mode
    • If the tado node dont add a topic to the msg (check the tado nodes configs), then put a change node after every tado node and set unique topic names like I did in my demo.

I delete the Netamo node and set the number of messages to 3 and now its working.

How can I join different devices (nodes) in one template?

I did this before without the join node but when the data is comming from the Tado node the Netatmo values are empy and vice versa

image
the first three nodes are Tado and the last one is Netatmo

You can join as many different types and sources as you wish so long as they have a topic in the message. Use a debug node to check that every message that goes into the join has a topic. If it does not have a topic, add one manually with a change node.


Some tips for you...

See this article in the cookbook for an example of how to join messages into one object.

Also, 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.

this is the output of the Netatmo node:

and this is the output of a Tado node:

what value should i use in the Join node?

You don't need to do anything with the join node.

As I've said 2 times before simply ensure that the message going into the join node has a topic.

Set your debug nodes to "show complete message" - ensure EVERY msg that GOES INTO the JOIN has a topic.

Then use the "copy path" button as I demonstrated before

That was the problem there was no topic send into the join node. I mixed up "topic" and "path". Sorry.
But it's working now.

Thanks for your help.

I want to add another device to the floorplan. My lights.
This is the original flow:

[{"id":"70bea0a.fec8f6","type":"mqtt in","z":"46d40c7e.15e854","name":"MQTT receiver light","topic":"homie/homey-5d14b942367eb80ccf0c77c3/woonkamer/onoff","qos":"2","datatype":"auto","broker":"a4ac80e1.bc5fe","x":290,"y":260,"wires":[["459d2d4e.cb8bf4"]]},{"id":"459d2d4e.cb8bf4","type":"function","z":"46d40c7e.15e854","name":"Kleur en icoon","func":"// note that this flow is triggered by an mqtt message AND by the repeating timestamp node\n// here we deal with the message payload only\nif (msg.payload === \"true\"){\n\n    flow.set(\"statusWoonkamerLamp\", true);\n}\nelse if (msg.payload ===\"false\") {\n    flow.set(\"statusWoonkamerLamp\", false);\n}\nelse {\n    // don't do anything here as this could be your timestamp trigger\n}\n\n// here we deal with the flow variable.\nif (flow.get(\"statusWoonkamerLamp\")){\n    msg.ui_control = {icon:\"icons/light-bulb-on-60.png\", tooltip:\"Licht is aan\"};\n    msg.label = \"Licht is aan\"\n}\nelse {\n    msg.ui_control = {icon:\"icons/light-bulb-off-60.png\", tooltip:\"Licht is uit\"};\n    msg.label = \"Licht is uit\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":260,"wires":[["acc314d2.fd2e58"]]},{"id":"1feffbb6.1a5754","type":"mqtt out","z":"46d40c7e.15e854","name":"MQTT Transmitter","topic":"homie/homey-5d14b942367eb80ccf0c77c3/woonkamer/onoff/set","qos":"","retain":"","broker":"a4ac80e1.bc5fe","x":1130,"y":260,"wires":[]},{"id":"acc314d2.fd2e58","type":"ui_template","z":"46d40c7e.15e854","group":"b290cc21.d734d","name":"Woonkamer","order":7,"width":4,"height":3,"format":"<md-button class=\"btn1\" id=\"buttonlight\" style=\"background-color:#ff333333\" ng-click=\"send({payload: msg.payload })\"> \n    <img id=\"imgofbutton\" src=\"{{msg.ui_control.icon}}\">\n    <div class=\"textofbutton\">\n         <b id=\"buttonslighttext\">Woonkamer</b>\n    </div>\n</md-button>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":750,"y":260,"wires":[["4791f9ea.330c68"]]},{"id":"4791f9ea.330c68","type":"function","z":"46d40c7e.15e854","name":"","func":"\nif (msg.payload === \"false\" ){\n    msg.payload = \"true\";\n}\nelse { msg.payload = \"false\";\n}\nreturn [msg];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":260,"wires":[["1feffbb6.1a5754"]]},{"id":"1c318816.bec408","type":"inject","z":"46d40c7e.15e854","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"15","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":310,"y":220,"wires":[["459d2d4e.cb8bf4"]]},{"id":"a4ac80e1.bc5fe","type":"mqtt-broker","z":"","name":"Homey MQTT","broker":"192.168.1.6","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b290cc21.d734d","type":"ui_group","z":"","name":"Buttons","tab":"2a0bd1d7.7ca9ce","order":1,"disp":false,"width":30,"collapse":false},{"id":"2a0bd1d7.7ca9ce","type":"ui_tab","z":"","name":"Verlcihting","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

I added a light to the previous flow:


and I add a change node to set a topic. But now the msg.payload doesn't come out the join node. Anyone know why?

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