Displaying "last changed" from a different entity

I’m trying to have a a vacuum automation toggle (so auto-cleaning can be overridden) with a secondary row displaying the vacuum entity’s “last changed” attribute.

I’m using Canary to get a secondary info row to display a different entity’s attributes with this:

  - entity: automation.vacuum_cleanup_if_nobody_is_home
    icon: phu:roborock
    name: Vacuum if nobody home
    secondary_info:
      entity: vacuum.xiaomi_vacuum_cleaner
      attribute: clean_stop #this is the vacuum entity's attribute with last cleanup

That gives me this:
Screenshot 2021-09-28 at 22.35.11
Which is an absolute date/time of the last cleanup. That’s something but I’d love to have “xxx days/hourse/whatever ago”.

Basically i want a “last changed” attribute (that works fine when I’m just using the vacuum entity card but not when I’m trying to have two different entities - the automation and the vacuum - on the same card). When i tried “attribute: last-changed” in the above script, that didn’t work.

Or, at least, how do I clean this up so it just shows a date? I tried reading up on templates but as a non-programmer, it goes right over my head. Thanks!

I’m on my cellphone, so it’s not very easy to reply, but look for relative_time on the forum, you’ll find how to do it.

Thank you. It’s pages and pages of contradictory info, as a non-developer it’s too much for me. I can’t figure it out. I’ll just not have that info on my lovelace, no big deal :slight_smile:

This is the template I’m using. Replace the name of the website and you should be good to go…

{{ (relative_time(as_datetime(state_attr('sensor.0x00158d0003cef8cf_temperature',
      'last_seen'))))  }} ago

Thank you but I can’t get it to work. I just can’t work with templates. With

{{ (relative_time(as_datetime(state_attr('vacuum.xiaomi_vacuum_cleaner','clean_stop'))))  }} ago

Lovelace editor gives me

missed comma between flow collection entries (34:105)

34 is the line with the template.

Anyone can help?