Skip to content

Instantly share code, notes, and snippets.

@GuySie
Last active January 21, 2023 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GuySie/10be467734bbffc4f938479fe539964d to your computer and use it in GitHub Desktop.
Save GuySie/10be467734bbffc4f938479fe539964d to your computer and use it in GitHub Desktop.
NodeRED - Dynamic sensors for Home Assistant Apple Watch Buienradar + Buienalarm Complication
[{"id":"7a281822.950da8","type":"change","z":"7ce23c23.7ea124","name":"Get location data to 2 decimals","rules":[{"t":"set","p":"latitude","pt":"msg","to":"$round(data.attributes.latitude, 2)","tot":"jsonata"},{"t":"set","p":"longitude","pt":"msg","to":"$round(data.attributes.longitude, 2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":100,"wires":[["f2faa1b4.b7939"]]},{"id":"a080c47a.c59908","type":"http request","z":"7ce23c23.7ea124","name":"Get Buienradar data","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://gpsgadget.buienradar.nl/data/raintext?lat={{{latitude}}}&lon={{{longitude}}}&c={{{random}}}","tls":"","persist":false,"proxy":"","authType":"","x":920,"y":100,"wires":[["6d1cadcf19a2edfd"]]},{"id":"f2faa1b4.b7939","type":"random","z":"7ce23c23.7ea124","name":"Add random number","low":1,"high":"999999999999999","inte":"true","property":"random","x":700,"y":100,"wires":[["a080c47a.c59908"]]},{"id":"f42baf1e.07df","type":"poll-state","z":"7ce23c23.7ea124","name":"Get Guy's data every 3 minutes","server":"","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"3","updateIntervalType":"num","updateIntervalUnits":"minutes","outputinitially":false,"outputonchanged":false,"entity_id":"person.guy","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":150,"y":100,"wires":[["7a281822.950da8","1d9cd395.ff023c"]]},{"id":"b035056e.17dc18","type":"http request","z":"7ce23c23.7ea124","name":"Get Buienalarm data","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://cdn-secure.buienalarm.nl/api/3.4/forecast.php?lat={{{latitude}}}&lon={{{longitude}}}&region=nl&unit=mm%2Fu&c={{{random}}}","tls":"","persist":false,"proxy":"","authType":"","x":920,"y":160,"wires":[["9c92573c.2f33f8"]]},{"id":"9c92573c.2f33f8","type":"json","z":"7ce23c23.7ea124","name":"Parse JSON","property":"payload","action":"","pretty":false,"x":1110,"y":160,"wires":[["a028348170fdc13d"]]},{"id":"1d9cd395.ff023c","type":"change","z":"7ce23c23.7ea124","name":"Get location data to 3 decimals","rules":[{"t":"set","p":"latitude","pt":"msg","to":"$round(data.attributes.latitude, 3)","tot":"jsonata"},{"t":"set","p":"longitude","pt":"msg","to":"$round(data.attributes.longitude, 3)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":160,"wires":[["fa8601c9.4e8dc"]]},{"id":"fa8601c9.4e8dc","type":"random","z":"7ce23c23.7ea124","name":"Add random number","low":1,"high":"999999999999999","inte":"true","property":"random","x":700,"y":160,"wires":[["b035056e.17dc18"]]},{"id":"6d1cadcf19a2edfd","type":"ha-sensor","z":"7ce23c23.7ea124","name":"Buienradar sensor","entityConfig":"882f36a5.86dfc8","version":0,"state":"Success","stateType":"str","attributes":[{"property":"data","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1290,"y":100,"wires":[[]]},{"id":"a028348170fdc13d","type":"ha-sensor","z":"7ce23c23.7ea124","name":"Buienalarm sensor","entityConfig":"b142b1eb.0730c","version":0,"state":"Success","stateType":"str","attributes":[{"property":"data","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1290,"y":160,"wires":[[]]},{"id":"882f36a5.86dfc8","type":"ha-entity-config","server":"8b4b8e88.90a08","deviceConfig":"","name":"sensor config for Buienradar sensor","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"NodeRed Rain Buienradar"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"b142b1eb.0730c","type":"ha-entity-config","server":"8b4b8e88.90a08","deviceConfig":"","name":"sensor config for Buienalarm sensor","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"NodeRed Rain Buienalarm"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true}]
@GuySie
Copy link
Author

GuySie commented Jan 21, 2023

Code updated on 21 jan 2023 because original code started causing "ValidationError: "state" is not allowed to be empty" error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment