Alexa timer template from alexa_media

I’m trying to pass the timer data from alexa_media “next_timer” sensor into an external device.
This seems simple at first glance, but I’m getting hung up on the multiple timers use-case:

  1. Timer added when there are existing active timer/s - send new timer data

  2. Timer ended and cleared - send timer ended message

  3. Timer cancelled - send timer ended message

I know i can identify the timer/s by the “sorted_all[0].id” property, the state of it (on/off) from the “sorted_all[0].status” property, and the trigger time in unix epoch from “sorted_all[0].triggerTime”.

note: alexa_media treats ended timers and cancelled differently. when ended, the timer is cleared from “total_active”, but when cancelled it will also be cleared from “total_all”.

Can anyone please help me handle all these use-cases?

Would still appreciate any help i can get