Automation using number helper

Hello, i am completely new to Home Assistant, and need some help with making an automation

What i am trying to create is a temperature control for my 3D printer enclosure, i have a hue motion sensor as the temperatur sensor and i will have a hue smart plug to turn on a fan but for now its just gonna be a light, the target temperature i want to be able to just set with a slider in the home assistant dashboard, i’ve already created the number helper, but i cannot get the automation to work i’ve tried googling stuff with no result.

How im trying to have it work: You select a temperature using the dashboard slider, then if the temperature is ABOVE the target temperatur it needs to turn on a smart plug. then when the temperatur drops down to below the target temperatur it turns the fan off

So basiclly i just need this automation but have the slider/number helpers value to be the value in the above field when doing the automation with UI

Some info:

  • In blue is the number helper info
  • In red is the silder on the dashboard
  • In green is the infomation on the motion sensor atributes
description: ""
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    value_template: ""
    above: input_number.testnumber
    id: above
    for:
      hours: 0
      minutes: 0
      seconds: 30
  - platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    value_template: ""
    below: input_number.testnumber
    id: below
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: above
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.cooling_fan
      - conditions:
          - condition: trigger
            id: below
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.cooling_fan

(I’ve added a 30 sec state, so it won’t start switching on/off contiously :wink: )

alias: example
trigger:
  - id: 'on'
    platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    above: input_number.testnumber
  - id: 'off'
    platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    below: input_number.testnumber
condition: []
action:
  - service: 'switch.turn_{{ trigger.id }}'
    target:
      entity_id: switch.your_fan

If you’re experimenting with a light instead of a switch then use the following service call instead:

  - service: 'light.turn_{{ trigger.id }}'
    target:
      entity_id: light.your_light

If you want a service call that can turn on/off either type of entity, use this:

  - service: 'homeassistant.turn_{{ trigger.id }}'
    target:
      entity_id: light.your_light

hehe samesame but different :grin:

Similar but different:

alias: example
trigger:
  - platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    above: input_number.testnumber
    below: input_number.testnumber
condition: []
action:
  - service: 'switch.turn_{{ 'on' if trigger.to_state.state | float(0) > trigger.above else 'off' }}'
    target:
      entity_id: switch.your_fan

I can’t get your script to work, it won’t trigger, so i started using “sensor.hue_motion_sensor_1_illuminance” instead of “sensor.hue_motion_sensor_1_temperature” so i could test it faster with just putting my hand over it and still doesnt want to trigger :frowning:

Your script seems to work, could you explain it a little so i could understand it and maybe i the future make scripts my self :slight_smile:

would it be possible to add a timer like aceindy had? :slight_smile:

Also sorry if its to much but do you guys know if its possible to have a gauges serity colours change based on how close its to the target temp? :slight_smile:

So like it would be green if the temp is within like 5 or 10 C, yellow if its 5 over or under green temp and red if its over or under that :slight_smile:

I must have missed that requirement. Where is it mentioned in your first post? What I see is this:

@123 Im sorry it wasnt a requirement but after what @aceindy said it made sense so the fan doesnt switch on and off really quickly and will have a little buffer of sorts

In that case, sure, just add the for option to the Numeric State Trigger.

Example 1

alias: example
trigger:
  - id: 'on'
    platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    above: input_number.testnumber
    for:
      seconds: 15
  - id: 'off'
    platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    below: input_number.testnumber
    for:
      seconds: 15
condition: []
action:
  - service: 'switch.turn_{{ trigger.id }}'
    target:
      entity_id: switch.your_fan

Example 2

alias: example
trigger:
  - platform: numeric_state
    entity_id: sensor.hue_motion_sensor_1_temperature
    above: input_number.testnumber
    below: input_number.testnumber
    for:
      seconds: 15
condition: []
action:
  - service: 'switch.turn_{{ 'on' if trigger.to_state.state | float(0) > trigger.above else 'off' }}'
    target:
      entity_id: switch.your_fan