bed_light fading implemented
This commit is contained in:
parent
2f65ff360d
commit
34e7cab818
@ -3,7 +3,7 @@
|
||||
#
|
||||
"""
|
||||
devices (DEVICES)
|
||||
===========
|
||||
=================
|
||||
|
||||
**Author:**
|
||||
|
||||
@ -369,10 +369,11 @@ class tradfri_light(base):
|
||||
KEY_OUTPUT_0 = "state"
|
||||
KEY_BRIGHTNESS = "brightness"
|
||||
KEY_COLOR_TEMP = "color_temp"
|
||||
KEY_BRIGHTNESS_FADE = "brightness_move"
|
||||
#
|
||||
TX_TOPIC = 'set'
|
||||
TX_TYPE = base.TX_DICT
|
||||
TX_FILTER_DATA_KEYS = [KEY_OUTPUT_0, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
|
||||
TX_FILTER_DATA_KEYS = [KEY_OUTPUT_0, KEY_BRIGHTNESS, KEY_COLOR_TEMP, KEY_BRIGHTNESS_FADE]
|
||||
#
|
||||
RX_KEYS = [KEY_LINKQUALITY, KEY_OUTPUT_0, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
|
||||
RX_IGNORE_TOPICS = [TX_TOPIC]
|
||||
@ -432,6 +433,15 @@ class tradfri_light(base):
|
||||
"""brightness: [0, ..., 100]"""
|
||||
self.pack(self.KEY_BRIGHTNESS, brightness)
|
||||
|
||||
def brightness_inc(self, speed=40):
|
||||
self.pack(self.KEY_BRIGHTNESS_FADE, speed)
|
||||
|
||||
def brightness_dec(self, speed=-40):
|
||||
self.brightness_inc(speed)
|
||||
|
||||
def brightness_stop(self):
|
||||
self.brightness_inc(0)
|
||||
|
||||
def set_color_temp(self, color_temp):
|
||||
"""color_temp: [0, ..., 100]"""
|
||||
self.pack(self.KEY_COLOR_TEMP, color_temp)
|
||||
|
@ -18,31 +18,35 @@ import inspect
|
||||
|
||||
class all_functions(object):
|
||||
def __init__(self, mqtt_client):
|
||||
self.rooms = {}
|
||||
self.mqtt_client = mqtt_client
|
||||
#
|
||||
self.__devices__ = None
|
||||
#
|
||||
# ground floor west
|
||||
#
|
||||
self.gfw_floor = ground_floor_west_floor(mqtt_client)
|
||||
self.gfw_marion = ground_floor_west_marion(mqtt_client)
|
||||
self.gfw_dirk = ground_floor_west_dirk(mqtt_client)
|
||||
# add rooms
|
||||
#
|
||||
# # ground floor west
|
||||
self.gfw_floor = ground_floor_west_floor(self.mqtt_client)
|
||||
self.gfw_marion = ground_floor_west_marion(self.mqtt_client)
|
||||
self.gfw_dirk = ground_floor_west_dirk(self.mqtt_client)
|
||||
# first floor west
|
||||
#
|
||||
self.ffw_julian = first_floor_west_julian(mqtt_client)
|
||||
self.ffw_living = first_floor_west_living(mqtt_client)
|
||||
#
|
||||
self.ffw_julian = first_floor_west_julian(self.mqtt_client)
|
||||
self.ffw_living = first_floor_west_living(self.mqtt_client)
|
||||
# first floor east
|
||||
self.ffe_floor = first_floor_east_floor(self.mqtt_client)
|
||||
self.ffe_kitchen = first_floor_east_kitchen(self.mqtt_client)
|
||||
self.ffe_dining = first_floor_east_dining(self.mqtt_client)
|
||||
self.ffe_sleep_madi = first_floor_east_sleep_madi(self.mqtt_client)
|
||||
self.ffe_living = first_floor_east_living(self.mqtt_client)
|
||||
#
|
||||
self.ffe_floor = first_floor_east_floor(mqtt_client)
|
||||
self.ffe_kitchen = first_floor_east_kitchen(mqtt_client)
|
||||
self.ffe_dining = first_floor_east_dining(mqtt_client)
|
||||
self.ffe_sleep_madi = first_floor_east_sleep_madi(mqtt_client)
|
||||
self.ffe_living = first_floor_east_living(mqtt_client)
|
||||
# additional functionality
|
||||
#
|
||||
# Input devices sleep_madi
|
||||
self.init_input_device_sleep_madi_functionality()
|
||||
|
||||
def init_input_device_sleep_madi_functionality(self):
|
||||
#
|
||||
self.ffe_button_tradfri_sleep = devices.tradfri_button(
|
||||
self.mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
||||
#
|
||||
self.ffe_button_tradfri_sleep = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
||||
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "toggle",
|
||||
self.ffe_sleep_madi.toggle_main_light)
|
||||
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_up_click",
|
||||
@ -51,6 +55,8 @@ class all_functions(object):
|
||||
self.ffe_sleep_madi.toggle_bed_light_di)
|
||||
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "arrow_right_click",
|
||||
self.ffe_floor.toggle_main_light)
|
||||
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, None,
|
||||
self.ffe_sleep_madi.fade_bed_light)
|
||||
|
||||
def devicelist(self):
|
||||
if self.__devices__ is None:
|
||||
|
@ -92,6 +92,14 @@ class first_floor_east_sleep_madi(room_shelly_tradfri_light):
|
||||
logger.info("Toggeling \"%s\" main light", type(self).__name__)
|
||||
self.main_light_shelly.set_output_0("toggle")
|
||||
|
||||
def fade_bed_light(self, device, topic, data):
|
||||
if (data == 'brightness_up_hold'):
|
||||
self.bed_light_di_tradfri.brightness_inc()
|
||||
elif (data == 'brightness_down_hold'):
|
||||
self.bed_light_di_tradfri.brightness_dec()
|
||||
elif (data.startswith('brightness') and data.endswith('release')):
|
||||
self.bed_light_di_tradfri.brightness_stop()
|
||||
|
||||
def gui_switch_command_bed_light_di(self, device, key, data):
|
||||
logger.info("Switching \"%s\" bed light dirk: %s", type(self).__name__, str(data))
|
||||
self.bed_light_di_tradfri.set_output_0(data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user