Ok, clearly I’m not familiar with JS super well; but what this flow does is grab all the properties of my Ecobee Thermostat’s Outside Weather conditions and then start filtering them off to ultimately end up at a function node that complies the statement i want my Echo device to read back to me.
This is definitely over complicating this — I’m sure of it. I’d like to simplify this flow.
Most people suggest i just use switches over functions, but I don’t want a switch node 5” tall with all these outputs in my flow.
Could i maybe combine all those function nodes into one with IF/ELSE IF statements? I did try this, but i was lost how to code it properly.
Any advice?
Thanks.
[{"id":"335737ad.1a0418","type":"switch","z":"b66e483.15a8eb8","name":"Raining?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"raining","vt":"str"},{"t":"eq","v":"rainy","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":440,"y":440,"wires":[["fba14caf.090db8"],["fba14caf.090db8"],["f0d69251.a2a27"]]},{"id":"fba14caf.090db8","type":"switch","z":"b66e483.15a8eb8","name":"Temp Suggestion =","property":"data.attributes.temperature","propertyType":"msg","rules":[{"t":"gte","v":"29","vt":"str"},{"t":"lte","v":"15","vt":"str"},{"t":"lte","v":"10","vt":"str"},{"t":"lte","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":630,"y":360,"wires":[["ff0d1714.bb5348"],["37d0fd60.3ffce2"],["bc61b2b9.09ca78"],["16c917db.eabcf"],["45c5cf66.e347e8"]]},{"id":"f0d69251.a2a27","type":"switch","z":"b66e483.15a8eb8","name":"Temp Suggestion =","property":"data.attributes.temperature","propertyType":"msg","rules":[{"t":"gte","v":"29","vt":"str"},{"t":"lte","v":"15","vt":"str"},{"t":"lte","v":"10","vt":"str"},{"t":"lte","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":630,"y":560,"wires":[["1dc33845.cf419"],["62ad0afb.48e24c"],["6596742d.5baab4"],["f6b75bc0.692d4"],["76a31530.d8ae0c"]]},{"id":"ff0d1714.bb5348","type":"function","z":"b66e483.15a8eb8","name":"Very Hot (+29c) and Raining >>","func":"msg.payload = {\n data: {\"message\": \"Bring an umbrella Jon, also, its hot as balls. Currently its \" + msg.payload + \", and very hot at \" + msg.data.attributes.temperature + \" degrees outside. Ha, enjoy your walk\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":890,"y":280,"wires":[["b327215b.d6c9e"]]},{"id":"37d0fd60.3ffce2","type":"function","z":"b66e483.15a8eb8","name":"Chilly (15c - 10c) and Raining >>","func":"msg.payload = {\n data: {\"message\": \"Bring an Umbrella. its a tad chilly and raining. Currently, its \" + msg.payload + \", and \" + msg.data.attributes.temperature + \" degrees outside. Make the best of this walk\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":920,"y":320,"wires":[["b327215b.d6c9e"]]},{"id":"bc61b2b9.09ca78","type":"function","z":"b66e483.15a8eb8","name":"Cold (10c - 1c) and Raining >>","func":"msg.payload = {\n data: {\"message\": \"You'll need an umbrella jon. Its Cold and raining outside. Id wear a hoodie. Currently its \" + msg.payload + \", and \" + msg.data.attributes.temperature + \" degrees outside. Enjoy your walk guys\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":890,"y":360,"wires":[["b327215b.d6c9e"]]},{"id":"16c917db.eabcf","type":"function","z":"b66e483.15a8eb8","name":"Freezing (below 1c) and Raining >>","func":"msg.payload = {\n data: {\"message\": \"Its cold as balls, and fucking raining. Wear a jacket and bring an umbrella. Currently its \" + msg.payload + \", and \" + msg.data.attributes.temperature + \" degrees outside. Fuck this shit, move to the bahamas\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":920,"y":400,"wires":[["b327215b.d6c9e"]]},{"id":"45c5cf66.e347e8","type":"function","z":"b66e483.15a8eb8","name":"Nice temp (15c - 28c) and Raining >>","func":"msg.payload = {\n data: {\"message\": \"It's a Nice temperature, but bring an umbrella Jon. Its currently \" + msg.payload + \", and \" + msg.data.attributes.temperature + \" degrees outside. Enjoy your walk guys\"}};return msg;\n\n","outputs":1,"noerr":0,"x":910,"y":440,"wires":[["b327215b.d6c9e"]]},{"id":"1dc33845.cf419","type":"function","z":"b66e483.15a8eb8","name":"Very Hot (+29c) >>","func":"msg.payload = {\n data: {\"message\": \"Bust out your skimpiest thong Jon, is very hot. Currently its \" + msg.payload + \", and very hot at \" + msg.data.attributes.temperature + \" degrees outside. ill have the A C blasting for you guys when you return\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":850,"y":480,"wires":[["b327215b.d6c9e"]]},{"id":"62ad0afb.48e24c","type":"function","z":"b66e483.15a8eb8","name":"Chilly (15c - 10c) >>","func":"msg.payload = {\n data: {\"message\": \"its a tad chilly willy. Currently, its \" + msg.payload + \", and chilly at \" + msg.data.attributes.temperature + \" degrees outside\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":880,"y":520,"wires":[["b327215b.d6c9e"]]},{"id":"6596742d.5baab4","type":"function","z":"b66e483.15a8eb8","name":"Cold (10c - 1c) >>","func":"msg.payload = {\n data: {\"message\": \"Its Cold out, Id wear a hoodie. Currently its \" + msg.payload + \", and cold at \" + msg.data.attributes.temperature + \" degrees outside\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":850,"y":560,"wires":[["b327215b.d6c9e"]]},{"id":"f6b75bc0.692d4","type":"function","z":"b66e483.15a8eb8","name":"Freezing (below 1c) >>","func":"msg.payload = {\n data: {\"message\": \"Its cold as balls, Wear a jacket bitch, or just pack up and move to the bahamas. Currently its \" + msg.payload + \", and freezing at \" + msg.data.attributes.temperature + \" degrees outside\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":880,"y":600,"wires":[["b327215b.d6c9e"]]},{"id":"76a31530.d8ae0c","type":"function","z":"b66e483.15a8eb8","name":"Nice temp (15c - 28c) >>","func":"msg.payload = {\n data: {\"message\": \"its a Nice temperature outside. Its currently \" + msg.payload + \", and \" + msg.data.attributes.temperature + \" degrees. Have a great walk you two\"}};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":870,"y":640,"wires":[["b327215b.d6c9e"]]},{"id":"7d21809c.cdedb8","type":"api-current-state","z":"b66e483.15a8eb8","name":"Current Weather Conditions","server":"41c2e4cc.1954cc","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"weather.ecobee4_thermostat","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":220,"y":440,"wires":[["335737ad.1a0418"]]},{"id":"271665df.9bdc6a","type":"inject","z":"b66e483.15a8eb8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":380,"wires":[["7d21809c.cdedb8"]]},{"id":"b327215b.d6c9e","type":"debug","z":"b66e483.15a8eb8","name":"Off to Alexa to read back >>","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1360,"y":440,"wires":[]},{"id":"41c2e4cc.1954cc","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]