Error: in 'numeric_state': 'number' is undefined

I’m still pretty new to all this and I have been working on this for hours now. I have some displays that return the active page as a number entity:

number.garage_hasp_disp04_active_page_2

I am attempting to write an automation that triggers whenever the entity changes then have a condition to test for a certain page. Here is my current code although I have tried numerous methods.

alias: test template
description: ""
triggers:
  - trigger: state
    entity_id:
      - number.garage_hasp_disp04_active_page_2
conditions:
  - condition: numeric_state
    entity_id: number.garage_hasp_disp04_active_page_2
    above: 0
    value_template: "{{ states(number.garage_hasp_disp04_active_page_2) == 1}}"
actions:
  - action: notify.pushover
    metadata: {}
    data:
      message: It works!
mode: single

Unfortunately keep getting the following error:

Error: In 'numeric_state': In 'numeric_state' condition: template error: UndefinedError: 'number' is undefined

The problem seems to be the fact that the entity is a number type but I don’t quite know how to handle it. I would appreciate any suggestions.

Thanks,

Bob

You need to quote the entity id in the states() function, or home assistant will think the domain number is a variable.

value_template: "{{ states('number.garage_hasp_disp04_active_page_2') == 1 }}"

However, forget the value template altogether and just use a state condition:

conditions:
  - condition: state
    entity_id: number.garage_hasp_disp04_active_page_2
    state: '1'

Thank you so much. The state condition worked perfectly. I knew there had to be an easy way to do it. This is a steep learning curve but definitely worth it.

Thanks again,

Bob

1 Like