Node-red flow to use an anemometer as trigger for homebridge

Using an anemometer on Raspberry GPIO 05 (32) and Ground pins, activate ou de activate any Homebridge accessories.

Thanks to Raspberry weather station project, NorthernMan54 project (https://github.com/NorthernMan54/node-red-contrib-homebridge-automation) and Bicycle speedometer and Test Flow (https://flows.nodered.org/flow/6eb0a6ca6474b163d54b8d2488e973f2).

This flow will allow me to retract an automatic motorized awning when wind speeds gets to XX km/h, hope it'll be useful for someone else.

"Speed Calculator" should be setup with your anemometer radius.

[{"id":"873552cf.634818","type":"tab","label":"Anemometro","disabled":false,"info":""},{"id":"7c1d1240.12417c","type":"debug","z":"873552cf.634818","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1190,"y":260,"wires":[]},{"id":"342676f4.a7281a","type":"function","z":"873552cf.634818","name":"rpm","func":"var x = msg.payload;\nvar rev = (60000/x);\nvar msg1 = {payload:rev};\nreturn msg1;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":340,"wires":[["2db502f0.871366"]]},{"id":"2db502f0.871366","type":"function","z":"873552cf.634818","name":"speed calculator","func":"var rpm = msg.payload;\nvar radius = 10;\nvar cm_in_km = 100000.0;\nvar sec_in_an_hour = 3600;\nvar circumference_cm = (2* 3.1415926535) * radius;\n\nvar dist_km =  (circumference_cm * rpm )/ cm_in_km;\nvar km_per_sec =dist_km /3600; \nvar km_per_hour = (km_per_sec * sec_in_an_hour * 1.8);\nvar msg1 = {payload: km_per_hour};\n\nreturn msg1;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":790,"y":340,"wires":[["7ec4a542.d2bd14","7e5940e5.b3075","7d884e9a.3e8428"]]},{"id":"3da9b475.60d0f4","type":"interval-length","z":"873552cf.634818","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"1","minimumunit":"msecs","maximumunit":"secs","windowunit":"msecs","msgTimeoutUnit":"secs","reset":false,"startup":false,"msgField":"payload","timestampField":"timestamp","repeatTimeout":false,"name":"","x":440,"y":340,"wires":[["342676f4.a7281a"],[]]},{"id":"7e5940e5.b3075","type":"ui_gauge","z":"873552cf.634818","name":"","group":"df423369.1e76","order":1,"width":"4","height":"4","gtype":"gage","title":"Speed","label":"KM/H","format":"{{value | number:1 }}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"35","seg2":"50","x":1010,"y":340,"wires":[]},{"id":"261b8dfc.65b69a","type":"debug","z":"873552cf.634818","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1670,"y":340,"wires":[]},{"id":"efe4c15b.52cb7","type":"rpi-gpio in","z":"873552cf.634818","name":"Wheel Sensor","pin":"29","intype":"up","debounce":"1","read":true,"x":250,"y":340,"wires":[["3da9b475.60d0f4"]]},{"id":"7ec4a542.d2bd14","type":"delay","z":"873552cf.634818","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"4","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1040,"y":420,"wires":[["4b9401fe.16ca48"]]},{"id":"9e114b07.fdd888","type":"hb-control","z":"873552cf.634818","name":"Corredor SW2","Homebridge":"Homebridge rPi4","Manufacturer":"Sonoff","Service":"Lightbulb","device":"Homebridge rPi40E:8C:21:EC:D4:ADSonoffCorredor SW200000043","conf":"1b9891c.58cb36e","x":1680,"y":420,"wires":[]},{"id":"95500a9a.a9b24","type":"inject","z":"873552cf.634818","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"On\":true} ","payloadType":"json","x":1360,"y":360,"wires":[["9e114b07.fdd888","261b8dfc.65b69a"]]},{"id":"7ad92a6f.147e14","type":"inject","z":"873552cf.634818","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"on\":\"false\"} ","payloadType":"json","x":1350,"y":480,"wires":[["9e114b07.fdd888","261b8dfc.65b69a"]]},{"id":"584c8834.6e2ad","type":"change","z":"873552cf.634818","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"on\": true} ","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":420,"wires":[["9e114b07.fdd888"]]},{"id":"4b9401fe.16ca48","type":"switch","z":"873552cf.634818","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"1.5","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":420,"wires":[["584c8834.6e2ad"]]},{"id":"7d884e9a.3e8428","type":"delay","z":"873552cf.634818","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1040,"y":260,"wires":[["7c1d1240.12417c"]]},{"id":"df423369.1e76","type":"ui_group","z":"","name":"Bicycle Crank and Wheel Sensors","tab":"b12ebccc.218e98","order":1,"disp":true,"width":"12","collapse":false},{"id":"1b9891c.58cb36e","type":"hb-conf","z":"","username":"688-21-899"},{"id":"b12ebccc.218e98","type":"ui_tab","z":"","name":"Speedometer and RPM Test Project","icon":"dashboard","disabled":false,"hidden":false}]

Flow Info

Created 4 years, 11 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x1)
  • debug (x2)
  • delay (x2)
  • function (x2)
  • inject (x2)
  • switch (x1)
Other

Tags

  • wind
  • anemometer
  • homebridge
  • trigger
  • gpio
  • windspeed
  • speed
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option