How can I load the last time a person was seen at home to an input_datetime entitiy? Hoping for example

Hello all,

Could someone possibly show me an example of how to do the attached? Below is my entity I would like to contain this information.

I have a person called person.weston that would contain this information.

Thank you all for any guidance you can give me on this one!!

input_datetime:
  last_time_home_weston:
    name: Weston Last Seen
    has_date: true
    has_time: true

Trigger when the person entity’s state changes from home, then execute the input_datetime.set_datetime action. There are examples in the Input Datetime docs showing how to dynamically set the value (either of the last two examples will work for your case).

I am doing that for some of my automations where I set datetime when something triggers it.

action: input_datetime.set_datetime
target:
  entity_id: input_datetime.last_time_home_weston
data:
  datetime: >-
    {{ now() | as_timestamp | timestamp_local  }}

Trigger could be for example state trigger when person.weston changes state from home to not_home

@Didgeridrew @stomko thank you all for the education on this, the links, and the example. Very appreciative of you all’s time!!