Automation based on brightness and state

current situation: The lights in the hallway are triggered by a sensor (just low brightness).
That works fine.

Now I want to add a switch that does the following:
if light is on and above a certain threshold: switch light off
if light is on and below a certain threshold: change to full brightness
if light is off: switch light on on full brightness

I already have a setup that works and is doing exactly what I described above. The only problem is: The functionality that covers the switch on/increase brightness is throwing an error every time it’s triggered (even though it works).

The automation in question:

alias: Flur unten ein (manuell)
description: ''
trigger:
  - device_id: c3d689b159b2c55de67b2cda9a331dba
    domain: deconz
    platform: device
    type: remote_button_short_press
    subtype: turn_on
condition:
  - condition: or
    conditions:
      - condition: device
        type: is_off
        device_id: f3d47241032a11eba506cdbdcb522cb7
        entity_id: light.flur_unten
        domain: light
      - condition: numeric_state
        entity_id: light.flur_unten
        value_template: '{{ state.attributes.brightness }}'
        below: 65
action:
  - type: turn_on
    device_id: f3d47241032a11eba506cdbdcb522cb7
    entity_id: light.flur_unten
    domain: light
    brightness_pct: 100
mode: single

Error message:

Logger: homeassistant.helpers.condition
Source: helpers/condition.py:234
First occurred: 10:26:26 (1 occurrences)
Last logged: 10:26:26
Value cannot be processed as a number: <state light.flur_unten=off; is_deconz_group=False, friendly_name=Flur unten, supported_features=41 @ 2020-12-21T10:18:29.779826+01:00> (Offending entity: )

What am I missing?

Try changing your numeric state condition to this:

- condition: template
  value_template: "{{ state_attr('light.flur_unten', 'brightness') | int < 65 }}"

The problem is that lights don’t have the agtribute brightness when they are turned off. So dour condition will give an error because the value is none.

1 Like

Hmm, I have changed it the way you described to this:

alias: Flur unten ein (manuell)
description: ''
trigger:
  - device_id: c3d689b159b2c55de67b2cda9a331dba
    domain: deconz
    platform: device
    type: remote_button_short_press
    subtype: turn_on
condition:
  - condition: or
    conditions:
      - condition: device
        type: is_off
        device_id: f3d47241032a11eba506cdbdcb522cb7
        entity_id: light.flur_unten
        domain: light
      - condition: template
        value_template: '{{ state_attr(''light.flur_unten'', ''brightness'') | int < 65 }}'
action:
  - type: turn_on
    device_id: f3d47241032a11eba506cdbdcb522cb7
    entity_id: light.flur_unten
    domain: light
    brightness_pct: 100
mode: single

But I still do get whenever the automation is triggered:

Logger: homeassistant.helpers.condition
Source: helpers/condition.py:234
First occurred: 10:59:20 (1 occurrences)
Last logged: 10:59:20

Value cannot be processed as a number: <state light.flur_unten=off; is_deconz_group=False, friendly_name=Flur unten, supported_features=41 @ 2020-12-21T10:59:16.585975+01:00> (Offending entity: )

I have reloaded the automation. I have even restarted the whole home assistant to make sure that the changes have been applied.

Did you try removing the other condition to make sure that this is the offending condition?

1 Like

bangs head on the table

Yes, you are absolutely right! Damn, sometimes I really wonder whether I should try to get a home automation up and running or better play with my son’s Legos …

Thank you!

1 Like