Multiple Actions on Automation based on conditions

I’ve got several ‘helpers’ as I want to be able to control the light percentage based on the time of day.
But I’m a little stuck with the automation.

image

image

Below is the automation so far.
I also have several other ‘helpers’ to aid with the following

  • Master switch to disable all the automations
  • Master ‘Start’ time (lights only come on after this time)
  • Master ‘End’ time (lights stop coming on after this time)
  • “brightness test” boolean that I toggle to test the lights (this will be replaced with the light entity)
- id: '1626713191171'
  alias: '[Light Auto On With Motion] [OfficeNew] On With Toggle'
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.lights_brightness_test
  condition:
  - condition: time
    after: input_datetime.lights_automation_lights_auto_on_after
    before: input_datetime.lights_automation_lights_auto_on_before
  - condition: state
    entity_id: input_boolean.lights_automation_master
    state: 'on'
  action:
  - condition: time
    after: input_datetime.lightautomation_am_bri_start
    before: input_datetime.lightautomation_am_bri_end
  - service: light.turn_on
    target:
      entity_id: light.jamies_bedroom
    data:
      brightness_pct: '{{ states(''input_number.lights_brightness_am'') |int}}'
  - condition: or
    conditions:
    - condition: time
      after: input_datetime.lightautomation_pm_bri_start
      before: input_datetime.lightautomation_pm_bri_end
  - service: light.turn_on
    target:
      entity_id: light.jamies_bedroom
    data:
      brightness_pct: '{{ states(''input_number.lights_brightness_pm'') |int}}'
  mode: single

Just to add, with the above setup, the ‘AM Brightness’ works, but the PM doesn’t.

Your “or” condition isn’t set up properly, but a Choose action would be a better choice anyway. In regards to the PM not working, double check that you aren’t killing it with your ...lights_auto_on_after/_before datetime conditions.

- id: '1626713191171'
  alias: '[Light Auto On With Motion] [OfficeNew] On With Toggle'
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.lights_brightness_test
  condition:
  - condition: time
    after: input_datetime.lights_automation_lights_auto_on_after
    before: input_datetime.lights_automation_lights_auto_on_before
  - condition: state
    entity_id: input_boolean.lights_automation_master
    state: 'on'
  action:
  - choose:
      - conditions: 
          - condition: time
            after: input_datetime.lightautomation_am_bri_start
            before: input_datetime.lightautomation_am_bri_end
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.jamies_bedroom
            data:
              brightness_pct: '{{ states(''input_number.lights_brightness_am'') |int}}'
      - conditions:
          - condition: time
            after: input_datetime.lightautomation_pm_bri_start
            before: input_datetime.lightautomation_pm_bri_end
        sequence:  
          - service: light.turn_on
            target:
              entity_id: light.jamies_bedroom
            data:
              brightness_pct: '{{ states(''input_number.lights_brightness_pm'') |int}}'
    default: []
  mode: single
1 Like

That got it working, thanks!

Yeah, I’m hoping to better utilise these automations in the future when I have a little more knowledge…
I know this is a long config but ideally I want the config customizable via the Helpers without having to change all my automations.