Hi
Now that Christmas is approaching I found it would be nice to show the kids what Santa is up to at the moment. So I made a a little automation that randomly send a virtual device tracker around lapland.
The automation it self is made in node red, but with a little helper entities in home assistant.
Destinations are randomized, and their locations made by zones. Easy to modify for your own needs.
Feel free to use, and feel free to suggest further improvements.
Source code for node red:
[{"id":"cb7347efacc6d2a5","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination Treriksröset","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.treriksroset","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":500,"wires":[["71543613d91668a4"]]},{"id":"bed2238890c8ccdc","type":"debug","z":"dd93e6866f5cb769","name":"debug 3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1720,"y":480,"wires":[]},{"id":"89dc58f1b63ebd75","type":"random","z":"dd93e6866f5cb769","name":"","low":1,"high":"8","inte":"true","property":"payload","x":220,"y":580,"wires":[["6c9c659e997e1973"]]},{"id":"41581f3161f3362c","type":"server-state-changed","z":"dd93e6866f5cb769","name":"Go santa","server":"aa915ced.e4587","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.go_santa","entityidfiltertype":"exact","outputinitially":false,"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"}],"x":80,"y":580,"wires":[["89dc58f1b63ebd75"]]},{"id":"6c9c659e997e1973","type":"switch","z":"dd93e6866f5cb769","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"5","vt":"num"},{"t":"eq","v":"6","vt":"num"},{"t":"eq","v":"7","vt":"num"},{"t":"eq","v":"8","vt":"num"},{"t":"eq","v":"9","vt":"num"},{"t":"eq","v":"10","vt":"num"}],"checkall":"true","repair":false,"outputs":10,"x":350,"y":580,"wires":[["8f76f1be72b5075d"],["8f6425ea6d5cb8a3"],["cb7347efacc6d2a5"],["dc9b57470f0ef35f"],["39c151445354e21d"],["230a6cc0a3eded11"],["23b5fbb977c3aff3"],["f6fb471ad234c26d"],[],[]]},{"id":"dc9b57470f0ef35f","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination Santas Village","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.santa_claus","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":540,"wires":[["71543613d91668a4"]]},{"id":"39c151445354e21d","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination Korvatunturi","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.korvatunturi","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":580,"wires":[["71543613d91668a4"]]},{"id":"230a6cc0a3eded11","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination Tromsö","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.tromso","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":620,"wires":[["71543613d91668a4"]]},{"id":"23b5fbb977c3aff3","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination Ruka","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.ruka","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":660,"wires":[["71543613d91668a4"]]},{"id":"f6fb471ad234c26d","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination North Cape","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.north_cape","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":700,"wires":[["71543613d91668a4"]]},{"id":"8f6425ea6d5cb8a3","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination Ylläs","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.yllas","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":570,"y":460,"wires":[["71543613d91668a4"]]},{"id":"8f76f1be72b5075d","type":"api-current-state","z":"dd93e6866f5cb769","name":"Destination Alko","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.alko_rovaniemi","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":560,"y":420,"wires":[["71543613d91668a4"]]},{"id":"71543613d91668a4","type":"api-current-state","z":"dd93e6866f5cb769","name":"Where am I","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"device_tracker.santa_claus","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"start","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":890,"y":560,"wires":[["ebf648537c3f36eb","a4e376eee6431024","bef70796208f1432"]]},{"id":"e07271f56a4ea65c","type":"function","z":"dd93e6866f5cb769","name":"From A to B","func":"// Flow context variables\nvar startLat = flow.get(\"start.attributes.latitude\");\nvar startLon = flow.get(\"start.attributes.longitude\");\n\nvar destinationtLat = flow.get(\"destination.attributes.latitude\");\nvar destinationtLon = flow.get(\"destination.attributes.longitude\");\n\nvar offset = msg.offset;\nvar percent = msg.payload.brightness_pct;\n\nvar currentLat = (destinationtLat - startLat) * percent * 0.01 + startLat + offset;\nvar currentLon = (destinationtLon - startLon) * percent * 0.01 + startLon + offset;\n\n//Make string of current gps position\nvar gps = `${currentLat}, ${currentLon}`;\n\nmsg.payload = gps;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1490,"y":560,"wires":[["9f6eeb901260f48d","bed2238890c8ccdc"]]},{"id":"ebf648537c3f36eb","type":"light-transition","z":"dd93e6866f5cb769","name":"","startRGB":"#ff0000","transitionRGB":"#ffc864","endRGB":"#ffffff","startMired":"","endMired":"","transitionTime":"5","transitionTimeUnits":"Minute","steps":"30","startBright":"1","endBright":"100","brightnessType":"Percent","transitionType":"Linear","colorTransitionType":"None","x":1110,"y":560,"wires":[["35ecdd32f2723ccf"],[]]},{"id":"9f6eeb901260f48d","type":"api-call-service","z":"dd93e6866f5cb769","name":"Update GPS position","server":"aa915ced.e4587","version":5,"debugenabled":false,"domain":"device_tracker","service":"see","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"dev_id\":\"santa_claus\",\t \"gps\":[{{payload}}]\t}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1720,"y":560,"wires":[[]]},{"id":"a4e376eee6431024","type":"change","z":"dd93e6866f5cb769","name":"","rules":[{"t":"move","p":"destination","pt":"msg","to":"destination","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":620,"wires":[[]]},{"id":"bef70796208f1432","type":"change","z":"dd93e6866f5cb769","name":"","rules":[{"t":"move","p":"start","pt":"msg","to":"start","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":660,"wires":[[]]},{"id":"444636defd7270ea","type":"comment","z":"dd93e6866f5cb769","name":"Travel upon button click, random destination","info":"","x":210,"y":360,"wires":[]},{"id":"e7e0bd667c2b5d6b","type":"inject","z":"dd93e6866f5cb769","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"00 16 * * 5","once":false,"onceDelay":0.1,"topic":"","payload":"friday","payloadType":"str","x":110,"y":420,"wires":[["8f76f1be72b5075d"]]},{"id":"c0111c858ea75c09","type":"api-current-state","z":"dd93e6866f5cb769","name":"Coming home for X-mas","server":"aa915ced.e4587","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"zone.home","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"destination","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":590,"y":780,"wires":[["71543613d91668a4"]]},{"id":"f1550e2831decf16","type":"inject","z":"dd93e6866f5cb769","d":true,"name":"Get home","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"go","payloadType":"str","x":120,"y":780,"wires":[["c0111c858ea75c09"]]},{"id":"7a0cb760de8c4948","type":"inject","z":"dd93e6866f5cb769","name":"","props":[{"p":"payload"}],"repeat":"28800","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"go","payloadType":"str","x":90,"y":540,"wires":[["89dc58f1b63ebd75"]]},{"id":"35ecdd32f2723ccf","type":"random","z":"dd93e6866f5cb769","name":"random offset","low":"0","high":"0.05","inte":"false","property":"offset","x":1320,"y":560,"wires":[["e07271f56a4ea65c"]]},{"id":"aa915ced.e4587","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}]