Simple automation help. + Temperature turns in switch

Hi there, I’m struggling to grasp where to start for a simple automation on how to turn on a switch if temperature reaches 25*C

I currently have (sensor.12_temperature) and (switch.livingroom_fan). Basically if temperature reaches 25 I’d like the switch to turn on. Is this done in automation.yaml? Anybody fancy putting me out of my misery on how to set this up? Thanks in advance

I modified an automation I have that is somewhat similar to what you want. I make no promises but I think this may work for you:

automation 15:
 trigger:
    platform: numeric_state
    entity_id: sensor.12_temperature
    above: 25
 
  action:
    service: homeassistant.turn_on
    entity_id: switch.livingroom_fan
     

automation 16:
 trigger:
    platform: numeric_state
    entity_id: sensor.12_temperature
    below: 24
 
  action:
    service: homeassistant.turn_off
    entity_id: switch.livingroom_fan
1 Like

you sir are a legend. Thank you so much. Your code gave me the basis but after staring at the screen and the sensors for a few hours got it working. I know now how it works.

Just a thing to note, you’re trigger: reference I think needs another space to the right. HA gave me errors and wouldn’t start.

I put my code in automation.yaml also so the ‘automation 15’ for example wasn’t needed I think?.. makes sense as its in the automation section but if it was in config then i’m sure would be good.

I ended up with Homeassistant sensor12 temperature

Again thank you for your time. I think I will be comfortable using the automation now as I understand the trigger and action method now.

Quick question actually. If I turn off switches from the GUI does this override the automation? Let’s say for example the living room is 26 degrees and I turn it off will the automation rule kick back in and turn it on or does it respect it being turned off manually? When should it know when to turn back on too?

I think you can do this by putting your manual on/off switch as a condition by your automation. Then it only works when the switch is on. Or off. Just what you want.

I have a similar (undesirable) situation with light levels. Here is what I think happens in your case. If the temp rises above what you set in automation the fan turns on. You, now manually turn it off. It will not come back on automatically unless:

  • Temp drops below then rises above your setting in your config file.

What appears to be happening in my case with light levels (LUX) is when the (1) value exceeds a set amount, send HIGH LUX message. When the (2) value is below a certain amount, send LOW LUX message. The problems I appear to having is (1) will occur only once even after the LUX falls below (2) the rises again. In other words I am only getting on HIGH Lux message ever.

Thank you so much for posting this! I’m using this to turn on my electric wall radiators. I’m wanting to advance this a bit and make it conditional. I’d like to make it so that when I’m asleep, the triggered temp is a lot lower until about an hour before i wake up for work, then I’d like it to raise back to normal.

In tasker on my phone i can set multiple states (near work SSID during work hours with a work calendar entry triggers phone to go silent and automatically log into the public wifi.

Is there a way to do this in home assistant? Multiple conditions needing to be met to make event to be triggered? Any ideas?