Temp sensor automation

need help with my first automation. i have an aquara temp sensor that i would like to toggle on a smart outlet. If the temp goes above xx then turn on an outlet. here is what i have so far. if i manually run the automation it works, just not automatically. Thanks

# turn on fan when temp sensor reaches certain degree
   -alias: fan
    -description: ''
  - type: temperature
    platform: device
    device_id: 965594261325d21b8b28b38719993f5d
    entity_id: sensor.lumi_lumi_weather_58aabc06_temperature
    domain: sensor
    above: 70
      hours: 0
      minutes: 1
      seconds: 0
condition: []
  - service: switch.toggle
      area_id: network_rack
      device_id: 4dae043d8f620fabf8a34a57a7e78c67
      entity_id: switch.boilerfan_socket_1
mode: restart

Hello and welcome to the forum. Please have a read of point 11 here then edit your post and fix your pasted code.

But rather than automating this it sounds like a job for a thermostat.

switch.toggle :thinking:



  - platform: generic_thermostat
    name: Fan 
    heater: switch.boilerfan_socket_1
    target_sensor: sensor.lumi_lumi_weather_58aabc06_temperature
    min_temp: 18
    max_temp: 80
    ac_mode: true
    target_temp: 50
    cold_tolerance: 0
    hot_tolerance: 0
      seconds: 240
      minutes: 4
    initial_hvac_mode: "cool"
    away_temp: 24.5
    precision: 0.1 

If the current temperature of the sensor is above 70 then the automation won’t trigger.

the trigger only happens when it goes from false to true. So in your case from below 70 to above 70.