Temp based automation not running

I am attempting to manually turn on a heater when the temperature falls below 70 degrees. Here is my code:

alias: Office Heater On
description: ""
trigger:
  - type: temperature
    platform: device
    device_id: mydeviceid
    entity_id: myentityid
    domain: sensor
    below: 70  
condition:
  - condition: time
    after: "06:00:00"
    before: "16:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
action:
  - service: switch.turn_on
    target:
      entity_id: switch.plug_16
    data: {}
mode: single

It simply does not run. When I look at the temperature entity - it is reporting every 2 mins. It is a Govee Bluetooth which I have connected via ESP2 bluetooth. I have tried deleting and recreating. I have tried a numeric state but nothing seems to get it to work…what am I missing? Appreciate any help.

the temperature needs to cross the 70 degree threshold. Meaning your starting temp needs to be above 70 degrees, then move to a value below 70. Otherwise no trigger will occur if the temperature is already below 70 degrees and moves further below 70 degrees.

So what would be the solution? I need it to come on in the mornings and the temp in that room is often in the 40s as I shut it off all night…I guess I could have a separate automation that justs turns it on in the mornings but surely there is a way to have it read the temp and fire off simply based on what the temp is at that time…

Not perfect, but I added a second trigger at 6:00am so that should take care of the initial turn on. I guess I will just disable it during the summer. I still would like to know what I should be doing to use that temp as a trigger on its own just based on the value and not on it passing the threshold.

Use two triggers as you suggest above; and supplement with two matching conditions:

alias: Office Heater On
description: ""
trigger:
  - platform: numeric_state
    entity_id: myentityid
    below: 70
  - platform: time
    at: "06:00:01"
condition:
  - condition: time
    after: "06:00:00"
    before: "16:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
  - condition: numeric_state
    entity_id: myentityid
    below: 70
action:
  - service: switch.turn_on
    target:
      entity_id: switch.plug_16

That way it will turn on at 06:00 if it’s already cold; and also during your time period if the temperature drops again.

I’ve converted your device trigger to a numeric state trigger as it’s tidier.

Probably better to use a Generic Thermostat and a Schedule that feeds an automation to turn it on and off as needed.

1 Like

Thanks - I will look into that. Appreciate the help!