Trigger from temperature attribute to turn on a light

Hello Home Assistant Wizards,

I am struggeling thith the follwing. I want turn on a light when the temperatarure of the HA weather app is above the temperature I defined with a helper.

Name of the helper is ‘input_number.pl005_temperature_input’

The only condition si that, for the automation to work I have to put ‘on’ a bolean switch: input_boolean.ppl_005_startfrom_tempssensor_help_toggle_001

I doesn’t seem to work, althoug in developper Tools it seems to give results.

Any thoughts ?

Here below is my code:

alias: PPL_005_StartFromTempSensor_AUTO_001_StartAutomation
description: ''
trigger:
  - platform: template
    value_template: >-
      {{ (state_attr('weather.seeshome' , 'temperature') | float) >
      (states('input_number.pl005_temperature_input') | float )}}
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.ppl_005_startfrom_tempssensor_help_toggle_001
        state: 'on'
action:
  - type: turn_on
    device_id: 765e3842005015519cabd05f72f11e20
    entity_id: light.on_off_plug_1
    domain: light
mode: single

The automation only triggers when it is evaluated as false at the beginning then change and evaluated as true.

So, the weather temperature at first must be below your input_number and then rise above it for the automation to be triggered.

Thank you you reply.
Code is correct (just tested it with a state change of the temperature).
And it works :slight_smile:

Grazie mille, mille grazie.
Much appreciated

Ardy,

how shoud you adapt the code if you want to dismiss the trigger.
I mean If I put my bolean switch to ‘on’ and the temperature is higher then my input.number then it should start right away.

How to adapt the code in that way ?

Try this-

trigger:
  - platform: state
    entity_id: input_boolean.ppl_005_startfrom_tempssensor_help_toggle_001
    from: 'off'
    to: 'on'
condition:
  - condition: template
    value_template: >-
      {{ (state_attr('weather.seeshome', 'temperature') | int) >
      (states('input_number.pl005_temperature_input') | int ) }}
action:
  - service: light.turn_on
    target:
      entity_id: light.on_off_plug_1

This will trigger if the input_boolean is OFF and then turned ON.

Note: The automation above defeats the purpose of an automation. An automation should manages itself - turns ON when temperature higher than your input boolean and turns OFF when temperature is lower than your input boolean.

Or…

You can use both things as triggers and also both things as conditions (and).

That way if the boolean is off when the temperature requirement is met and you then turn on the boolean the automation will trigger. Ang if the boolean is already on and the temperature requirement gets met the automation will also trigger then too.