Automation with climate sensor and smartphone alarm

Hi everyone,

I’ve been trying to make an automation and after several trials I’ve come to the result that I need help to get this done.

What the automation should do: 10 minutes before my smartphone alarm starts and if the temperature in my bathroom is under 20°C the thermostate will be enabled.

My code so far:

- id: '1581871043818'
  alias: Bathroom Warmup
  description: ''
  - minutes: /1
    platform: time_pattern
    seconds: '0'
  - condition: template
    value_template: '{{ (((as_timestamp(now()) | int) + 10*60) | timestamp_custom("%Y-%m-%d
      %H:%M:00")) == states.sensor.next_alarm.state }}'
  - condition: template
    data_template: "{{ state_attr('climate.heizungsthermostat_climate', 'current_temperature') | float < 20 }}"
  - entity_id: script.1581870339430
    service: script.turn_on

By the way: The part to start 10 minutes before the alarm goes off works already properly on other automations.

Thanks for your help in advance.

What help do you need? :wink:

you need quotes around value

should be value_template. and why 2 template conditions?

Thanks for your help! So it has to be like this?

  - condition: template
      {{ (((as_timestamp(now()) | int) + 10*60) | timestamp_custom("%Y-%m-%d%H:%M:00")) == states.sensor.next_alarm.state }}
      {{ state_attr('climate.heizungsthermostat_climate', 'current_temperature') | float < 20 }}

Edit: No, this can’t be. I’m getting errors in the configurator.

I still don’t know what is the problem :wink:
your value_template isn’t right at least because it should return either True of anything else.

Something like this

- condition: template
  value_template: >
    {% set ctime = states.sensor.time %}
      (((as_timestamp(now()) | int) + 10*60) | timestamp_custom("%Y-%m-%d%H:%M:00")) == states('sensor.next_alarm') and
      state_attr('climate.heizungsthermostat_climate', 'current_temperature') | float < 20

The problem is that I don’t get the code working and always getting errors :slight_smile:

With your code I still get this error:

missed comma between flow collection entries at line 162, column 8:
          {% set ctime = states.sensor.time %}

that’s easy - I forgot > after value_template - updated my previous post, try it out.