Help needed with condition...if,then

Hi there.
I am by no means a programmer of any kind, have never been taught, and what I know about programming is self-taught.
I am having a problem with the new “if, then” condition in automation. in particular the numeric state condition. What I am trying to achieve is that when home assistant boots up, (let’s say after a power failure,) then if the office lamp is on at below 6% then the office light switch must turn on. Yes, the office lamp is on so that I can choose the brightness attribute. Can someone help me with this automation or point me in the right direction. For whatever reason, the numeric state does not see the brightness values. Please bear in mind that I don’t know code/coding etc…

Below is the automation yaml

alias: Lamp Low Light On
description: ''
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - if:
      - condition: numeric_state
        entity_id: light.office_lamp
        attribute: brightness
        above: '1'
        below: '6'
    then:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.office_light
mode: single

condition is and to the trigger

So logic is
when
home assistant starts
and
office lamp is above 1 and less than 6
then
turn on office light.

alias: Lamp Low Light On
description: ''
trigger:
  - platform: homeassistant
    event: start
condition: 
  - condition: state
    entity_id: light.office_lamp
    attribute: brightness
    above: '1'
    below: '6'
action:
  - service: switch.turn_on
      target:
        entity_id: switch.office_light
mode: single

I get this error when trying to save the automation……

Message malformed: required key not provided @ data['trigger']

The brightness attribute’s value ranges from 0 to 255. If you want 6% then six percent of 255 is approximately 15. That’s the value you would use for the below option. You are currently using 6 which represents approximately 2.4% brightness level.

In addition, if the automation fails to behave the way you expect, check its trace to understand why.

Thank you…sorted and working now…thanks again

1 Like