Kids nightlight automation question

I have a question regarding dimming a currently lit bulb through automation (smart bulbs - Ecosense). My automations seem to turn off the lights instead when the dim lights is activated. What I would like to have is the kids lights be on at dusk or shortly before at 100% and then dim down to about 10-20% when the time is 9:30pm and run most of night. Should they be automated individually? or as part of a group?

Thanks for any suggestions in advance! Still a learning process for me, but I have come a long way in a week.

Which type of lights are you using? Can you show us the automation you have now?

The most versatile solution that comes to my mind is to define two scene : kids_max and kids_dim
Then in the first automation you just turn on the first scene, and on your second automation you trun on the second scene.
By doing so, you can reuse the scenes to turn on the lights in the morning, etc

scene:
  - name: kid_max
    entities:
      light.ecosense_kid1: 
        state: on
        brightness: 255
      light.ecosense_kid2:
        state: on
        brightness: 255
  - name: kid_dim
    entities:
      light.ecosense_kid1: 
        state: on
        brightness: 45
        transition: 20
      light.ecosense_kid2:
        state: on
        brightness: 45
        transition: 20

And for the automations part, the most simple is

automation:
 - alias: "Kids lights full"
    trigger:
      - platform: sun
        event: sunset
    action:
        service: scene.turn_on
        entity_id: scene.kid_max

You can proceed likwise for the second one, changing the trigger from sun to time,…
I recommand using conditions as well :

  • To check the lights are not already turned on for the first one (in order to avoid changing the state that has been manually set)
  • That they are already on before the second one (to be sure that if your kids manually turned them off to sleep before 21:30, the lights won’t get back on)
  • You might also try to find something for what happens if the sunset is after 9:30 (basically the first automation has a condition that force it to run only before 9:29, otherwise only the second one will be executed or something). This may be in contradiction with the previous condition.

I’ll try to cut and paste to show what I have now… I use 2 Ecosmart bulbs and a wemo switch(doesn’t dim just on/off, not connected to the lights in other rooms) condition of home from my nest thermostat as its my only occupancy sensor at the moment. Just getting my CloudMQTT working.

- action:
  - data:
      brightness: 250
      entity_id: light.child1_lamp,light.child2_lamp
      transition: 60
    service: light.turn_on
  - data:
      entity_id: switch.child3_room
    service: switch.turn_on
  alias: kids lamps on at dusk
  condition:
  - condition: state
    entity_id: climate.home_family_room_thermostat
    state: auto
  id: '1****************'
  trigger:
  - event: sunset
    offset: -01:00:00
    platform: sun
- action:
  - data:
      brightness: 30
      entity_id: light.child1_lamp,light.child2_lamp
      transition: 60
    service: light.turn_on
  - data:
      entity_id: switch.child3_room
    service: switch.turn_off
  alias: kid's nightlights
  condition:
  - condition: state
    entity_id: climate.home_family_room_thermostat
    state: auto
  id: '1******************'
  trigger:
  - at: '22:00'
    platform: time
- action:
  - data:
      entity_id: light.child1_lamp,light.child2_lamp
    service: light.turn_off
  alias: Turn off night lights
  condition:
  - condition: state
    entity_id: climate.home_family_room_thermostat
    state: auto
  id: '1******************'
  trigger:
  - event: sunrise
    offset: 00:30:00
    platform: sun

I might be wrong, but the automations should all have a different ID I think (not sure as I do not use the automation editor). That may be a first problem.
Otherwise, I really hate looking at the automations.yaml that has been generated by the editor :stuck_out_tongue: . That being said, you could try to turn on the lamps independantly from each other, instead of having the two entity_ids in the same command. I do not know if that is mandatory too, but in general I have " " around the offset

 - event: sunset
    offset: "-01:00:00"
    platform: sun

Thanks lambtho, I’ll give that a try. :+1: They all have a different ID in reality, I only fudged the values for the post. I am just unfamiliar what constitutes as privacy concerns when posting.

1 Like

automations IDs are not a privacy problem, you can call them whatever you want. So no need to redact them :wink:

1 Like

Happened again last night, and I just realized my mistake… it had nothing to do with home assistant at all… I have a Wink as my Zwave radio and I had a prepackaged Moonlight scene turned on for lights. At midnight it was turning them all off. haha Now it should run smoother.

1 Like