Help with automation template sensor

Hi,
I have a mqtt temperature sensor sensor.teplota_obyvak and a temperature slider input_number.cilova_teplota that I want to set up and call automation accordingly, but it does not work. What am I doing wrong? If the temperature sensor is higher than the input slider, open the cover.

- id: '1551610020112'
  alias: Test slider
  trigger:
  - above: '220'
    below: '300'
    entity_id: sun.sun
    platform: numeric_state
    value_template: '{{ state.attributes.azimuth }}'
  condition:
  - condition: template
    value_template: '{{ states.sensor.teplota_obyvak.state > states.input_number.cilova_teplota.state }}'
  action:
  - data:
      entity_id: cover.francouzke_okno_2
    service: cover.open_cover

I don’t know if this helps but I have this example that works for me:

  • id: PlantOneNeedsWater
    alias: Plant ONE Needs Water
    hide_entity: True
    trigger:
    platform: numeric_state
    entity_id: sensor.plant_one
    above: 700
    below: 1000
    action:
    service: notify.notify_pushover
    data:
    message: Plant ONE needs water!!!

I dont think so. I need Above number set with slider. input_number.cilova_teplota

Hve you checked this one:
Alarm clock: Alarm clock

Change this:

'{{ state.attributes.azimuth }}'

to this:

'{{ states.sun.sun.attributes.azimuth }}'

Also. I don’t believe you need to delimit the values for above and below with single-quotes. See: Numeric State Trigger.

Your main issue is this:

    value_template: '{{ states.sensor.teplota_obyvak.state > states.input_number.cilova_teplota.state }}'

States are strings, and comparing string representations of numbers often will not work as you expect. You need to convert to numbers before doing the comparison. Try this:

    value_template: '{{ states.sensor.teplota_obyvak.state|float > states.input_number.cilova_teplota.state|float }}'

It started working without modification. But I’d rather use the Float.

Thank you

Probably because sometimes string representations of numbers compare the same way as the numbers themselves, but sometimes they don’t. E.g., '11' > '10' is true, but '11' > '9' is not. You need the float conversion.

Software that magically repairs itself! :thinking:

Let’s hope it doesn’t magically un-repair itself.