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

Use a service adaptive lightning to turn light On #72

Open bilbon0bud opened 3 years ago

bilbon0bud commented 3 years ago

Hello

Could it be possible to use a service for the light on ? I use the custom component Adaptive Lightning, this component is used to calculate the best brightness et temp for the light during the day and to change the light properties when they are on. It could be call with a list of light to turn them on at the brightness and temp color that should be use now, it could be reallly cool to permit a service call like this with automoli.

so automoli make light auto on or off, and adaptive lightining make the automation for brightness and color temp.

Best Regards

paviro commented 3 years ago

Hi @bilbon0bud, You can easily already use the Adaptive Lightning component. I do the following:

Scenes:

- name: Schlafzimmer Normal
  icon: "mdi:flower-tulip"
  entities:
    switch.adaptive_lighting_default:
      state: "on"
    light.schlafzimmer_decke:
      state: "on"

- name: Schlafzimmer Abend
  icon: "mdi:flower-tulip"
  entities:
    switch.adaptive_lighting_default:
      state: "on"
    light.schlafzimmer_decke:
      state: "on"
    light.schlafzimmer_bett:
      state: "on"
    light.schlafzimmer_bucherregal:
      state: "on"
    light.schlafzimmer_schreibtisch:
      state: "on"

- name: Schlafzimmer Entspannend
  icon: "mdi:flower-tulip"
  entities:
    switch.adaptive_lighting_default:
      state: "off"
    light.schlafzimmer_bett:
      state: "on"
      brightness: 254
    light.schlafzimmer_bucherregal:
      state: "on"
      brightness: 150
      color_temp: 454
    light.schlafzimmer_schreibtisch:
      state: "on"
      brightness: 80
      color_temp: 454
    light.schlafzimmer_decke_1:
      state: "on"
      brightness: 254
      hs_color:
        - 213.093
        - 76.078
    light.schlafzimmer_decke_2:
      state: "on"
      brightness: 220
      hs_color:
        - 330
        - 83.137
    light.schlafzimmer_decke_3:
      state: "on"
      brightness: 254
      hs_color:
        - 26.814
        - 88.627

- name: Schlafzimmer Nacht
  icon: "mdi:flower-tulip"
  entities:
    switch.adaptive_lighting_default:
      state: "off"
    light.schlafzimmer_decke_1:
      state: "on"
      brightness: 2
      hs_color:
        - 30
        - 85.714
    light.schlafzimmer_bucherregal:
      state: "on"
      brightness: 2
      color_temp: 454

adaptive_lighting:

adaptive_lighting:
   - name: "default"
     lights:
        - light.schlafzimmer_decke_1
        - light.schlafzimmer_decke_2
        - light.schlafzimmer_decke_3
        - light.schlafzimmer_bett
        - light.schlafzimmer_bucherregal
        - light.schlafzimmer_schreibtisch
     prefer_rgb_color: true
     min_color_temp: 2700
     transition: 45
     initial_transition: 1
     interval: 90
     take_over_control: true
     only_once: false

automoli:

schlafzimmer_bewegungsmelder:
  module: automoli
  class: AutoMoLi
  room: Schlafzimmer
  disable_switch_entities:
    - input_boolean.bewegungsmelder
    - input_boolean.bewegungsmelder_schlafzimmer
  disable_switch_states: "off"
  delay: 300
  daytimes:
    - { starttime: "04:00", name: morning, light: "scene.schlafzimmer_normal" }
    - { starttime: "sunset-01:30", name: evening, light: "scene.schlafzimmer_abend" }
    - { starttime: "sunset+00:30", name: relaxed, light: "scene.schlafzimmer_entspannend" }

  night_mode:
    entity: input_boolean.night_mode
    light: "scene.schlafzimmer_nacht"

  motion_state_on: "on"
  motion_state_off: "off"
  motion:
    - binary_sensor.schlafzimmer_treppe_bewegung

  only_own_events: false
  transition_on_daytime_switch: true

This works great for me.

paviro commented 3 years ago

After using the above workaround for a while I have to agree with @bilbon0bud that this would be a great improvement. Using scenes like this has the problem that it makes the light slower to react to motion events when using zig bee networks as too many commands are sent at once. First automoli enables the lights, then adaptive lighting changes all of them again directly. This causes some light to turn on delayed sometimes for half a minute or longer.

SergioRius commented 2 years ago

After using the above workaround for a while I have to agree with @bilbon0bud that this would be a great improvement. Using scenes like this has the problem that it makes the light slower to react to motion events when using zig bee networks as too many commands are sent at once. First automoli enables the lights, then adaptive lighting changes all of them again directly. This causes some light to turn on delayed sometimes for half a minute or longer.

Hello @paviro it has been some time since you posted the above solution but anyways I would want to ask you about it. I tried to implement it in my setup. Simpler, with only two scenes. But Automoli always complains about not having any light specified. I wonder if in that time you have been forced to change something (or stopped using it altogether).

My hallway lights don't turn on on movement. I don't know if this message has something to do:

2022-09-07 11:48:47.666167 INFO hallway: ⚠️ No lights/sensors given and none found with name: 'light.*hallway*' or 'binary_sensor.motion_sensor_*hallway*'

And my config is:

hallway:
  module: automoli
  class: AutoMoLi
  room: hallway
  only_own_events: false
  transition_on_daytime_switch: true
  delay: 60
  daytimes:
    - { starttime: "07:00", name: normal, light: "scene.hallway_lights_normal" }
    - { starttime: "22:30", name: sleeptime, light: "scene.hallway_lights_sleeping" }
  motion:
    - binary_sensor.pasillo_pir1_occupancy
    - binary_sensor.pasillo_pir2_occupancy
  motion_state_on: 'on'
  motion_state_off: 'off'

Note: the room hallway doesn't match to any light name, but I expected to just trigger the scenes. I've checked that those scenes work if triggered manually.

BTW my experience with this module it's been so infortunate. Yesterday with a plain pir to light setup it hung my zigbee container. Don't know why.

TheNoim commented 2 years ago

I think it would be awesome, if automoli would have the possibility to just turn lights on and off without using scenes.

Example:

flur_light:
  module: automoli
  class: AutoMoLi
  debug_log: true
  room: flur
  daytimes:
    - { starttime: "sunrise", name: morning, light: "off" }
    - { starttime: "sunset-01:00", name: evening, light: "on" }
  lights:
    - light.flur_deckenlicht
  motion:
    - binary_sensor.0x00124b0025091116_occupancy
    - binary_sensor.0x00124b0025090f28_occupancy
  motion_state_on: "on"
  motion_state_off: "off"
  delay: 1

Instead of triggering scenes called on and off, just turn the lights on and off.

paviro commented 2 years ago

I think it would be awesome, if automoli would have the possibility to just turn lights on and off without using scenes.

Example:

flur_light:
  module: automoli
  class: AutoMoLi
  debug_log: true
  room: flur
  daytimes:
    - { starttime: "sunrise", name: morning, light: "off" }
    - { starttime: "sunset-01:00", name: evening, light: "on" }
  lights:
    - light.flur_deckenlicht
  motion:
    - binary_sensor.0x00124b0025091116_occupancy
    - binary_sensor.0x00124b0025090f28_occupancy
  motion_state_on: "on"
  motion_state_off: "off"
  delay: 1

Instead of triggering scenes called on and off, just turn the lights on and off.

It already does, see README. You can set a percentage instead of a scene name.

TheNoim commented 2 years ago

It already does, see README. You can set a percentage instead of a scene name.

Where? If I found this, I wouldn't make that comment. Because my exact example, tries to trigger a scene "on" or "off". It works at night, but in the day it just turns on the lights anyway.

paviro commented 2 years ago
flur_light:
  module: automoli
  class: AutoMoLi
  debug_log: true
  room: flur
  daytimes:
    - { starttime: "sunrise", name: morning, light: 0 }
    - { starttime: "sunset-01:00", name: evening, light: 100}
  lights:
    - light.flur_deckenlicht
  motion:
    - binary_sensor.0x00124b0025091116_occupancy
    - binary_sensor.0x00124b0025090f28_occupancy
  motion_state_on: "on"
  motion_state_off: "off"
  delay: 1
TheNoim commented 2 years ago

But this controls the brightness. I don't want this. It should only send on and off.

paviro commented 2 years ago

Then use a helper Boolean and disable_switch_entities to disable the motion sensing during the day. You can then remove the daytime array and it will only toggle on and off.

I am at work right now but with the keywords helper Boolean and then the disable_switch_entities config you should be able to figure it out. If not I can help a bit more in detail later.

TheNoim commented 2 years ago

Then use a helper Boolean and disable_switch_entities to disable the motion sensing during the day.

This is a work around. But then I can also just use scenes, which fit this much better. However, they are annoying to write. This is why I asked for this feature natively not for another workaround. I will look into making a PR. This shouldn't be that hard.

paviro commented 2 years ago

But what exactly are you asking for? You asked to turn lights on and off which is the default for automoli already when not specifying a daytime array. To disable motion sensing for a specific time (which is what you seem to want) the disable entities work great. Sure it could be included as a separate feature but it’s easily doable already and this way much more flexible.

Also this isn’t really related to calling services for things like adaptive lighting maybe a separate issue makes more sense.

TheNoim commented 2 years ago

But what exactly are you asking for? You asked to turn lights on and off which is the default for automoli already when not specifying a daytime array. To disable motion sensing for a specific time (which is what you seem to want) the disable switch works great. Sure it could be included as a separate feature but it’s easily doable already and this way much more flexible.

It makes sense. I want to define my times in the daytimes array. I don't want to use an external boolean which then in return I need to control separately.

his way much more flexible.

Maybe more flexible, but also more annoying to use. And at some point more messy.

Also this isn’t really related to calling services for things like adaptive lighting maybe a separate issue makes more sense.

It is a bit related. Because I only have this issue because I use adaptive lighting.

paviro commented 2 years ago

I see. I think the daytime array was meant to change the brightness etc for people not using things like adaptive lighting.

But it would indeed make it more flexible to include a turn off or at least turn off the light if the brightness is set to 0.

SergioRius commented 2 years ago

But what exactly are you asking for? You asked to turn lights on and off which is the default for automoli already when not specifying a daytime array. To disable motion sensing for a specific time (which is what you seem to want) the disable entities work great. Sure it could be included as a separate feature but it’s easily doable already and this way much more flexible.

Also this isn’t really related to calling services for things like adaptive lighting maybe a separate issue makes more sense.

If using your suggestion of specifying brightness all the circadian automations and integrations go offline for those lights as they will interpret an override/manual switching.

And what you are saying in the quote above is not possible because as soon as you add a second zone, automoli brings errors if all the zones are not configured with daytimes. There's an issue about this. All the people is forced to use daytimes even those that they don't really need'm.

Tha's probably the issue @TheNoim has.

paviro commented 2 years ago

Forgot about that bug in the moment. I think I introduced it see #87 - will try to check again if I find out why.