Heat the bath 30mins before wake sonos time

hi there,

iam using the following automation:

trigger

platform: template
value_template: >-
  {{ states('sensor.time') < (state_attr('input_datetime.sonosweckzeit',
  'timestamp') - 30*60) | timestamp_custom('%H:%M', false) }}

condition

condition: state
entity_id: switch.sonos_alarm_1_2
state: 'on'

action

service: tado.set_climate_timer
target:
  device_id: tado_heating_device_in_bath
data:
  time_period: '00:25:00'
  temperature: 24

from the developer tools i get the following output for
{{ (state_attr('input_datetime.sonosweckzeit', 'timestamp') - 30*60 ) | timestamp_custom('%H:%M', false) }}
β†’ 05:13

when i look into the trace timeline, i wonder why it’s triggered at 00:00:00

this automation works fine with Version Home Assistant OS 7.1. It was heating my bathroom at 05:13 for 25Minutes. In Version Home Assistant OS 7.2 it triggers at midnight and i don’t know why.

Use the trace for the automation.

hi nickrout,

thanks for your answer. could you please be a little bit more specific?
Iam new to home assist :slight_smile: :slightly_smiling_face:

this is the trace timeline

and i debugged the values with developer tools. they seems to be okay.

sensors are defined as follows:

sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_utc'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'

Well, even considering you’re doing string comparisons, β€œ00:00” is smaller than β€œ05:13”.
I would expect this to trigger every minutes until 05:13.

If you want it to trigger once at at 05:13, you probably want β€œ==”

1 Like

thank you so much koying

{{ states('sensor.time') == (state_attr('input_datetime.sonosweckzeit', 'timestamp') - 30*60) | timestamp_custom('%H:%M', false) }}

is the correct solution :slight_smile: :heart: