Hi Guys,
Since it’s my first post, let me say that HASS is just an awesome project. I recently migrate over from OpenHAB and I already achieved more in one week than with OpenHAB in couple of months. Still - I’m not a python developer, so excuse my noob questions.
I’m trying to develop custom component for great BLEBOX wLightBoxS - wifi enabled LED dimmer. I used this document as an example:
Since this device is http controlled, I need some http library, I usually use urllib. So I created following component, but it’s throwing error during HASS start:
Error:
Oct 03 23:02:41 orangepiplus2e hass[1503]: 2017-10-03 23:02:41 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform blebox_wlightboxs
Oct 03 23:02:41 orangepiplus2e hass[1503]: Traceback (most recent call last):
Oct 03 23:02:41 orangepiplus2e hass[1503]: File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 164, in _async_setup_platform
Oct 03 23:02:41 orangepiplus2e hass[1503]: SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
Oct 03 23:02:41 orangepiplus2e hass[1503]: File “/usr/lib/python3.4/asyncio/tasks.py”, line 372, in wait_for
Oct 03 23:02:41 orangepiplus2e hass[1503]: return fut.result()
Oct 03 23:02:41 orangepiplus2e hass[1503]: File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
Oct 03 23:02:41 orangepiplus2e hass[1503]: raise self._exception
Oct 03 23:02:41 orangepiplus2e hass[1503]: File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
Oct 03 23:02:41 orangepiplus2e hass[1503]: result = self.fn(*self.args, **self.kwargs)
Oct 03 23:02:41 orangepiplus2e hass[1503]: File “/home/homeassistant/.homeassistant/custom_components/light/blebox_wlightboxs.py”, line 33, in setup_platform
Oct 03 23:02:41 orangepiplus2e hass[1503]: if urllib3.urlopen(device).getcode() != 200:
Oct 03 23:02:41 orangepiplus2e hass[1503]: AttributeError: ‘module’ object has no attribute ‘urlopen’
I have no idea how to properly import urllib3
Another question is how to easier debug the code for custom components - right now I need to restart HASS every time I update the code.
Thanks in advance!