-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for GU10 lights #141
Conversation
tests/devices.py
Outdated
"5709":30138, | ||
"5710":26909, | ||
"5706":"efd275", | ||
"9003":0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"5711":450, | ||
"5709":30138, | ||
"5710":26909, | ||
"5706":"efd275", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"5717":0, | ||
"5711":450, | ||
"5709":30138, | ||
"5710":26909, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"5850":0, | ||
"5717":0, | ||
"5711":450, | ||
"5709":30138, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"5851":10, | ||
"5850":0, | ||
"5717":0, | ||
"5711":450, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"3":{ | ||
"0":"IKEA of Sweden", | ||
"1":"TRADFRI bulb GU10 WS 400lm", | ||
"2":"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"9019":1, | ||
"3":{ | ||
"0":"IKEA of Sweden", | ||
"1":"TRADFRI bulb GU10 WS 400lm", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"9054":0, | ||
"9019":1, | ||
"3":{ | ||
"0":"IKEA of Sweden", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"9003":65540, | ||
"9054":0, | ||
"9019":1, | ||
"3":{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
tests/devices.py
Outdated
"9020":1516008285, | ||
"9003":65540, | ||
"9054":0, | ||
"9019":1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
pytradfri/device.py
Outdated
class LightControl: | ||
"""Class to control the lights.""" | ||
class DeviceControl: | ||
"""Superclass to control lights.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to control devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed this now
pytradfri/device.py
Outdated
"""Return raw data that it represents. | ||
If regular bulb=>ATTR_LIGHT_CONTROL If GU10 light=>ROOT_SWITCH.""" | ||
if ATTR_LIGHT_CONTROL in self._device.raw: | ||
return self._device.raw[ATTR_LIGHT_CONTROL] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type should come from another func, maybe _device_type
? This then means we only have one place we do the selection.
I feel that in the future device.light_control
and device.has_light_control
will be confusing, so we may need to move this logic up to Device
, which can then return the appropriate Control class for the type, making DeviceControl
the super.
Then we'd have three functions on Device
;
device_control
(I don't care what type it is, I just want to be able to switch the device on/off)light_control
(I want light specific control functions)switch_control
(I want switch specific functions, whatever these may be)
However, it's very frustrating that the GU10 bulb is identified as a switch, as this makes the API very confusing to a user, I'm not sure there is a neat way for us to handle this.
The way this stands today, if IKEA release a switch tomorrow the API will allow someone to change the brightness on a switch... Not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lwis thanks! I will give this some more consideration and revert. On switches, I believe they call their "switch" a "plug", so it might be put in a whole different root path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lwis should we wait for the plugs to be released before we do the reshuffling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's wise, as we'll have to do some work to support it anyway.
@lwis ok, let's talk more on structure of classes later on. Good to merge once it's been user tested? |
LGTM |
👍🏻 (I had to look that one up in urban dictionary 🙈) |
Closes #135