Set dim level using Automations based on time of day

Hello. New to HA, so need some help.

Have a motion detector that turn on light on movement. But want to use condition, so i can set the dim level, based on what time of day it is.

Example: movement at 02:00 to 06:30 should set a dim level/brightness of 50. But movement 6:30 to 11:00 should set a dim level/brightness of 130 etc…

Do need to make many automations or can i choose a action using condition:

Nice if somebody points me in the right direction.

You can set the level with a data_template.
See the documentation here:

@treno yes, that i know. Now i use:

- alias: 'Bevegelse: Slaa på lys yttergang'
  initial_state: 'on'
  id: '10000000000001'
  trigger:
    platform: state
    entity_id: binary_sensor.ygang_bevegelse_sensor
    to: 'on'
  condition:
    condition: time
    after: '20:00:00'
    before: '01:00:00'
  action:
    service: light.turn_on
    entity_id: light.rom
    data:
	  brightness: 100

But what do i need to add if i between 01 and 06 want “data: brightness: 60”?

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

:grinning::grin::smiley::star_struck::heart_eyes::sunglasses:

1 Like

Hi , i was trying to use your automation , but it seems not triggering anything.
Any help?
Thanks

- alias: Turn on toilet light when there is movement dimmed
  trigger:
    - platform: state
      entity_id: binary_sensor.0x00158d00047b8703_occupancy_2
      to: 'on'
  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.0x00158d00047b8703_illuminance_2
        above: 120
      - condition: state
        entity_id: light.light4
        state: 'off'
  action:
    service: light.turn_on
    data_template:
      entity_id: light.light4
      brightness: >
        {%- if now().strftime('%H')| int >= 21 %}
          100
        {%- elif now().strftime('%H')| int < 7 %}
          100
        {%- elif now().strftime('%H')| int >= 7 %}
          255
        {%- endif %}

I also want this type of automation and can’t figure it out… :frowning:

Update… I was able to get this working. See my working automation below. I set the data template YAML through the UI, but copied directly from my automation.yaml file hence the weird formatting…

trigger:
  - event_data:
      node_id: 10
      scene_data: 7680
      scene_id: 2
    event_type: zwave.scene_activated
    platform: event
  condition: []
  action:
  - data_template:
      group_name: Marley Bedroom
      scene_name: "{%- if now().strftime('%H')| int >= 21 %}\n  Dimmed\n{%- elif now().strftime('%H')|\
        \ int < 6 %}\n  Dimmed\n{%- elif now().strftime('%H')| int >= 6 %}\n  Energize\n\
        {%- endif %}\n"
    service: hue.hue_activate_scene
1 Like