Combining 'AND' and 'OR' conditions

I tried:

trigger:
  platform: template 
  value_template: "{{ state_attr('light.attick' , 'brightness_pct')|int < 22 }}"

But than it’s erroring out on the ‘for’ statement. I’ll try your suggestion, because I would like to keep the delay.

Forgot about the ‘for’ - try doing it like this instead…

trigger:
  platform: template 
  value_template: "{{ state_attr('light.attick' , 'brightness_pct')|int < 22 }}"
condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  - condition: or
    conditions:
      - condition: state
        entity_id: media_player.sony_XXXX
        state: 'on'
      - condition: state
        entity_id: media_player.panasonic_XXXX
        state: 'on'
action:
  - delay: 00:00:04
  - condition: template 
    value_template: "{{ state_attr('light.attick' , 'brightness_pct')|int < 22 }}"
  - entity_id: light.onoff_plug_1
    service: light.turn_on

So the automation triggers when the brightness pct is below 22, then the action waits 4 seconds and checks that this is still the case before switching the light on.

2 Likes

The automation didn’t trigger when the brightness was at 20%. Strange.

But when I moved the slider (via Philips Hue app) to a lower value the switch turned on. Does it only trigger when the value changes, maybe? That’s not what the automation is telling, but it appears not to work when it’s not lowering brightness.

It will have to go from above 22 to below 22 to trigger in its current form, and still be below 22 4 seconds later.

Ok. I’ll give it another go tonight.

@anon43302295 I tried your solution but I couldn’t get it to work every time. I just added the turning on the plug to the dimming light automation and it’s working every time (as expected). Can’t wrap my head around the value_template stuff yet.

Thanks for all the help!