Please consider donating if this saves you time so that I can continue to deliver tutorials for you. Here you can download the code that I used for the template in the video How to create Action Template Sensors in Home Assistant. You can simply copy and paste this code so that you do not have to type it yourself. You get lifetime updates with this purchase. Thank you!