benleb / ad-automoli

💡 Fully automatic light management based on conditions like motion, illuminance, humidity, and other clever features
https://github.com/benleb/ad-automoli
MIT License
112 stars 29 forks source link

Dim lights before switching them off #10

Closed chbndrhnns closed 3 years ago

chbndrhnns commented 4 years ago

Would it be possible to dim lights to some level for some time before switching them off?

benleb commented 4 years ago

as some kind of "warning" to move or the lights will switch off? That could indeed be useful!

chbndrhnns commented 4 years ago

I like how it is implemented for Deconz. Sadly, this cannot be re-used in home assistant yet.

benleb commented 4 years ago

To be honest, something like this looks not really useful to me. It looks nice, but I am not sure if it has real value. If no one moves, the lights could be switched of or?! Whats the use case for dimming the lights over 10 or 20min in steps if you are not there anymore?

chbndrhnns commented 4 years ago

My intention was to point out where I got the idea from, not to ask for that specific implementation. As a warning, I find it really helpful to not be in darkness immediately.

benleb commented 4 years ago

So lets think about how this could be implemented (one dimming stage before switching off for now, thats easier to talk about for now)... An absolute time before switching off or after switching on? Or a relative one maybe? And the same for the dimming, decrease the brightness by an absolute or relative value? and what about scene? just touch the brightness value if the configured setting is a scene?

Currently an absolut time value (in seconds probably) which dimms to 80% (or 50%?) before switching off seems reasonable to me. What would you (and maybe others reading this :)) prefer?

Sure, it would be possible to implement every possible way listed above, but that would add really much complexity.

chbndrhnns commented 4 years ago

Yeah, let's start with what's most simple. For the use case of "I'll warn you that I am being turned off soon", I would like to see

Also, if new motion is detected, the dim stage should be aborted.

atterdal commented 4 years ago

Was going to issues to ask if this was possible. This would be an amazing for bathrooms.

efurban commented 4 years ago

It'll be nice to have a "Fade Rate" feature, or Fade On, Fade Off separately. (In Insteon, it's called Ramp Rate). The issue is that not all protocols/platforms provide this feature (Lutron Caseta does not) so it'll be nice to have it here instead. E.g:

  fade_rate: 5 
  daytimes:
    - { starttime: "02:00", name: late_night, light: 50 }
    - { starttime: "08:30", name: day, light: 100 }
kroimon commented 4 years ago

Would it be possible to mimic the deconz feature by defining a list of delay/value pairs for the daytimes/light parameter? So something like this:

daytimes:
  - starttime: "02:00"
    name: late_night
    light:
      - 100
      - delay: 60
        value: "FadeOutScene"
      - delay: 120
        value: 0
  - { starttime: "08:30", name: day, light: 100 }

This would give you the flexibility of deconz, but keeps the simple configuration style if you just want to have a two-step fade-out.

thundergreen commented 4 years ago

I was also thinking about this feature and find it really helpful as my lights turn off completely but sometimes it's just nice having a dimmed mode.... maybe with timer before turning off completely or the possibility to deactivate turn off and let it dimmed?

adec commented 4 years ago

Just looking into this, I like the idea of being able to specify scenes for the intermediate state as it gives the flexibility of perhaps turning a light a different colour rather than dimming it.

X1pheR commented 3 years ago

Any chance this will get implemented (since request was from januari)? I still have a lot of lights with all motion sensors on Hue because of this missing feature in Home Assistant. Hue natively dims the lights for 10 seconds or so before turning off the lights when triggered by motion. I love it because it indeed acts as a warning that the lights go off triggering you to move :)

kroimon commented 3 years ago

With the new restart mode in HA, I created the following automation directly in HA to turn on the kitchen lights when motion is detected and when the motion sensor turns back to idle while the lights are still on, it will first dim the lights, then turn them off after one minute. If motion is detected during the dim period, the automation will simply restart, turning the lights back on.

- alias: Kitchen: Motion detected
  mode: restart
  trigger:
  - type: motion
    platform: device
    domain: binary_sensor
    device_id: 56754e39c3874eb39d7181dfd3d682ae
    entity_id: binary_sensor.motionsensor_kitchen
  condition:
  - condition: numeric_state
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
    below: '8.5'
  action:
  - service: light.turn_on
    entity_id: light.group_kitchen
    data:
      brightness_pct: 100
      transition: 2
  - wait_template: '{{ is_state(trigger.entity_id, ''off'') }}'
  - condition: device
    domain: light
    device_id: ae538670194e4fd18ce4c721eb0faa9f
    entity_id: light.group_kitchen
    type: is_on
  - service: light.turn_on
    entity_id: light.group_kitchen
    data:
      brightness_pct: 50
      transition: 2
  - delay: 00:01:00
  - service: light.turn_off
    entity_id: light.group_kitchen
    data:
      transition: 2
benleb commented 3 years ago

Any chance this will get implemented (since request was from januari)? I still have a lot of lights with all motion sensors on Hue because of this missing feature in Home Assistant. Hue natively dims the lights for 10 seconds or so before turning off the lights when triggered by motion. I love it because it indeed acts as a warning that the lights go off triggering you to move :)

sorry, I am in the last weeks of my thesis currently and have no real time for open source projects :/ but! taking care of this and all other issues is planned to start at the end of November :) 🎉

X1pheR commented 3 years ago

With the new restart mode in HA, I created the following automation directly in HA to turn on the kitchen lights when motion is detected and when the motion sensor turns back to idle while the lights are still on, it will first dim the lights, then turn them off after one minute. If motion is detected during the dim period, the automation will simply restart, turning the lights back on.

- alias: Kitchen: Motion detected
  mode: restart
  trigger:
  - type: motion
    platform: device
    domain: binary_sensor
    device_id: 56754e39c3874eb39d7181dfd3d682ae
    entity_id: binary_sensor.motionsensor_kitchen
  condition:
  - condition: numeric_state
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
    below: '8.5'
  action:
  - service: light.turn_on
    entity_id: light.group_kitchen
    data:
      brightness_pct: 100
      transition: 2
  - wait_template: '{{ is_state(trigger.entity_id, ''off'') }}'
  - condition: device
    domain: light
    device_id: ae538670194e4fd18ce4c721eb0faa9f
    entity_id: light.group_kitchen
    type: is_on
  - service: light.turn_on
    entity_id: light.group_kitchen
    data:
      brightness_pct: 50
      transition: 2
  - delay: 00:01:00
  - service: light.turn_off
    entity_id: light.group_kitchen
    data:
      transition: 2

Nice! Thanks for sharing. I'm still a newbie so will try and work this out for my setup. Your motion sensor does not have a light sensor since you are using the sun elevation? How do I know which device id I have?

Do you also by any chance have something like this for hue dimmer switches? I have some directly on deconz now but you loose the functionality to tap the on button multiple times to change between different scenes/light settings.

X1pheR commented 3 years ago

Any chance this will get implemented (since request was from januari)? I still have a lot of lights with all motion sensors on Hue because of this missing feature in Home Assistant. Hue natively dims the lights for 10 seconds or so before turning off the lights when triggered by motion. I love it because it indeed acts as a warning that the lights go off triggering you to move :)

sorry, I am in the last weeks of my thesis currently and have no real time for open source projects :/ but! taking care of this and all other issues is planned to start at the end of November :) 🎉

Totally understandable. Thank you for your quick response and good luck with your thesis ;)

paviro commented 3 years ago

I would also love to see this! Very much like the original Hue bridge does it. Dimm it down over 5-10 seconds or so to give you the chance to move enough.

Hope your thesis is going alright!

benleb commented 3 years ago

https://github.com/benleb/ad-automoli/commit/4ed699a856bbacc0ea2afef03604f0682c10b5ee

it works but probably has some bugs... do not use it if you need reliable lights ;)

thundergreen commented 3 years ago

Will try and report :) any special config needed?

paviro commented 3 years ago

Will test when I am back at home from work on Thursday :)

thundergreen commented 3 years ago
Can we havea config example for this feature? Gesendet von Mail für Windows 10 Von: Paul-Vincent RollGesendet: Montag, 23. November 2020 18:06An: benleb/ad-automoliCc: ThUnD3r|Gr33n; CommentBetreff: Re: [benleb/ad-automoli] Dim lights before switching them off (#10) That was fast! Will Test when I am back at home from work on Thursday :)—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe. 
benleb commented 3 years ago

ah sorry 😅 but expect it to slightly change until officially released and documented ;)

transition style

starts seconds_before seconds before the light will turn off to smoothly turn down the lights until off. uses the transition parameter in home assistant

diningroom:
  module: automoli
  class: AutoMoLi
  disable_switch_entities: [input_boolean.automoli]
  disable_hue_groups: true
  room: esszimmer
  delay: 300
  dim:
    method: transition
    seconds_before: 10

step style

dims the lights by brightness_step_pct, seconds_before seconds before the light will turn off. uses the brightness_step_pct parameter in home assistant

bedroom:
  module: automoli
  class: AutoMoLi
  disable_switch_entities: [input_boolean.automoli]
  disable_hue_groups: true
  room: schlafzimmer
  delay: 180
  dim:
    method: step
    brightness_step_pct: -30
    seconds_before: 20
paviro commented 3 years ago

Installed it :) Is it correct that the dimming parameters are not shown yet in the summary log of ad yet? Also dimming down works perfectly but it does not seem to get cancelled when motion is detected during dimming?

dim:
    method: transition
    seconds_before: 10
paviro commented 3 years ago

The last commits seem to have fixed the canceling but it only worked until I updated to Home Assistant 2020.12.0 now the lights show as turned on in home assistant but in reality they dim down and won't turn back on ever as home assistant sees them as on. Not sure if this is a HA bug or an issue here.

benleb commented 3 years ago

Installed it :) Is it correct that the dimming parameters are not shown yet in the summary log of ad yet?

ah yes, thanks, fixed in https://github.com/benleb/ad-automoli/commit/c4add6c89025cb6b11240ad3f05032a82594c046f

The last commits seem to have fixed the canceling but it only worked until I updated to Home Assistant 2020.12.0 now the lights show as turned on in home assistant but in reality they dim down and won't turn back on ever as home assistant sees them as on. Not sure if this is a HA bug or an issue here.

Hm sounds as you have a problem with your lights? I don't think thats an automoli issue as automoli relies on the state-informations from home assistant and cannot work as it should when this info is wrong.

chbndrhnns commented 3 years ago

I also have the impression that starting with Homeassistent 2020.12.0, something is off with automoli, as well. The humidity-controlled bathroom light is no longer respecting the humidity sensor value and just turns off. Any idea how to debug that? @benleb

paviro commented 3 years ago

I don’t think it’s the lights as they were fine before the Home assistant update. But again I also don’t really can image it being automoli. Seems more like a home assistant bug.

benleb commented 3 years ago

Ok so we have problems since 2020.12...

Anything else? If you have other info which could be useable, tell me ;) I will try to reproduce this and find the bug over the weekend ✌️

As automoli does not change the state directly, just via the home assistant services, I expect that if lights have a wrong state in home assistant, it must be something else... But will investigate this too!

benleb commented 3 years ago

lets move to the new issue here to keep things separate.

As the feature requested here is implemented, I will close here and release this weekend :)