Closed danodemano closed 7 years ago
Hi, I'm willing to help but don't have a color TPLink bulb so it's hard to debug. If I created a version with more debug are you in a position to test that?
Hi @gollo - should be able to. Just tell me what I need to do.
I think I've found something - could you put the attached file in, for example /srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/tplink.py or wherever your hass install is. I can tell you if you let me know if you are running python venv or hassbian generic linux (above example is this one).
Once it's in, restart hass. then play with the slider. Hopefully it just works, but you'll also see some debug log like this
2017-08-01 02:19:11 INFO (SyncWorker_2) [homeassistant.components.light.tplink] Using ATTR_COLOR_TEMP = 205
2017-08-01 02:19:11 INFO (SyncWorker_2) [homeassistant.components.light.tplink] sending 4878
You'll have to rename the attachment from tplink.txt to tplink.py. Let me know if you need help. tplink.txt
@gollo - looks like 0.50.2 fixed the color temp issue. However there is still no way to change the color from HASS.
I just created a PR which should add support for changing the color as long as everything is fine. As I don't have any of those bulbs I can't really test it myself, so please try it out and report bugs on that PR so I can fix it. Btw, the backend library provides a 'pyhs100' tool which can be used in command-line to test and debug these bulbs.
@rytilahti I would be happy to test it out, if you tell me how. :)
@danodemano you need to check out that git PR (or copy https://raw.githubusercontent.com/rytilahti/home-assistant/d5ffd04df8c6166f221fbf17482f60d851e8e0b0/homeassistant/components/light/tplink.py - to replace the tplink.py temporarily).
edit: to test the backend library it depends how you have installed homeassistant. if it is in a virtualenv environment, you need to activate that and then just use pyhs100
tool as described in the README here: https://github.com/GadgetReactor/pyHS100 or something like:
pyhs100 --ip 192.168.100.x --hsv H S V
(needs color in hsv format obviously...). There is apparently also support for reading out the power consumption of the device which could also be added if there's interest for such.
I'll opt for the second option as I don't have any way to check out your PR and test from my HA instance. Let me snapshot the VM then I'll test. Stand-by.
@rytilahti no color temp or color options at all: http://imgur.com/Pi9N6CF.jpg
The brightness slider works, as does turning it off. However I cannot turn it back on.
I'm going to need some logs to see what's the error :-) Could you also try out the console tool to see what it reports / are you getting errors there too? pyhs100 --bulb --ip <ip of the device> sysinfo
will also print out the full system information, for color support it looks for is_color
entry to see if color setting is supported.
I'm an idiot, sorry. I should have provided those (see the bottom of this message). As for the sysinfo:
[root@ha:~# pyhs100 --ip 192.168.9.199 sysinfo
== System info ==
{'active_mode': 'none',
'alias': 'Den',
'ctrl_protocols': {'name': 'Linkie', 'version': '1.0'},
'description': 'Smart Wi-Fi LED Bulb with Color Changing',
'dev_state': 'normal',
'deviceId': '801212E4C41D307BBF7058DF3978623518039092',
'disco_ver': '1.0',
'heapsize': 332072,
'hwId': '111E35908497A05512E259BB76801E10',
'hw_ver': '1.0',
'is_color': 1,
'is_dimmable': 1,
'is_factory': False,
'is_variable_color_temp': 1,
'light_state': {'brightness': 68,
'color_temp': 0,
'hue': 0,
'mode': 'normal',
'on_off': 1,
'saturation': 0},
'mic_mac': '50C7BF2503C3',
'mic_type': 'IOT.SMARTBULB',
'model': 'LB130(US)',
'oemId': '05BF7B3BE1675C5A6867B7A7E4C9F6F7',
'preferred_state': [{'brightness': 50,
'color_temp': 2700,
'hue': 0,
'index': 0,
'saturation': 0},
{'brightness': 100,
'color_temp': 0,
'hue': 0,
'index': 1,
'saturation': 75},
{'brightness': 100,
'color_temp': 0,
'hue': 120,
'index': 2,
'saturation': 75},
{'brightness': 100,
'color_temp': 0,
'hue': 240,
'index': 3,
'saturation': 75}],
'rssi': -67,
'sw_ver': '1.4.3 Build 170504 Rel.144921'}
](url)
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/__init__.py", line 279, in async_handle_light_service
yield from light.async_turn_on(**params)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/tplink.py", line 84, in turn_on
self.smartbulb.hsv = color_RGB_to_hsv(rgb[0], rgb[1], rgb[2])
TypeError: 'NoneType' object is not subscriptable
2017-08-01 20:31:53 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/__init__.py", line 279, in async_handle_light_service
yield from light.async_turn_on(**params)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/tplink.py", line 84, in turn_on
self.smartbulb.hsv = color_RGB_to_hsv(rgb[0], rgb[1], rgb[2])
TypeError: 'NoneType' object is not subscriptable
2017-08-01 20:33:51 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/__init__.py", line 279, in async_handle_light_service
yield from light.async_turn_on(**params)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/tplink.py", line 84, in turn_on
self.smartbulb.hsv = color_RGB_to_hsv(rgb[0], rgb[1], rgb[2])
TypeError: 'NoneType' object is not subscriptable
2017-08-01 20:33:52 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/__init__.py", line 279, in async_handle_light_service
yield from light.async_turn_on(**params)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/tplink.py", line 84, in turn_on
self.smartbulb.hsv = color_RGB_to_hsv(rgb[0], rgb[1], rgb[2])
TypeError: 'NoneType' object is not subscriptable
2017-08-01 20:33:56 WARNING (MainThread) [homeassistant.helpers.entity] Update for light.den is already in progress
2017-08-01 20:34:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/__init__.py", line 279, in async_handle_light_service
yield from light.async_turn_on(**params)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/tplink.py", line 84, in turn_on
self.smartbulb.hsv = color_RGB_to_hsv(rgb[0], rgb[1], rgb[2])
TypeError: 'NoneType' object is not subscriptable
My bad, the if clause on line 81 was wrong (not checking if it exists in the parameters..), I just updated the PR so please re-try. (https://github.com/rytilahti/home-assistant/blob/47ce7ebb8611add67af91527027f7ed3188f193c/homeassistant/components/light/tplink.py)
No dice for color: http://imgur.com/DWK5KOY.jpg
The on/off is working right though. As is the brightness. Nothing in the logs. If you want to setup a Skype or something let me know. I can get you into the server and point my webcam at the bulb.
I pushed yet another commit to fix a mistake on reporting, though the color temperature slider should have been visible already even without it... You could try to add a logging output (e.g. with _LOGGER.info(self.smartbulb.sysinfo)
) on the same level just before the line 119 which checks for the is_color
to see if it is detected correctly.
I have a weird feeling on working on someone else's server, but if you are on the discord channel we can try to debug there maybe?
I'm not seeing your new push. Either way let's take this to Discord, username 0110010001100010. Send me a DM and we'll dig into it.
Hi guys, did you get anywhere? I've got a version that at least should give you the color_temp and rgb colour picker when you click on the light. I've tested as best I can with a fake colour light object and it seems ok. You can get it here https://raw.githubusercontent.com/gollo/home-assistant/light_tplink_8766/homeassistant/components/light/tplink.py. Follow the same instructions as above to test. Thanks!
@rytilahti has the PR in that should have a fix. I'll be testing later this evening when I get home.
The problem currently in #8780 is that the values are/were delivered in an unexpected format, the patch you mentioned @gollo uses color_*
functions which do not work as the backend library expects H in degrees, and S & V in 0-100 (percent) format. The patch to do the conversion correctly is in that PR, but apparently still not completely correct. It is just hard to debug this without having a device, so.. :)
I see now, I can't test the colour either, just the white, but at least something.I know how to fix your linting issues and I have found other bugs with the white. Shall I include your rgb functions? I'm @gollo on discord if you want to chat.
On Fri, 4 Aug 2017, 21:21 Teemu R., notifications@github.com wrote:
The problem currently in #8780 https://github.com/home-assistant/home-assistant/pull/8780 is that the values are/were delivered in an unexpected format, the patch you mentioned @gollo https://github.com/gollo uses color_* functions which do not work as the backend library expects H in degrees, and S & V in 0-100 (percent) format. The patch to do the conversion correctly is in that PR, but apparently still not completely correct. It is just hard to debug this without having a device, so.. :)
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/8766#issuecomment-320344474, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJ2FC3QxG5ChRlAOgxtR83Yzparr9Kvks5sU31RgaJpZM4OpD0v .
@gollo - just sent you a friend request
The PR @rytilahti created (#8780) fixes the color issue. Thanks!
Home Assistant release (
hass --version
): 0.50.1Python release (
python3 --version
): Python 3.4.2Component/platform: TPLink Light Bulb
Description of problem: Cannot change color. In addition after changing the color temperature the slider simply disappears
Expected: Color change to work and temp slider not to vanish
Problem-relevant
configuration.yaml
entries and steps to reproduce:Additional info:
Since Github is being a bugger, pics on Imgur Pic showing no color: http://imgur.com/aTxsNL7.jpg Pic showing no slider after changing color temp: http://imgur.com/vqVahiP.jpg Pic showing slider coming back after a few minutes: http://imgur.com/VANgOUE.jpg