At each motion event the event time and the motion sensor’s friendly name is inserted at the beginning of input_text.last_motions separated with a special character from the rest allowing to transform the string into a list of event-time - sensor-name pairs.
On the lovelace-UI the string is rendered using a markdown card like this:
- type: markdown
title: Last five motions...
content: "{{ states('input_text.last_motions') | replace('|', '\n') }}"
The markdown card could be combined with a conditional card which could display the markdown content only if the last_changed time of the input_text is not older than n minutes (implemented in a form of a template binary sensor).
That’s a superb solution! In case of somebody is interested in getting the timezone correct as well for the triggers (as it’s UTC otherwise), just have the newItem defined as: newItem = trigger.to_state.last_changed.astimezone().strftime('%H:%M:%S')
Meanwhile I simplified it (I removed the for statement, using a namespace to inject a variable from the outer scope is a little bit noisy)… @tarmo - you are right, you should convert last_changed value to local