device: brightness and color temperature calculations corrected
This commit is contained in:
parent
1c417fb73f
commit
f86ad1813c
@ -580,17 +580,17 @@ class tradfri_light(base):
|
|||||||
|
|
||||||
def unpack_filter(self, key):
|
def unpack_filter(self, key):
|
||||||
if key == self.KEY_BRIGHTNESS:
|
if key == self.KEY_BRIGHTNESS:
|
||||||
self[key] = (self[key] - 1) * 100 / 254
|
self[key] = round((self[key] - 1) * 100 / 253, 0)
|
||||||
elif key == self.KEY_COLOR_TEMP:
|
elif key == self.KEY_COLOR_TEMP:
|
||||||
self[key] = (self[key] - 250) * 10 / 204
|
self[key] = round((self[key] - 250) * 10 / 204, 0)
|
||||||
else:
|
else:
|
||||||
super().unpack_filter(key)
|
super().unpack_filter(key)
|
||||||
|
|
||||||
def pack_filter(self, key, data):
|
def pack_filter(self, key, data):
|
||||||
if key == self.KEY_BRIGHTNESS:
|
if key == self.KEY_BRIGHTNESS:
|
||||||
return data * 254 / 100 + 1
|
return round(data * 253 / 100 + 1, 0)
|
||||||
elif key == self.KEY_COLOR_TEMP:
|
elif key == self.KEY_COLOR_TEMP:
|
||||||
return data * 204 / 10 + 250
|
return round(data * 204 / 10 + 250, 0)
|
||||||
else:
|
else:
|
||||||
return super().pack_filter(key, data)
|
return super().pack_filter(key, data)
|
||||||
|
|
||||||
@ -708,180 +708,6 @@ class tradfri_button(base):
|
|||||||
return "Low battery level detected for %s. Battery level was %.0f%%." % (self.topic, self.get(self.KEY_BATTERY))
|
return "Low battery level detected for %s. Battery level was %.0f%%." % (self.topic, self.get(self.KEY_BATTERY))
|
||||||
|
|
||||||
|
|
||||||
class nodered_gui_leds(base):
|
|
||||||
KEY_LED_0 = "led0"
|
|
||||||
KEY_LED_1 = "led1"
|
|
||||||
KEY_LED_2 = "led2"
|
|
||||||
KEY_LED_3 = "led3"
|
|
||||||
KEY_LED_4 = "led4"
|
|
||||||
KEY_LED_5 = "led5"
|
|
||||||
KEY_LED_6 = "led6"
|
|
||||||
KEY_LED_7 = "led7"
|
|
||||||
KEY_LED_8 = "led8"
|
|
||||||
KEY_LED_9 = "led9"
|
|
||||||
KEY_LED_LIST = [KEY_LED_0, KEY_LED_1, KEY_LED_2, KEY_LED_3, KEY_LED_4, KEY_LED_5, KEY_LED_6, KEY_LED_7, KEY_LED_8, KEY_LED_9]
|
|
||||||
#
|
|
||||||
TX_TYPE = base.TX_VALUE
|
|
||||||
|
|
||||||
def set_led(self, key, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.pack(key, data)
|
|
||||||
|
|
||||||
|
|
||||||
class nodered_gui_timer(base):
|
|
||||||
KEY_TIMER = "timer"
|
|
||||||
#
|
|
||||||
TX_TYPE = base.TX_VALUE
|
|
||||||
|
|
||||||
def set_timer(self, data):
|
|
||||||
"""data: numeric"""
|
|
||||||
self.pack(self.KEY_TIMER, data)
|
|
||||||
|
|
||||||
def set_timer_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_timer(data)
|
|
||||||
|
|
||||||
|
|
||||||
class nodered_gui_button(base):
|
|
||||||
KEY_STATE = "state"
|
|
||||||
#
|
|
||||||
RX_KEYS = [KEY_STATE]
|
|
||||||
|
|
||||||
#
|
|
||||||
# RX
|
|
||||||
#
|
|
||||||
@property
|
|
||||||
def state(self):
|
|
||||||
"""rv: [True, False]"""
|
|
||||||
return self.get(self.KEY_STATE)
|
|
||||||
|
|
||||||
|
|
||||||
class nodered_gui_switch(nodered_gui_button):
|
|
||||||
TX_TYPE = base.TX_VALUE
|
|
||||||
|
|
||||||
#
|
|
||||||
# TX
|
|
||||||
#
|
|
||||||
def set_state(self, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.pack(self.KEY_STATE, data)
|
|
||||||
|
|
||||||
def set_state_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_state(data)
|
|
||||||
|
|
||||||
|
|
||||||
class nodered_gui_light(nodered_gui_switch, nodered_gui_leds, nodered_gui_timer):
|
|
||||||
KEY_ENABLE = "enable"
|
|
||||||
KEY_BRIGHTNESS = "brightness"
|
|
||||||
KEY_COLOR_TEMP = "color_temp"
|
|
||||||
#
|
|
||||||
TX_TYPE = base.TX_VALUE
|
|
||||||
#
|
|
||||||
RX_KEYS = nodered_gui_switch.RX_KEYS + [KEY_ENABLE, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
|
|
||||||
|
|
||||||
#
|
|
||||||
# RX
|
|
||||||
#
|
|
||||||
@property
|
|
||||||
def enable(self):
|
|
||||||
"""rv: [True, False]"""
|
|
||||||
return self.get(self.KEY_ENABLE)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def brightness(self):
|
|
||||||
"""rv: [True, False]"""
|
|
||||||
return self.get(self.KEY_BRIGHTNESS)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def color_temp(self):
|
|
||||||
"""rv: [True, False]"""
|
|
||||||
return self.get(self.KEY_COLOR_TEMP)
|
|
||||||
|
|
||||||
#
|
|
||||||
# TX
|
|
||||||
#
|
|
||||||
def set_enable(self, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.pack(self.KEY_ENABLE, data)
|
|
||||||
|
|
||||||
def set_enable_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_enable(data)
|
|
||||||
|
|
||||||
def set_brightness(self, data):
|
|
||||||
"""data: [0%, ..., 100%]"""
|
|
||||||
self.pack(self.KEY_BRIGHTNESS, data)
|
|
||||||
|
|
||||||
def set_brightness_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_brightness(data)
|
|
||||||
|
|
||||||
def set_color_temp(self, data):
|
|
||||||
"""data: [0, ..., 10]"""
|
|
||||||
self.pack(self.KEY_COLOR_TEMP, data)
|
|
||||||
|
|
||||||
def set_color_temp_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_color_temp(data)
|
|
||||||
|
|
||||||
|
|
||||||
class nodered_gui_radiator(nodered_gui_timer):
|
|
||||||
KEY_TEMPERATURE = "temperature"
|
|
||||||
KEY_SETPOINT_TEMP = "setpoint_temp"
|
|
||||||
KEY_SETPOINT_TO_DEFAULT = "setpoint_to_default"
|
|
||||||
KEY_BOOST = 'boost'
|
|
||||||
KEY_AWAY = "away"
|
|
||||||
KEY_SUMMER = "summer"
|
|
||||||
KEY_ENABLE = "enable"
|
|
||||||
#
|
|
||||||
RX_KEYS = [KEY_TEMPERATURE, KEY_SETPOINT_TEMP, KEY_SETPOINT_TO_DEFAULT, KEY_BOOST, KEY_AWAY, KEY_SUMMER]
|
|
||||||
|
|
||||||
#
|
|
||||||
# TX
|
|
||||||
#
|
|
||||||
def set_temperature(self, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.pack(self.KEY_TEMPERATURE, data)
|
|
||||||
|
|
||||||
def set_temperature_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_temperature(data)
|
|
||||||
|
|
||||||
def set_setpoint_temperature(self, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.pack(self.KEY_SETPOINT_TEMP, data)
|
|
||||||
|
|
||||||
def set_setpoint_temperature_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_setpoint_temperature(data)
|
|
||||||
|
|
||||||
def set_away(self, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.pack(self.KEY_AWAY, data)
|
|
||||||
|
|
||||||
def set_away_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_away(data)
|
|
||||||
|
|
||||||
def set_summer(self, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.pack(self.KEY_SUMMER, data)
|
|
||||||
|
|
||||||
def set_summer_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_summer(data)
|
|
||||||
|
|
||||||
def set_enable(self, data):
|
|
||||||
"""data: [True, False]"""
|
|
||||||
self.pack(self.KEY_ENABLE, data)
|
|
||||||
|
|
||||||
def set_enable_mcb(self, device, key, data):
|
|
||||||
self.logger.debug("Sending %s with content %s", key, str(data))
|
|
||||||
self.set_enable(data)
|
|
||||||
|
|
||||||
|
|
||||||
class brennenstuhl_heatingvalve(base):
|
class brennenstuhl_heatingvalve(base):
|
||||||
KEY_LINKQUALITY = "linkquality"
|
KEY_LINKQUALITY = "linkquality"
|
||||||
KEY_BATTERY = "battery"
|
KEY_BATTERY = "battery"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user