I’ve been using this for years and thought I should share it. Support on/off, brightness and profile via effect. Does not support api keys yet as I don’t use the feature. Please let me know what features you are missing.
Thanks so much for this!
I’ve tried to implement it, however I’m having problems. How does one setup the config in HASS?
After adding the following to my lights.yaml, the switch turns on, but immediately turns off. The brightness slider works and I can only turn the lightpack off by dragging the slider to zero.
Your assistance would be much appreciated!
2018-09-09 01:01:45 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.lightpack fails
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
yield from self.async_device_update()
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 353, in async_device_update
yield from self.hass.async_add_job(self.update)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/light/lightpack.py", line 197, in update
self._mode = self._update.getMode()
AttributeError: 'Lightpack' object has no attribute 'getMode'
Ok, I’ve updated the file and removed the cache folder, after rebooting and enabling debug logging, I receive the following:
After I switch on the Lightpack, it turns on, but the switch immediately turns off. I am on able to turn off by dragging the bightness slider to 0.
2018-09-10 18:56:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.lightpack>
2018-09-10 18:56:54 DEBUG (MainThread) [custom_components.light.lightpack] Lightpack: available(); result: True
2018-09-10 18:56:54 DEBUG (SyncWorker_4) [custom_components.light.lightpack] Lightpack: lock()
2018-09-10 18:56:54 DEBUG (SyncWorker_4) [custom_components.light.lightpack] Lightpack: turn_on()
2018-09-10 18:56:54 DEBUG (SyncWorker_4) [custom_components.light.lightpack] Lightpack: unlock()
2018-09-10 18:56:54 DEBUG (SyncWorker_19) [custom_components.light.lightpack] Lightpack: connect()
2018-09-10 18:56:54 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.lightpack fails
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
yield from self.async_device_update()
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 353, in async_device_update
yield from self.hass.async_add_job(self.update)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/light/lightpack.py", line 198, in update
brightness = self._update.getBrightness()
AttributeError: 'Lightpack' object has no attribute 'getBrightness'
Hi Mihalski,
Thanks alot for your assistance with this!
I’m receiving the following error in my logs every 30 seconds:
2018-09-15 08:19:34 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.lightpack fails
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
yield from self.async_device_update()
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 353, in async_device_update
yield from self.hass.async_add_job(self.update)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/light/lightpack.py", line 225, in update
brightness = self._update.getBrightness()
AttributeError: 'Lightpack' object has no attribute 'getBrightness'
Are there maybe any specific options that need to be setup on the Prismatik side?
BTW, I’ve found that I can use the brightness slider to turn the Lightpack on and I’m able to adjust the brightness. If I drag the brightness slider to 0 the lightpack turns off. So its just the switch that I’m having issues with, but I see that in your code it is reliant on the brightness and effect attributes.
I’ve read that ATTR_BRIGHTNESS for the light entity isn’t really reliable since it can give null values. Dunno if that has anything to do with it? I’m not a programmer, so my input is probably utterly useless
I know it’s been a while, but in case you want a working component all you have to do is on line 203 I think just set it to brightness = 100 #self._update.getBrightness()
You’ll lose brightness control (but really I just care about on/off more than brightness. If I want it dim I’ll usually just have it off anyway), but gain everything else.