I need help to a template. Sensor alarm minus 1 hour

Hi

Can anyone help me with a template?

My goal is to show my next alarm minus 1 hour, and only if the alarm is set by Package: hdesign.theclock

in the format : H:M

is it possible?

Try this in the developer tools template editor.

{{ states('sensor.rhmobil_naeste_alarm')|as_datetime - timedelta(hours = 1) }}

1 Like

Yes, it works ! do you now if its possible to only check : Package: hdesign.theclock
?

I will use it for my heating, but if I have made a reminder it will start heat when i got the reminder.

Sorry I don’t know what you mean.

You can either check it in the same template:

{{ states('sensor.rhmobil_naeste_alarm')|as_datetime - timedelta(hours = 1) and state_attr('sensor.rhmobil_naeste_alarm','package') == 'hdesign.theclock' }}

or you just add it as another condition:

  - condition: state
    entity_id: sensor.rhmobil_naeste_alarm
    attribute: package
    state: hdesign.theclock

see my screen shot - if i set my alarm in my alarm app it says - Package: hdesign.theclock
but if i set a reminder in samsung reminder app - it says package: samsung.reminder

when I use your template, it will trigger on both - I only want to trigger it on Package: hdesign.theclock

Ideally what you want to do is to create an input helper to store the alarm time, and have an automation that runs when the sensor state changes (the alarm time has been changed) AND the package is hdesign.theclock. That way if some other package changes the alarm time, Home Assistant will still know what time to do it’s thing - otherwise like you say if you set a reminder then it’s gone, and your automation will not fire.

1 Like

Thanks for your time. You’re right - that will be right thing to do. I hoped it could be done in a template :slight_smile: