HomeAssistant History in Function

I deeply apologize about the n00bie request but I cannot find anywhere on how to acquire the history array to determine last changed state of a person within a function. I have figured out how to use the HA websocket api-get-history as a node but I need to do the same within a function for multiple persons/devices. Can someone guide me on how to do this?


[{"id":"9e21ba5b.c58628","type":"inject","z":"f0fecdf0.b4cc9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":380,"wires":[["e4f3856b.c67928"]]},{"id":"e4f3856b.c67928","type":"api-get-history","z":"f0fecdf0.b4cc9","name":"Person","server":"f4c3f22d.c5133","startdate":"","enddate":"","entityid":"person.aaron","entityidtype":"is","useRelativeTime":false,"relativeTime":"","flatten":true,"output_type":"array","output_location_type":"msg","output_location":"payload","x":280,"y":260,"wires":[["3f073ad5.cefb76","fcb691ec.48db7"]]},{"id":"3f073ad5.cefb76","type":"change","z":"f0fecdf0.b4cc9","name":"send stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].last_changed","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":200,"wires":[["fcb691ec.48db7"]]},{"id":"fcb691ec.48db7","type":"debug","z":"f0fecdf0.b4cc9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":140,"wires":[]},{"id":"4bf50d6c.ce5b44","type":"function","z":"f0fecdf0.b4cc9","name":"","func":"const haCtx = global.get(\"homeassistant\");\nconst configCtx = haCtx.homeAssistant;\n\nconst aaron = configCtx.states[\"person.aaron\"].last_updated;\nmsg=aaron;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":380,"wires":[["fcb691ec.48db7"]]},{"id":"f4c3f22d.c5133","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.