# HomeAssistant History in Function

**URL:** <https://discourse.nodered.org/t/homeassistant-history-in-function/44657>\
**Category:** General\
**Created:** [24 April 2021 13:47 UTC](https://discourse.nodered.org/t/homeassistant-history-in-function/44657 "2021-04-24T13:47:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PrayerfulDrop](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/prayerfuldrop/32/24073_2.png) [@PrayerfulDrop](https://discourse.nodered.org/u/PrayerfulDrop)\
**Post date:** [24 April 2021 13:47 UTC](https://discourse.nodered.org/t/homeassistant-history-in-function/44657/1 "2021-04-24T13:47:27Z")

</div>

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?

```auto

[{"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}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 June 2021 13:47 UTC](https://discourse.nodered.org/t/homeassistant-history-in-function/44657/2 "2021-06-23T13:47:43Z")

</div>

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