HA-Sensor numeric: unknown

If a numerical comparison: greater than or less than - is used in the automation, the automation stops if the sensor has the status "Unknown" for any reason:

"Unknown" status

if/condition/3/entity_id/0
Executed: May 4, 2023 at 7:20:27 AM
Result:
result: false
message: value 'unknown' is non-numeric and treated as False

Solution: Value Template

This can be remedied by using a "value template" in the automation: 

{{states('sensor.rain_zamg_12') | default(0)}}

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

created by Bernhard | published: 2024-01-07 | Updated: 2024-01-07 | Übersetzung Deutsch |🔔 | Comments:1

Questions / Comments


(sorted by rating / date) [all comments (best rated first)]

✍anonym
2025-02-19 10:19
Thank you Bernhard,

Found your blog with a google search and hopefully it resolves my issue with charging my car,
sometimes the charging station gives a weird response which crashes my HA automation
Uitgevoerd op: 18 februari 2025 om 23:17:16
result: false
message: value 'unknown' is non-numeric and treated as False
entity: number.alfen_laadpaal_max_station_current

Edit my autmation with     value_template: "{{states('sensor.alfen_laadpaal_main_state_socket_1') | default(32)}}"
Crossing fingers this fixed it, it happens like once in a few months


alias: Auto laden stoppen rond accu 80% vol
description: ""
triggers:
  - entity_id:
      - sensor.leaf1aloi_battery
    above: 82
    trigger: numeric_state
conditions:
  - condition: state
    entity_id: sensor.alfen_laadpaal_main_state_socket_1
    state: Charging Power On
  - condition: numeric_state
    entity_id: number.alfen_laadpaal_max_station_current
    above: 0
    value_template: "{{states('sensor.alfen_laadpaal_main_state_socket_1') | default(32)}}"
actions:
  - device_id: 666f7e1b6514f5bc24903490ca2bac06
    domain: number
    entity_id: 3e48b7ab5ddbe83f662bb7259ec3ddb9
    type: set_value
    value: 0
    enabled: true
  - repeat:
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
        - device_id: 666f7e1b6514f5bc24903490ca2bac06
          domain: number
          entity_id: 3e48b7ab5ddbe83f662bb7259ec3ddb9
          type: set_value
          value: 0
        - metadata: {}
          data:
            message: Auto 80% vol maar laadpaal niet afgeschakeld
          action: notify.mobile_app_pixel_6a
      while:
        - condition: numeric_state
          entity_id: number.alfen_laadpaal_max_station_current
          above: 0
          value_template: >-
            {{states('sensor.alfen_laadpaal_main_state_socket_1') |
            default(32)}}
mode: single

 
By continuing to browse the site, you agree to our use of cookies. More Details