Set dim level using Automations based on time of day

Here an automation for my hallway light with different brightnesses between specific times:

alias: Verlichting hal aan bij beweging
trigger:
  - platform: state
    entity_id: binary_sensor.multisensor_hal_sensor
    to: 'on'
condition:
  condition: and
  conditions:
    - condition: numeric_state
      entity_id: sensor.multisensor_hal_luminance
      below: 15
    - condition: state
      entity_id: light.dimmer_hanglamp_hal_level
      state: 'off'
action:
  service: light.turn_on
  data_template:
    entity_id: light.dimmer_hanglamp_hal_level
    brightness: >
      {%- if now().strftime('%H')| int >= 21 %}
        100
      {%- elif now().strftime('%H')| int < 7 %}
        100
      {%- elif now().strftime('%H')| int >= 7 %}
        255
      {%- endif %}
5 Likes