Automation not working with simple numeric_state

Hello, I’m sorry for the silly question but I’ve lost so many hours and tried all the different suggestion on the forum without anything working.
I’m trying to have an automation based on two numbers. One is the azimuth and the other one is a number found on a web page.
I’ve started creating the automation part for the first portion, but I cannot make it work.
With the first trigger it should bring the cover down when the azimuth is above 237, but in reality it doesn’t do anything.
I’m running 0.41 version of HA. Thanks for the help guys.

- alias: 'Abbasso tapparelle ufficio azimut 237.5'
  trigger:
    platform: numeric_state
    entity_id: sun.sun
    value_template: '{{ states.sun.sun.attributes.azimuth }}'
    above: 237

  action:
    service: cover.set_cover_position
    entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2_0
    data:
     position: '50'

Hi @Shaz, maybe try a value_template like in the example for the numeric_state trigger:
'{{ state.attributes.azimuth }}',
or use the Template Trigger:

automation:
  trigger:
    platform: template
    value_template: "{{ states.sun.sun.attributes.azimuth > 237 }}"
1 Like

Hi VDRainer, thanks a lot for your help. I’ve used the code you wrote and it is actually working. I’ve tried many different time with different code, but I think I tent to make things complicated. I would like now to add a condition to the action.
I’ve looked at the example here but when I reload HA configs it crashes. Is my code so wrong ? :slight_smile:

 - alias: 'Abbasso tapparelle ufficio azimut 237'
  trigger:
    platform: template
    value_template: "{{ states.sun.sun.attributes.azimuth > 237 }}"
  condition:
    - condition: template
      value_template: "{{ states.sensor.nuvolosita < 40 }}"
  action:
    service: cover.set_cover_position
    entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2_0
    data:
     position: '8'

Thanks again for the help here, really appreciated.

I made it. :slight_smile:

- alias: 'Abbasso tapparelle ufficio azimut 237'
  trigger:
    platform: template
    value_template: "{{ states.sun.sun.attributes.azimuth > 237 }}"
  condition:
      condition: template
      value_template: "{{ states.sensor.nuvolosita | int  < 40 }}"
  action:
    service: cover.set_cover_position
    entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2_0
    data:
     position: '8'

Hi @Shaz, this template will always return true, no matter what value the sensor returns.
Should be {{ states.sensor.nuvolosita.state | int < 40 }}
You can easily test templates in Developer Tools/Templates.
Just copy and paste {{ states.sensor.nuvolosita }} and you will see what it returns.
Then try it with {{ states.sensor.nuvolosita.state }}, and so on.

2 Likes

Wow… thanks a lot VDRainer, you open a world to me. :slight_smile:
I never realized it was an interactive windows in the developer tool section.
I still have to learn so much.

Thank you again