At the beginning I found these posts about people sharing their flows very useful. So here I am sharing a few automations I created recently. I Believe these can give you some ideas also I would be really happy to see some suggestions from you, to improve mines. I learnt there are many ways to achieve a goal in Node Red and there can be faster/easier ways to do it.
Sensor: moving
the new HA android companion is now reporting the speed. Based on this information, I created a sensor showing if I am moving or not_moving. I don’t know what exactly I am going to do it right now but I will come up with something…
[{"id":"b77629a0.dfb2c8","type":"trigger-state","z":"9dcc9ab2.d57aa8","name":"serkan's speed","server":"e447d17a.16a64","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.serkan_speed","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"num","x":110,"y":420,"wires":[["4b426ca.f6ecc94"],[]]},{"id":"e447d17a.16a64","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
GIF from Snapshots
I am using wall panel’s camera as generic mjpeg camera but that integration doesn’t support recording (or I don’t know how to do it). So I find a way to save snapshots as a gif file with the help of animate-gif node.
when the alarm is armed, movement at the front_door movement sensor triggers the taking snapshots service, loads jpg files as buffer, converts them to gif and saves to www folder.
[{"id":"44f332b8.4a7c6c","type":"trigger-state","z":"5b8207c0.dcb8c8","name":"front door motion","server":"e447d17a.16a64","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.front_door_sensor_motion","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"62r1m87tqi6","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":110,"y":720,"wires":[["336ccd1f.8e7ca2"],[]]},{"id":"336ccd1f.8e7ca2","type":"api-current-state","z":"5b8207c0.dcb8c8","name":"armed away?","server":"e447d17a.16a64","version":1,"outputs":2,"halt_if":"armed_away","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"alarm_control_panel.ha_alarm","state_type":"str","state_location":"data.state","override_payload":"msg","entity_location":"data.entity","override_data":"msg","blockInputOverrides":false,"x":320,"y":720,"wires":[["5be687d4.8256a8","5c29f73e.5bd238"],[]]},{"id":"fdc31b63.99c958","type":"api-call-service","z":"5b8207c0.dcb8c8","name":"snapshots","server":"e447d17a.16a64","version":1,"debugenabled":false,"service_domain":"camera","service":"snapshot","entityId":"camera.wp_entrance_camera","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":850,"y":720,"wires":[["153ed262.4adb9e"]]},{"id":"1f62e7c3.0e5f68","type":"change","z":"5b8207c0.dcb8c8","name":"file names","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.data.filename","pt":"msg","to":"'/config/www/snapshots/temp/snapshot_' & $now() & '.jpg'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":720,"wires":[["fdc31b63.99c958"]]},{"id":"5be687d4.8256a8","type":"looptimer","z":"5b8207c0.dcb8c8","duration":"1","units":"Second","maxloops":"30","maxtimeout":"3","maxtimeoutunits":"Minute","name":"","x":500,"y":720,"wires":[["1f62e7c3.0e5f68"],["42c0131a.99601c"]]},{"id":"a61636f4.160728","type":"animate-gif","z":"5b8207c0.dcb8c8","delay":"1000","dimensionX":"640","dimensionY":"480","quality":"50","repeat":false,"x":750,"y":840,"wires":[["1d668d26.aa9313","b1b257e0.4185e8"]]},{"id":"3b3fb307.99d81c","type":"file in","z":"5b8207c0.dcb8c8","name":"buffer them","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":1150,"y":720,"wires":[["cfe26649.15eef8"]]},{"id":"1505e200.fe18ee","type":"join","z":"5b8207c0.dcb8c8","name":"make array","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":590,"y":840,"wires":[["a61636f4.160728"]]},{"id":"153ed262.4adb9e","type":"change","z":"5b8207c0.dcb8c8","name":"filename","rules":[{"t":"move","p":"payload.data.filename","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":720,"wires":[["3b3fb307.99d81c"]]},{"id":"adcc3d4f.2865f","type":"file","z":"5b8207c0.dcb8c8","name":"save gif","filename":"","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":1080,"y":840,"wires":[[]]},{"id":"42c0131a.99601c","type":"change","z":"5b8207c0.dcb8c8","name":"loop ended","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"complete","pt":"msg","to":"complete","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":760,"wires":[["cfe26649.15eef8"]]},{"id":"1d668d26.aa9313","type":"change","z":"5b8207c0.dcb8c8","name":"new file","rules":[{"t":"set","p":"filename","pt":"msg","to":"'/config/www/snapshots/recording_' & $now() & '.gif'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":840,"wires":[["adcc3d4f.2865f"]]},{"id":"5c29f73e.5bd238","type":"api-call-service","z":"5b8207c0.dcb8c8","name":"turn on the light","server":"e447d17a.16a64","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.entrance","data":"{\"brightness\":255}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":500,"y":680,"wires":[[]]},{"id":"b1b257e0.4185e8","type":"file","z":"5b8207c0.dcb8c8","name":"save latest footage","filename":"/config/www/last_footage.gif","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":970,"y":880,"wires":[[]]},{"id":"cfe26649.15eef8","type":"link out","z":"5b8207c0.dcb8c8","name":"footage","links":["71012e8c.75d0b"],"x":1275,"y":760,"wires":[]},{"id":"71012e8c.75d0b","type":"link in","z":"5b8207c0.dcb8c8","name":"footage","links":["cfe26649.15eef8"],"x":475,"y":840,"wires":[["1505e200.fe18ee"]]},{"id":"e447d17a.16a64","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
Additional Glances Info
Glances integration updated recently and now reports many more information but still somethings are missing. So I created my sensors using rest api nodes and calling Glances’ Api. This one shows me the uptime and disk size of RAID setup.
[{"id":"2039c6fe.11579a","type":"inject","z":"9a5e9cb4.3f28a","name":"","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":160,"wires":[["cb7a5a68.bbe2c8","eaf05cc.cb2a8a","6663bb13.c9b734","f4813862.11b768"]]},{"id":"cb7a5a68.bbe2c8","type":"http request","z":"9a5e9cb4.3f28a","name":"uptime server","method":"GET","ret":"obj","paytoqs":false,"url":"192.168.178.31:61208/api/3/uptime","tls":"","persist":false,"proxy":"","authType":"","x":340,"y":100,"wires":[["e66a6b9.c2a7f98"]]},{"id":"eaf05cc.cb2a8a","type":"http request","z":"9a5e9cb4.3f28a","name":"uptime raspi","method":"GET","ret":"obj","paytoqs":false,"url":"192.168.178.250:61208/api/3/uptime","tls":"","persist":false,"proxy":"","authType":"","x":330,"y":140,"wires":[["604169ae.d958c8"]]},{"id":"5ca10d33.8bbfe4","type":"join","z":"9a5e9cb4.3f28a","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"host","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":710,"y":120,"wires":[["212a55e5.64890a","def8bf3f.484ed"]]},{"id":"e66a6b9.c2a7f98","type":"change","z":"9a5e9cb4.3f28a","name":"host","rules":[{"t":"set","p":"host","pt":"msg","to":"server","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":100,"wires":[["5ca10d33.8bbfe4"]]},{"id":"604169ae.d958c8","type":"change","z":"9a5e9cb4.3f28a","name":"host","rules":[{"t":"set","p":"host","pt":"msg","to":"raspi","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":140,"wires":[["5ca10d33.8bbfe4"]]},{"id":"212a55e5.64890a","type":"mqtt out","z":"9a5e9cb4.3f28a","name":"","topic":"sensor/uptime","qos":"","retain":"true","broker":"ea336ecd.70b63","x":920,"y":120,"wires":[]},{"id":"def8bf3f.484ed","type":"debug","z":"9a5e9cb4.3f28a","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":890,"y":80,"wires":[]},{"id":"1b7af9ca.355e96","type":"debug","z":"9a5e9cb4.3f28a","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1070,"y":180,"wires":[]},{"id":"f4813862.11b768","type":"http request","z":"9a5e9cb4.3f28a","name":"nas fs","method":"GET","ret":"obj","paytoqs":false,"url":"192.168.178.250:61208/api/3/fs","tls":"","persist":false,"proxy":"","authType":"","x":310,"y":180,"wires":[["83dc6a22.f96408"]]},{"id":"6663bb13.c9b734","type":"http request","z":"9a5e9cb4.3f28a","name":"nas raid","method":"GET","ret":"obj","paytoqs":false,"url":"192.168.178.250:61208/api/3/raid","tls":"","persist":false,"proxy":"","authType":"","x":320,"y":220,"wires":[["61bf294.10823d8"]]},{"id":"83dc6a22.f96408","type":"split","z":"9a5e9cb4.3f28a","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":470,"y":180,"wires":[["cc4cf054.1a5a4"]]},{"id":"cc4cf054.1a5a4","type":"switch","z":"9a5e9cb4.3f28a","name":"","property":"payload.mnt_point","propertyType":"msg","rules":[{"t":"eq","v":"/mnt/raid1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":180,"wires":[["2e8dc448.f60a6c"]]},{"id":"61bf294.10823d8","type":"join","z":"9a5e9cb4.3f28a","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":930,"y":220,"wires":[["1b7af9ca.355e96","c847f8e.99ac408"]]},{"id":"c847f8e.99ac408","type":"mqtt out","z":"9a5e9cb4.3f28a","name":"","topic":"sensor/raid","qos":"","retain":"true","broker":"ea336ecd.70b63","x":1090,"y":220,"wires":[]},{"id":"2e8dc448.f60a6c","type":"change","z":"9a5e9cb4.3f28a","name":"convert to GB","rules":[{"t":"set","p":"payload.free","pt":"msg","to":"$round(payload.free / 1073741824, 2)","tot":"jsonata"},{"t":"set","p":"payload.size","pt":"msg","to":"$round(payload.size / 1073741824, 2)","tot":"jsonata"},{"t":"set","p":"payload.used","pt":"msg","to":"$round(payload.used / 1073741824, 2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":180,"wires":[["61bf294.10823d8"]]},{"id":"ea336ecd.70b63","type":"mqtt-broker","z":"","name":"home mqtt","broker":"192.168.178.31","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Another Rest Api node for alphavantage
The integration is little bit limited, so I am directly calling alphavantage’s Rest Api
[{"id":"cfe7806f.79a6d","type":"inject","z":"d91fca12.82c308","name":"","topic":"","payload":"{\"auth_code\":\"def502008faa6a2eb2e4c9e26a38884e1d81d5c87a7086eb33b3b225a055391d7a4a3e277065e8bd4e98c12ea1b63d3aa1013b19e208ddb2512ce7cca5109748338ef5a1925ada48df0b67bb0e40f0c1a31440e74197189ee93ea854f7b89b9d34d2554f031e6a61b745dadb29060bf44557bbf012dbbe1d8fdd9457d2197630dd7854fc6dced9a66819128364dc2d86a52bb2957f12591b9caf876639ff00250400bc6e1a509631a1f9529daeca1fdf627ac51725f49bd240acf07121f5d53017b87e0ae95cd065270025b0e0660cc30366b7c46e56adaff1be0c10ce1b5d833d34e9fa59c02635794e82c02f5b8f8184b7fd6597279eb788756ac5c7c130e4a66ee41904af06d3faade65965869d32a5c19fe2f3ccd68880b50fd10788f0f86bda6e6751b133b489dcccd6f5ef10adca36653a3bf6249e476c5fad92386bdb8d63cb02acf59a033c803b570339365996c4bf050586fbf4731f85225d623315a908a243d1d3f66fe7b93783503c24339fbeff937a4cd5\"}","payloadType":"json","repeat":"","crontab":"*/5 8-16 * * 1,2,3,4,5","once":false,"onceDelay":0.1,"x":90,"y":100,"wires":[["72619bf6.2fd784","a4c75059.4032f","c06611a7.08444"]]},{"id":"ab5b0181.34233","type":"change","z":"d91fca12.82c308","name":"remove space","rules":[{"t":"change","p":"payload","pt":"msg","from":". ","fromt":"str","to":"_","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":" ","fromt":"str","to":"_","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":60,"wires":[["d7c0f27a.05b3d"]]},{"id":"de012266.8dab8","type":"json","z":"d91fca12.82c308","name":"to String","property":"payload","action":"str","pretty":false,"x":400,"y":60,"wires":[["ab5b0181.34233"]]},{"id":"d7c0f27a.05b3d","type":"json","z":"d91fca12.82c308","name":"to Object","property":"payload","action":"obj","pretty":false,"x":720,"y":60,"wires":[["62ba3e76.c805e"]]},{"id":"62ba3e76.c805e","type":"change","z":"d91fca12.82c308","name":"move to payload","rules":[{"t":"move","p":"payload.Global_Quote","pt":"msg","to":"KNIN","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"KNIN.05_price","pt":"msg","to":"payload.KNIN","tot":"msg"},{"t":"move","p":"KNIN","pt":"msg","to":"payload.KNIN_attr","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":60,"wires":[["2bc5074b.cc2668"]]},{"id":"a4c75059.4032f","type":"http request","z":"d91fca12.82c308","name":"get USD rate","method":"GET","ret":"obj","paytoqs":false,"url":"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=TRY&apikey=G9NVVLV4YX36C799","tls":"","persist":false,"proxy":"","authType":"","x":250,"y":100,"wires":[["263929ad.a2bf36"]]},{"id":"46d79d11.d23f74","type":"change","z":"d91fca12.82c308","name":"remove space","rules":[{"t":"change","p":"payload","pt":"msg","from":". ","fromt":"str","to":"_","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":" ","fromt":"str","to":"_","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":100,"wires":[["a8ac1270.96d9f"]]},{"id":"263929ad.a2bf36","type":"json","z":"d91fca12.82c308","name":"to String","property":"payload","action":"str","pretty":false,"x":400,"y":100,"wires":[["46d79d11.d23f74"]]},{"id":"a8ac1270.96d9f","type":"json","z":"d91fca12.82c308","name":"to Object","property":"payload","action":"obj","pretty":false,"x":720,"y":100,"wires":[["e2c72ed8.c1dd9"]]},{"id":"e2c72ed8.c1dd9","type":"change","z":"d91fca12.82c308","name":"move to payload","rules":[{"t":"move","p":"payload.Realtime_Currency_Exchange_Rate","pt":"msg","to":"USDTRY","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"USDTRY.5_Exchange_Rate","pt":"msg","to":"payload.USDTRY","tot":"msg"},{"t":"move","p":"USDTRY","pt":"msg","to":"payload.USDTRY_attr","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":100,"wires":[["2bc5074b.cc2668"]]},{"id":"2bc5074b.cc2668","type":"join","z":"d91fca12.82c308","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"10","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1050,"y":100,"wires":[["22ccc08e.8f7da"]]},{"id":"c06611a7.08444","type":"http request","z":"d91fca12.82c308","name":"get EUR Rate","method":"GET","ret":"obj","paytoqs":false,"url":"https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=EUR&to_currency=TRY&apikey=G9NVVLV4YX36C799","tls":"","persist":false,"proxy":"","authType":"","x":240,"y":140,"wires":[["abf0f580.432df8"]]},{"id":"71fba27.50ced5c","type":"change","z":"d91fca12.82c308","name":"remove space","rules":[{"t":"change","p":"payload","pt":"msg","from":". ","fromt":"str","to":"_","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":" ","fromt":"str","to":"_","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":140,"wires":[["6ad553a5.0f8bec"]]},{"id":"abf0f580.432df8","type":"json","z":"d91fca12.82c308","name":"to String","property":"payload","action":"str","pretty":false,"x":400,"y":140,"wires":[["71fba27.50ced5c"]]},{"id":"6ad553a5.0f8bec","type":"json","z":"d91fca12.82c308","name":"to Object","property":"payload","action":"obj","pretty":false,"x":720,"y":140,"wires":[["472e070c.d054a8"]]},{"id":"472e070c.d054a8","type":"change","z":"d91fca12.82c308","name":"move to payload","rules":[{"t":"move","p":"payload.Realtime_Currency_Exchange_Rate","pt":"msg","to":"EURTRY","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"EURTRY.5_Exchange_Rate","pt":"msg","to":"payload.EURTRY","tot":"msg"},{"t":"move","p":"EURTRY","pt":"msg","to":"payload.EURTRY_attr","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":140,"wires":[["2bc5074b.cc2668"]]},{"id":"72619bf6.2fd784","type":"http request","z":"d91fca12.82c308","name":"get KNIN price","method":"GET","ret":"obj","paytoqs":false,"url":"https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=MSF&apikey=G9NVVLV4YX36C799","tls":"","persist":false,"proxy":"","authType":"","x":240,"y":60,"wires":[["de012266.8dab8"]]},{"id":"22ccc08e.8f7da","type":"mqtt out","z":"d91fca12.82c308","name":"","topic":"sensor/alphavantage","qos":"","retain":"true","broker":"ea336ecd.70b63","x":1220,"y":100,"wires":[]},{"id":"ea336ecd.70b63","type":"mqtt-broker","z":"","name":"home mqtt","broker":"192.168.178.31","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
That’s all for the moment.
Cheers.