How to dim lights over time

Hey all,

I’m using a little automation to set a timer to switch off some lights in my bedroom:

- alias: Sleeptimer
  id: 'Sleeptimer'
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.sleeptimer
  action:
  - service: light.turn_off
    entity_id: group.lichter_schlafzimmer

In the UI I'm using a simple Button to execute the sleeptimer:

  - type: glance
    title: Licht aus in 15 Minuten!
    entities:
      - entity: timer.sleeptimer
        tap_action:
          action: call-service
          service: timer.start
          service_data:
            entity_id: timer.sleeptimer

The code of the timer itself is very simple:

  sleeptimer:
    name: Gute Nacht!
    duration: '00:15:00'

My question ist how to get a transition effekt? This timer is the sleeptimer for my bedroom. I’m starting the timer and after 15 minutes the lights in my bedroom are off. It works as expected but it would be nice if the lights are diming over the time. Does anybody know how to archive this?

Thanks in advance.

  action:
  - service: light.turn_off
    entity_id: group.lichter_schlafzimmer
    transition: 60 # time in seconds for the off transition here.
2 Likes

You can setup a scene that gets called. You can have the dimming within the scene happen over a period of time. I have my morning wakup scene that brings the lights up from off to 100% over 30 min. It works very well.

  • name: Wakeup Alarm
    entities:
    light.her_night_stand:
    state: on
    color_temp: 200
    brightness: 255
    transition: 1800
    light.noahs_night_stand:
    state: on
    color_temp: 200
    brightness: 255
    transition: 1800
5 Likes

Thank you @Noahma I’ve solve it like you mentioned!

1 Like

Hi @Noahma,

What is your hardware configuration? Which dimmable light bulb are you using? What is your switch?
I really appreciate any detailed information since I am new to Home Assistant and want do the exact thing that you’ve done.

Any bulb that supports transition should work for this use case.

Thank you @Burningstone for your reply.
Can you give me an example here? And what is going to do the dimmer job?

Some examples would be Philips Hue, LIFX and Yeelight bulbs. The bulb does the dimming.

I use a z wave dimmer (fibaro, aeotec, qubino etc.), the dimmer does the dimming and the dimmable bulb gets dimmed

Thanks @Mutt,

Going with a separate dimmer seems to be a better idea.
But these models are expensive!

Why do you think it is a better idea? I think it depends on your use case.

When I’m away and a bulb goes (and inevitably they will) my wife (or even the dog (almost !)) can change the ‘dumb’ bulb (I have a Box of bulbs, they have numbers written on them, so ‘like’ is replaced by ‘like’).
No need to pair a bulb, set up identity names for automations, scenes, scripts etc.
Oh and the bulbs cost 1/10 of what ‘some’ smart bulbs cost. (I buy Ikea Ledare)
AND they don’t ALL come on after a power cut (like tradfri)
But YMMV

3 Likes

Some 6 years ago I replaced most of my bulbs with Philips Hue and Ikea “smart” bulbs and since then, not a single bulb failed on me. If it happens one day that I’m away, my wife at home and a bulb fails, she’ll happily wait some hours for me to replace it, as they are anyway too high up in the ceiling for her :sweat_smile:
Regarding cost, I agree they are more expensive than “dumb” bulbs, but the IKEA bulbs are extremly cheap as well. You also have to include the cost of your dimmers in this calculation and then I think the total price would be very similar in the end. Power cuts are no problem here, I had one power cut in the last 10 years, lucky me :rofl:
Anyway the main reason for me to use smart bulbs over smart dimmers is that we live in a rented apartment. In addition as far as I know, insurance companies here won’t pay if my apartment burns down due to a failed Sonoff or whatever, which has not be installed by a certified electrician.
As you said YMMV.
Just out of interest, if your Z-Wave dimmer fails, will the light switch still work? I was thinking to get some of them in the future, when we move into our own home.

2 Likes

Every single point you raised is valid.
I am an electrical engineer by training (with heavy control bias) so installation is not a problem for me. But each switch is live so requires isolation, so in the last six months, some parts of the house have been up and down like…
I was also under the impression that for scene activation (I don’t use scenes but I do use them as triggers) I needed to include those nodes as secure. So many more exclusions and inclusions later I have proved they don’t and so I will soon have to do the rounds again to improve network speed.
I think a dimmer and a dumb bulb will generally be slightly more expensive (especially above tradfri, maybe over the ‘20 years’ I’ll be ahead (Edit: though a pesent worth calculation would probably laugh at that contention), but then who knows what lights we’ll be using in 5 years time ???) and though our supply is both stiff and resilient, I never rely on that AND I have incorporated an SPD (surge protection device) at the incomer (stats attribute nearly 20% of all equipment failures to transients even in developed countries, a trend that has been exacerbated by the drift away from transformers to voltage dividers and choppers).
Different bulbs have different quoted lifespans and though the wife tends to leave lights on all over the house (I have added timers to ALL lights) I try to convert those lifespans into as many years as poss (reduces running costs twofold - bulb and power) even 15, 000 hours assuming 6 hours a day (my worst case) is 6.8 years. Some bulbs are 50,000 hrs.
The life of my switches is >= 20 yrs (longer than I’ll be in the house :rofl: )
If a switch goes then it’s just broke and it’ll be me (or a trician) who has to fix it. BUT if if HA goes down I can still switch everything just like a normal dumb house.

Edit: I don’t think my wife would be happy to wait a couple of days before getting a bulb changed, but I suppose you could just fit another unpaired tradfri and use the standard wall switch for that time

1 Like

Your insights are highly appreciated!
Good to hear that you are still able to control the light at the switch when HA goes down. Need to investigate the whole thing more, I even thought about doing some studies in the electrical field in order to be able to do mains powered stuff myself, but it’s probably overkill :rofl:

You are right, in case my wife would be home alone for a few days and a bulb would fail, I’d just tell her to replace the bulb and switch it with the standard wall switch.

Hi there,

I’m still having trouble with the transition. I wanted to add that in one of my automations, which looks like this:

- id: '1578176920150'
  alias: Licht WZ an 1
  description: ''
  trigger:
  - event: sunset
    offset: -00:15:00
    platform: sun
  condition:
  - condition: or
    conditions:
    - condition: zone
      entity_id: person.p1
      zone: zone.home
    - condition: zone
      entity_id: person.p2
      zone: zone.home
  action:
  - alias: ''
    data: {}
    entity_id: light.stern
    service: light.turn_on
  - entity_id: light.couch
    service: light.turn_on
  - entity_id: light.globus
    service: light.turn_on

I tried to enter the line

transition: 900

after each

service: light.turn_on

but then Hassio tells me that I have an error in my automation.yaml (after reloading) and the updated automation is not visible in the editor.
Where am I going wrong? Hints warmly welcome!

Carsten

The transition is part of the data: block. Try like this:

action:
  - service: light.turn_on
    entity_id: light.stern
    data:
       transition: 900
  - service: light.turn_on
    entity_id: light.couch
    data:
       transition: 900
  - service: light.turn_on
    entity_id: light.globus
    data:
       transition: 900
2 Likes

First success, the editor lets me save this. I keep the fingers crossed that my lights will dim to off later (with another automation of course)

For others: in the GUI-editor enter

transition: 900

in the service data box.

I forgot, you need to add the brightness that you want to have in the end. You can’t use transition without a brightness, except if you turn the light off.

1 Like

Thank you!
To set brightness for turning on also came to my mind and works as it should. The turning-of seems a bit odd at the moment but nothing that I should not be able to solve myself.