Help writing automation for brightness trigger

I’m new to Homeassistant and am not comfortable yet with how templates, triggers, and conditions all fit together. Here is what I want to do in pseudocode:

  • Trigger on change of brightness level of light.art

  • If brightness level of light.art is > 40 take action light.lamp.turn_on

  • Else if brightness level of light.art <= 40 take action light.lamp.turn_off

How would I write this for a Homeassistant automation?

Hi. I found help in this video:

Tell us if you still need help after this video

Thanks, I rewatched it to make sure I didn’t miss something. I am still not sure how to get a brightness level to trigger the automation. Here is the most recent automation.yaml section that I have tried:

  • action:
    • data:
      entity_id: switch.n_dining_lamp_switch
      service: light.turn_on
    • data:
      entity_id: switch.s_dining_lamp_switch
      service: light.turn_on
      alias: Painting Lamps on
      condition: []
      id: ‘1514940240049’
      trigger:
    • above: ‘126’
      entity_id: light.painting_light_level
      platform: numeric_state
      value_template: ‘{ “brightness” }’

This compiles fine but never triggers. I suspect that there is nothing to cause a “query” to the z-wave control (light.painting_light_level), so it never sees a value to act on. In my previous ISY994iz controller I had to set up a polling loop to read and save the current brightness to act on.

Will this automation do it’s own polling/query of the control or do I need to first create some sort of sensor to do that and then trigger off of the sensor?

Thanks in advance for any help.

You can test your value template on the front end, under dev tools, on the “templates” tab.

I think it actually needs to be value_template: ‘{{ state.attributes.brightness }}’

When testing the template, you’ll have to specify the entity_id, so on the templating page you’ll have to try {{ state.light.painting_light_level.attributes.brightness }}

1 Like