Error: In 'numeric_state' condition: entity xxx cannot be processed as a number

Hi,
I’m a bit puzzled by the error in my automation:
" Error: In ‘numeric_state’ condition: entity sensor.lazienka_gora_humidity state ‘“59.41”’ cannot be processed as a number"

but the value clearly is a number. Do you have an idea what can be the reason ?
The conditions are:

condition: and
conditions:
  - condition: or
    conditions:
      - condition: time
        after: '09:00:00'
        before: '15:00:00'
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
      - condition: time
        after: '10:30:00'
        before: '15:00:00'
        weekday:
          - sun
      - condition: time
        after: '19:00:00'
        before: '23:30:00'
        weekday:
          - sun
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
  - condition: state
    entity_id: switch.gniazdko_2
    state: 'off'
  - condition: numeric_state
    entity_id: sensor.lazienka_gora_humidity
    value_template: '"{{ (float(state.state) - 10)|float }}"'
    above: sensor.wilgotnosc_na_gorze_srednia
    attribute: humidity

I’m not even sure that a template is needed here.

Assuming there is an attribute of the sensor called “humidity” then I assume the “humidity” attribute actually is a number so there should be no reason to process the data any further.

try this for the condition:

  - condition: numeric_state
    entity_id: sensor.lazienka_gora_humidity
    above: sensor.wilgotnosc_na_gorze_srednia
    attribute: humidity

But I think you might also be using the attribute key unnecessarily. If the sensor itself is the actual humidity value then it likely doesn’t have an attribute called “humidity”. If that’s true then just use the sensor state instead of the non-existent attribute:

  - condition: numeric_state
    entity_id: sensor.lazienka_gora_humidity
    above: sensor.wilgotnosc_na_gorze_srednia

as far as too many quotes that’s likely the result of the condition being created in the UI and then converted to yaml via the editor. I’ve seen the editor do that other times when helpng others who use the UI for templates. So I don’t think there’s anything wrong there. I don’t think…

1 Like