Me again, next configuration - start time to heat house based on outside temperature

That’s ok, I’ve found a solution. Might not be the best or prettiest but it seems to work. Here’s what it looks like:

{% set at_time=5 * 60  %} 
{% set cur_time=now().hour * 60 + now().minute %}
{% set max_temp=15.0 %}
{% set out_temp=float(states('sensor.outside_temperature')) %}
{{ at_time - cur_time == 0 or (at_time - cur_time > 0 and out_temp < max_temp and at_time - cur_time + out_temp * 1.5 - 30.0 < 0) }}

Basically, the heat will turn on up to an hour before the wake time (at_time) but only if the outside temperature (out_temp, taken from my Acurite weather station, thank JardiamJ for the work) is already less than 15C (max_temp). At 15C, it will start 7 minutes 30 seconds before wake time. At -20, it will start an hour before the wake time.

To trigger it, I’ve set time templates of 5 and 7 for the hour and * for the minutes so it will try every minute of those hours.

So my code for turning on the heat in the morning looks like this now:

- id: '1578617316410'
  alias: Présence - Martin le matin
  description: ''
  trigger:
  - hours: '5'
    minutes: '*'
    platform: time_pattern
  - hours: '7'
    minutes: '*'
    platform: time_pattern
  condition:
  - condition: state
    entity_id: person.martin
    state: home
  - condition: or
    conditions:
    - condition: and
      conditions:
      - condition: state
        entity_id: binary_sensor.workday_sensor
        state: 'on'
      - after: '5:00:00'
        before: '6:00:00'
        condition: time
      - condition: template
        value_template: '"{% set at_time=5 * 60 %} {% set cur_time=now().hour * 60
          + now().minute %} {% set max_temp=15.0 %} {% set out_temp=float(states(''sensor.outside_temperature''))
          %} {{ at_time - cur_time == 0 or (at_time - cur_time > 0 and out_temp <
          max_temp and at_time - cur_time + out_temp * 1.5 - 30.0 < 0) }}"'
    - condition: and
      conditions:
      - condition: state
        entity_id: binary_sensor.workday_sensor
        state: 'off'
      - after: '7:00:00'
        before: '8:00:00'
        condition: time
      - condition: template
        value_template: '"{% set at_time=7 * 60 %} {% set cur_time=now().hour * 60
          + now().minute %} {% set max_temp=15.0 %} {% set out_temp=float(states(''sensor.outside_temperature''))
          %} {{ at_time - cur_time == 0 or (at_time - cur_time > 0 and out_temp <
          max_temp and at_time - cur_time + out_temp * 1.5 - 30.0 < 0) }}"'
  action:
  - data:
      temperature: 22
    entity_id: climate.neviweb130_climate_martin
    service: climate.set_temperature

Like I said, not the prettiest but with my current knowledge of Home Assistant (only 3 weeks), that’s the best I could muster :slight_smile: