Full weather forecast by joining sensors and then parsing the combined flow
Node-RED

Full weather forecast by joining sensors and then parsing the combined flow

In this flow, I take the value of various existing Home Assistant weather sensors and join them to form a full weather forecast. If any sensor value is updated, the entire forecast gets updated.
A flow by David Colahan

Download flow

Flow Details

This app takes the sensor data that might be used in a custom weather card to create an app. It's a fairly simple app with the one 'trick' being to change the msg.topic of the sensor values to make a meaningful key/value object in the Join node. The Join mode waits until it gets data from all of the sensors (6 message parts) and the outputs each time a new part is received. The function node then parses out the variables to create the app. I've applied some simple conditional logic to shorten the message if there is no rain.

Use your own sensors (set output on connect to on)

[{"id":"84c71a44a230b27e","type":"server-state-changed","z":"f33f0b6332bd73b0","name":"","server":"854ade0b.a1a0c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.west_end_extended_text_0","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"forecast","valueType":"str"}],"x":230,"y":400,"wires":[["6fc272d1bc7bf308"]]},{"id":"156419b165b14262","type":"server-state-changed","z":"f33f0b6332bd73b0","name":"","server":"854ade0b.a1a0c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.west_end_temp_max_0","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"maxtemp","valueType":"str"}],"x":220,"y":520,"wires":[["6fc272d1bc7bf308"]]},{"id":"78d8d90668ba1dd1","type":"server-state-changed","z":"f33f0b6332bd73b0","name":"","server":"854ade0b.a1a0c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.west_end_temp_min_0","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"mintemp","valueType":"str"}],"x":210,"y":460,"wires":[["6fc272d1bc7bf308"]]},{"id":"6a3802af54e13186","type":"server-state-changed","z":"f33f0b6332bd73b0","name":"","server":"854ade0b.a1a0c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.west_end_rain_amount_max_0","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"rainmax","valueType":"str"}],"x":240,"y":700,"wires":[["6fc272d1bc7bf308"]]},{"id":"1771da78f68a295d","type":"server-state-changed","z":"f33f0b6332bd73b0","name":"","server":"854ade0b.a1a0c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.west_end_rain_amount_min_0","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"rainmin","valueType":"str"}],"x":240,"y":640,"wires":[["6fc272d1bc7bf308"]]},{"id":"be8530c14787f263","type":"server-state-changed","z":"f33f0b6332bd73b0","name":"","server":"854ade0b.a1a0c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.west_end_rain_chance_0","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"rainchance","valueType":"str"}],"x":220,"y":580,"wires":[["6fc272d1bc7bf308"]]},{"id":"6fc272d1bc7bf308","type":"join","z":"f33f0b6332bd73b0","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":" ","joinerType":"str","accumulate":true,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":570,"y":560,"wires":[["554a6b0b4a6ab836"]]},{"id":"554a6b0b4a6ab836","type":"function","z":"f33f0b6332bd73b0","name":"parser","func":"var forecast = msg.payload.forecast;\nvar mintemp = msg.payload.mintemp;\nvar maxtemp = msg.payload.maxtemp;\nvar rainchance = msg.payload.rainchance;\nvar rainmin = msg.payload.rainmin;\nvar rainmax = msg.payload.rainmax;\nif (rainmax = \"0\");\n var response = forecast + \" Min \" + mintemp + \" Max \" + maxtemp + rainchance + \" chance of between \" + rainmin + \" and \" + rainmax + \" mm of rain\"; \nvar response = forecast + \" Min \" + mintemp + \" Max \" + maxtemp;\nvar json = msg.payload;\nmsg.payload = {\n \"text\": response,\n \"textCase\":2,\n \"icon\": 43247,\n \"pushIcon\": 2,\n \"repeat\": 2\n }; \nreturn msg;\n \n \n","outputs":1,"noerr":1,"initialize":"","finalize":"","libs":[],"x":730,"y":560,"wires":[["3510100d85dcc704"]]},{"id":"3510100d85dcc704","type":"mqtt out","z":"f33f0b6332bd73b0","name":"","topic":"awtrix_7c1864/custom/fulltoday","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"4113a21355848dfe","x":990,"y":560,"wires":[]},{"id":"38ddaaed0db0a5a5","type":"comment","z":"f33f0b6332bd73b0","name":"Today's weather","info":"","x":680,"y":480,"wires":[]},{"id":"854ade0b.a1a0c","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":"4113a21355848dfe","type":"mqtt-broker","name":"mosquitto","broker":"192.168.86.183","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
-- Flow first published on May 29, 2023.