Thank you for your response. it would be nice if you give it a try.
I created sort off a little workaround. It dims the lights based on two scenes which are called from a script.
But i think if you manage to implement it, it would look better.
Workaround to dim light and then turn them off:
scenes.yaml
name: dim
entities:
light.grotetafel:
state: on
brightness: 2
transition: 5
light.kleinetafel:
state: on
brightness: 2
transition: 5
and
name: offf
entities:
light.grotetafel:
state: off
light.kleinetafel:
state: off
Waiting is not a problem at all for me. It’s already awesome what is done!
But i messed with it a little bit. I used your _ init_.py and yeelight.py from your github.
It should work right?
For me at least it is working fine with fade-to-on. But fade-to-off was not working. Which is kind of strange because the code for turnOn and turnOff is the same.
(But i read in the yeelight documentation that when the effect is sudden the parameter transition will be ignored. But then it would be strange turnOn is working. Maybe i have this all wrong i am not a developer only did a few things in vba excel this is another level)
I modified turnOff in _ init_.py to make the effect variable :
def turn_off(self, **kwargs):
"""Turn the bulb off."""
transtime = 0
effect = 'sudden'
if ATTR_TRANSITION in kwargs:
transtime = kwargs[ATTR_TRANSITION]
effect = 'smooth'
elif self.transition:
transtime = self.transition
if self.is_on:
self.bulb.turnOff(transtime, effect)
With this change fade-to On and Off is working for me, but it also comes with a problem and that is that i can’t use transition in scenes or anything. Only in config.yaml. When is use transition in a scene the default of 350 is used and not the value i entered.
But maybe i just have to wait till everything is merged?
@Mister-Espria Is this working? I ran into some issues setting my own lights up. For whatever reason when I was testing the fade on / fade off , it was working, but it shouldn’t have.
@jared No for me it isn’t working either. I have the same issue as in post 87
So only fade to on is working and fade to off is just instantly off.
Sorry for not reporting back but i have some segfault issues with my ha at the moment. But i’m gonna try your dependency now.
I will report back soon.
@jared I tried the code, but i don’t get it to turnoff the bulbs not with fading and not instantly.
I saw home assistant installing your v1.7, but to be sure which yeelight.py are you using your forked one or the one from mxtra from 17 days ago?
when turning off i get this in the log:
16-10-29 22:01:25 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1221, in job_handler
func(*args)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1075, in execute_service
service_handler.func(service_call)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/light/__init__.py", line 223, in handle_light_service
getattr(light, service_fun)(**params)
File "/home/hass/.homeassistant/custom_components/light/yeelight.py", line 135, in turn_off
self.bulb.turnOff()
TypeError: turnOff() missing 1 required positional argument: 'transtime'
@jared Thank you! now we are getting there. Fading on and off is now working. Turning off and on is also working but it uses (i think) the default transition time. I don’t know if this is intended or not?
When i use scenes with a transition time of 5000 it still uses the default transition time (i think because it’s a lot quicker than 5 seconds). When i use transition: 0 in a scene it will do it instantly.
This is not new in your code i had the same with the previous versions.
? I didn’t do anything. i’m just using your files. And if i have a solution for the current problem i’m happy to share it. But i don’t know if i can manage to get transition working.