Need help with a basic fan heater timer / temp automation

Looking for a bit of guidance / advise if anyone can spare some time to help. I am trying to create an automation for a electric fan heater, but struggling with the most efficient logic to do this.

I have a fan heater (smart plug controlled), I am looking to trigger with a button press.

I have created a helper for the button, but would like the fan heater once triggered to stop under the following conditions:

20min time has elapsed
or
the temp in the room reaches X degree’s C.

I am getting my nickers in a twist with this one although basic. What is the best way for me to construct the Action based on this 20min timer or temperature reached, as its whichever happens first?

Any help really appreciated! These automations are quite new to me!

What I do is create a Generic Thermostat template and use the switch controlling the heater (or fans also in my case) just like a thermostat would. There’s your set point. After that it’s a matter of using a template in automation to turn it off after a certain point (if variable or on demand) or adding a condition of the switch being on for X minutes (if static).

1 Like

Just use wait for trigger for whatever temperature you need with a 20-minute timeout, have it continue on timeout and then turn the heater off after that

action:
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.heater
  - wait_for_trigger:
      - platform: numeric_state
        entity_id:
          - sensor.average_indoor_temperature
        above: 20
    timeout:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
    continue_on_timeout: true
  - service: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.heater


1 Like

Thanks both so much, @at9 this worked a treat thank you and @CO_4X4 this will be my next step to move this to a proper thermostat.

I really appreciate this community, thanks both

Just to check - Should the continue on timeout be true or false? I thought it should be on false?

It should be true. You want it to continue to turn it off if 20 minutes has elapsed.

OK thank you!