|
|
@@ -127,13 +127,66 @@ class HADeviceController:
|
|
|
"""关闭一楼大门玄关射灯"""
|
|
|
return self.control_device('exhibition_spotlight', 'turn_off')
|
|
|
|
|
|
- def turn_on_exhibition_ceiling_light(self):
|
|
|
- """打开一楼展厅顶灯"""
|
|
|
- return self.control_device('exhibition_ceiling_light', 'turn_on')
|
|
|
+ def turn_on_exhibition_ceiling_lights(self):
|
|
|
+ """打开一楼展厅顶灯 (全部)"""
|
|
|
+ r1 = self.control_device('exhibition_ceiling_light_1', 'turn_on')
|
|
|
+ r2 = self.control_device('exhibition_ceiling_light_2', 'turn_on')
|
|
|
+ r3 = self.control_device('exhibition_ceiling_light_3', 'turn_on')
|
|
|
+ return r1 and r2 and r3
|
|
|
+
|
|
|
+ def turn_off_exhibition_ceiling_lights(self):
|
|
|
+ """关闭一楼展厅顶灯 (全部)"""
|
|
|
+ r1 = self.control_device('exhibition_ceiling_light_1', 'turn_off')
|
|
|
+ r2 = self.control_device('exhibition_ceiling_light_2', 'turn_off')
|
|
|
+ r3 = self.control_device('exhibition_ceiling_light_3', 'turn_off')
|
|
|
+ return r1 and r2 and r3
|
|
|
+
|
|
|
+ def set_exhibition_ceiling_light_level(self, level):
|
|
|
+ """
|
|
|
+ 设置一楼展厅顶灯等级 (0-3)
|
|
|
+ 0: 全关
|
|
|
+ 1: 开启灯1 (关2,3)
|
|
|
+ 2: 开启灯1,2 (关3)
|
|
|
+ 3: 全开 (1,2,3)
|
|
|
+ """
|
|
|
+ logger.info(f"设置展厅顶灯等级: {level}")
|
|
|
+
|
|
|
+ # 确保 level 在 0-3 之间
|
|
|
+ try:
|
|
|
+ level = int(level)
|
|
|
+ if level < 0: level = 0
|
|
|
+ if level > 3: level = 3
|
|
|
+ except (ValueError, TypeError):
|
|
|
+ logger.error(f"无效的灯光等级: {level}")
|
|
|
+ return False
|
|
|
+
|
|
|
+ r1, r2, r3 = True, True, True
|
|
|
|
|
|
- def turn_off_exhibition_ceiling_light(self):
|
|
|
- """关闭一楼展厅顶灯"""
|
|
|
- return self.control_device('exhibition_ceiling_light', 'turn_off')
|
|
|
+ if level == 0:
|
|
|
+ # 0: 全关
|
|
|
+ r1 = self.control_device('exhibition_ceiling_light_1', 'turn_off')
|
|
|
+ r2 = self.control_device('exhibition_ceiling_light_2', 'turn_off')
|
|
|
+ r3 = self.control_device('exhibition_ceiling_light_3', 'turn_off')
|
|
|
+
|
|
|
+ elif level == 1:
|
|
|
+ # 1: 开启灯1 (关2,3)
|
|
|
+ r1 = self.control_device('exhibition_ceiling_light_1', 'turn_on')
|
|
|
+ r2 = self.control_device('exhibition_ceiling_light_2', 'turn_off')
|
|
|
+ r3 = self.control_device('exhibition_ceiling_light_3', 'turn_off')
|
|
|
+
|
|
|
+ elif level == 2:
|
|
|
+ # 2: 开启灯1,2 (关3)
|
|
|
+ r1 = self.control_device('exhibition_ceiling_light_1', 'turn_on')
|
|
|
+ r2 = self.control_device('exhibition_ceiling_light_2', 'turn_on')
|
|
|
+ r3 = self.control_device('exhibition_ceiling_light_3', 'turn_off')
|
|
|
+
|
|
|
+ elif level == 3:
|
|
|
+ # 3: 全开
|
|
|
+ r1 = self.control_device('exhibition_ceiling_light_1', 'turn_on')
|
|
|
+ r2 = self.control_device('exhibition_ceiling_light_2', 'turn_on')
|
|
|
+ r3 = self.control_device('exhibition_ceiling_light_3', 'turn_on')
|
|
|
+
|
|
|
+ return r1 and r2 and r3
|
|
|
|
|
|
def turn_on_exhibition_desktop_switch(self):
|
|
|
"""打开展厅桌面的灯座总开关"""
|
|
|
@@ -192,11 +245,14 @@ def turn_on_exhibition_spotlight():
|
|
|
def turn_off_exhibition_spotlight():
|
|
|
return ha_device_controller.turn_off_exhibition_spotlight()
|
|
|
|
|
|
-def turn_on_exhibition_ceiling_light():
|
|
|
- return ha_device_controller.turn_on_exhibition_ceiling_light()
|
|
|
+def turn_on_exhibition_ceiling_lights():
|
|
|
+ return ha_device_controller.turn_on_exhibition_ceiling_lights()
|
|
|
+
|
|
|
+def turn_off_exhibition_ceiling_lights():
|
|
|
+ return ha_device_controller.turn_off_exhibition_ceiling_lights()
|
|
|
|
|
|
-def turn_off_exhibition_ceiling_light():
|
|
|
- return ha_device_controller.turn_off_exhibition_ceiling_light()
|
|
|
+def set_exhibition_ceiling_light_level(level):
|
|
|
+ return ha_device_controller.set_exhibition_ceiling_light_level(level)
|
|
|
|
|
|
def turn_on_exhibition_desktop_switch():
|
|
|
return ha_device_controller.turn_on_exhibition_desktop_switch()
|