Skip to content

Commit

Permalink
add get gamut information (#13)
Browse files Browse the repository at this point in the history
* add get gamut information

* add attrs requirement

* small correction

self.controlcapabilities is variable not function
self.controlcapabilities() --> self.controlcapabilities

* switch from attrs to namedtuple

* remove attrs depandancy
  • Loading branch information
starkillerOG authored and balloob committed Jan 14, 2019
1 parent 6614a8a commit 9ae5d9e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions aiohue/lights.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
from .api import APIItems
from collections import namedtuple


# Represents a CIE 1931 XY coordinate pair.
XYPoint = namedtuple('XYPoint', ['x', 'y'])


# Represents the Gamut of a light.
GamutType = namedtuple('GamutType', ['red', 'green', 'blue'])


class Lights(APIItems):
Expand Down Expand Up @@ -52,6 +61,29 @@ def swversion(self):
"""Software version of the light."""
return self.raw['swversion']

@property
def controlcapabilities(self):
"""Capabilities that the light has to control it."""
return self.raw.get('capabilities', {}).get('control', {})

@property
def colorgamuttype(self):
"""The color gamut type of the light."""
light_spec = self.controlcapabilities
return light_spec.get('colorgamuttype', 'None')

@property
def colorgamut(self):
"""The color gamut information of the light."""
try:
light_spec = self.controlcapabilities
gtup = tuple([XYPoint(*x) for x in light_spec['colorgamut']])
color_gamut = GamutType(*gtup)
except KeyError:
color_gamut = None

return color_gamut

async def set_state(self, on=None, bri=None, hue=None, sat=None, xy=None,
ct=None, alert=None, effect=None, transitiontime=None,
bri_inc=None, sat_inc=None, hue_inc=None, ct_inc=None,
Expand Down

0 comments on commit 9ae5d9e

Please sign in to comment.