15
|
1 import logging
|
|
2 from dataclasses import dataclass
|
|
3
|
|
4 from color import Color
|
|
5
|
|
6 log = logging.getLogger('conv')
|
|
7
|
|
8
|
|
9 @dataclass(frozen=True)
|
|
10 class DeviceColor:
|
|
11 """neutral representation of the adjusted color that we send to a device"""
|
|
12 r: float = 0
|
|
13 g: float = 0
|
|
14 b: float = 0
|
|
15 w: float = 0
|
|
16 x: float = 0
|
|
17 y: float = 0
|
|
18 brightness: float = 0
|
|
19
|
|
20 def summary(self) -> dict:
|
|
21 return dict([(k, round(v, 3)) for k, v in self.__dict__.items() if v > 0])
|
|
22
|
|
23 # fix this to send what z2m likes
|
|
24 def zbConv(c: Color) -> DeviceColor:
|
|
25 return DeviceColor(r=c.r, g=c.g, b=c.b, brightness=max(c.r, c.g, c.b))
|