Automation Numeric State does not trigger

[Update]
My bad.

I just realized when posting I used “sonne.elevation” instead of “sonne_elevation”.

Fixed it and will wait if it fires now.
[/UPDATE]

Hi,

I am trying to get an automation working based on numeric value. I read a lot of threads regarding the numeric value trigger but none really helped.

So I have a sensor which shows the current sun elevation:

mqtt:
    sensor:
        - state_topic: hzg/status
          name: "sonne_elevation"
          unit_of_measurement: "°"
          force_update: true
          value_template: '{{value_json.sonne.elevation}}'

My HomeAssistant display the value of the sensor really nicely in Grafana. Works fine so far.

Now I tried to create an automation based on this.
The automation should switch the christmas lights on, when the above sensor crosses the “-23” value from below to higher, so sun is raising soon.
This is the automation, it only fires when the time trigger steps in:

- id: '1700628469118'
  alias: Weihnachtsbeleuchtung AN
  description: ''
  trigger:
  - platform: time
    at: 05:45:00
  - platform: numeric_state
    entity_id:
    - sonne.elevation
    above: -23
  - platform: sun
    event: sunset
    offset: 0
  condition: []
  action:
  - type: turn_on
    device_id: 734130f3fb63d63f3350c97b94808a0a
    entity_id: 7457c62c6fb61ddf76d5b7b7937a0540
    domain: light
  mode: single

The “-23” has been crossed this morning around 5:28am so the time trigger should not have taken place.

See stats of the light:
grafik

The value is a float, should I use “-23.0” instead?

Any idea what I did wrong?

/Knebb

My bad.

I just realized when posting I used “sonne.elevation” instead of “sonne_elevation”.

Good job picking up on that. However, in Home Assistant, entities are always prefixed by their domain. In your definition of sonne_elevation, we see it is in the sensor domain. So when you refer to it in your automation, you need to set the entity ID as sensor.sonne_elevation, not just sonne_elevation

I can’t see any other issues with your automation however it still won’t fire while it’s looking at the wrong entity ID.

If you want to test it without waiting for the next sunrise, you could make an input_number helper and use it as a trigger in the same way so you can manually change the number and test it.

Thanks! With the addition of “sensor.sonne_elevation” it works just fine.