home-assistant / architecture

Repo to discuss Home Assistant architecture
315 stars 99 forks source link

Ability to configure default light transition #351

Closed timmccor closed 1 year ago

timmccor commented 4 years ago

Context

Currently when a light changes brightness level, it does so instantly. Various mechanisms for changing brightness exist, and as far as I'm aware most of them provide no ability to specify a transition - this only really works if you're manually calling the service. Previously Home Assistant would use a transition for brightness changes from some sources (Google Assistant is where my experience comes from), but this changed at some point - presumably due to another architecture change.

There ought to be a mechanism to configure home assistant such that state changes for which a transition is valid have a configurable default where not explicitly specified by the service call.

Proposal

I propose that we add a configurable default transition period to the light integration, which is applied when a transition has not been explicitly set. I also suggest we have transition on by default, set to the shortest value of 1 second.

Allowing this to be configured on a per-light basis would also be valuable, and I would suggest that compliments the light wide default, overriding it where specified for the specific light. Perhaps the user could configure this as a 'customisation'.

This could be delivered in a 2-phase approach:

1 - Light domain default for all lights 2 - Light specific default

The transition should apply to:

Consequences

It becomes easier/possible for users to make use of light transitions in their home assistant configuration. I can't think of any downsides to this approach, but I'm sure someone else can :)

dmulcahey commented 4 years ago

I'd like to see this at the HA level myself. We get asked to support this in ZHA a lot and i'd rather have an officially supported solution than have to hack this into ZHA.

timmccor commented 4 years ago

If I'm right @dmulcahey , putting the code into the light integration will add this capability for all lights regardless of what platform they're on, so should include ZHA. Certainly I've got ZHA bulbs so will be testing that scenario.

dmulcahey commented 4 years ago

If I'm right @dmulcahey , putting the code into the light integration will add this capability for all lights regardless of what platform they're on, so should include ZHA. Certainly I've got ZHA bulbs so will be testing that scenario.

Understood... was essentially adding a +1 to the proposal 😀

balloob commented 4 years ago

So you're saying that only if you change the brightness do you want a default transition, but not when you change color or turn things on/off?

Adminiuga commented 4 years ago

My personal take: it should apply to turning on/off and I'd say to color and/or temperature transitions too

timmccor commented 4 years ago

@balloob I had not realised that the transition also applies to colour and light temperature changes - I don't yet have any bulbs with those features. I suggest the default transition is on wherever relevant.

I also suggest it applies to on/off states too.

I will edit the proposal with this in mind.

frenck commented 4 years ago

I do like this proposal.

Some concerns:

donkawechico commented 4 years ago

Still new to HA dev, but have done a bit of work in this domain recently.

How would this fit in our configuration? How would a user set this up?

The most intuitive thing to me would be allowing this schema for light:

# configuration.yaml
light:
  defaults:
    transition: 5
    brightness: 200
  entities:
    - platform: mqtt
      name: chandelier
   #...

But I'm not sure how messy it would be to support that + the existing schema.

Other options:

# configuration.yaml

# Option 1 -- top-level generic defaults (if we want to allow for other domain defaults in the future)
homeassistant:
  defaults:
    light:
      transition: 5
      brightness: 200

# Option 2 -- new generic defaults integration
defaults:
  light:
    transition: 5
    brightness: 200

# Option 3 -- new non-generic "light_defaults" integration
light_defaults:
  transition: 5
  brightness: 200

Some devices may support a default transition natively already...

How do such bulbs currently handle it when a user sends transition in a service call? I assume all light device integrations have been built knowing they could be sent a transition parameter?

The way I see it, "default transition" in an HA context simply means "if the service call didn't receive a transition param, send this one to the device".

liranco commented 2 years ago

It's possible to achieve it via light_profiles.csv:

profile,color_x,color_y,brightness,transition
group.all_lights.default,,,,0.5

All lights are part of the profile group.all_lights.default, and only the transition column is being applied to the profile.

frenck commented 1 year ago

This architecture issue is old, stale, and possibly obsolete. Things changed a lot over the years. Additionally, we have been moving to discussions for these architectural discussions.

For that reason, I'm going to close this issue.

../Frenck