From 426de4c054f2b8c6ec5bc032a21fcef469fc439d Mon Sep 17 00:00:00 2001 From: network-guy Date: Mon, 1 Jan 2024 22:33:43 -0600 Subject: [PATCH 01/13] Update capabilities to include 6" full-color downlights --- custom_components/cync_lights/cync_hub.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index eadb556..eeb85cc 100644 --- a/custom_components/cync_lights/cync_hub.py +++ b/custom_components/cync_lights/cync_hub.py @@ -16,13 +16,13 @@ API_DEVICE_INFO = "https://api.gelighting.com/v2/product/{product_id}/device/{device_id}/property" Capabilities = { - "ONOFF":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165], - "BRIGHTNESS":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,48,49,55,56,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165], - "COLORTEMP":[5,6,7,8,10,11,14,15,19,20,21,22,23,25,26,28,29,30,31,32,33,34,35,80,82,83,85,129,130,131,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,153,154,156,158,159,160,161,162,163,164,165], - "RGB":[6,7,8,21,22,23,30,31,32,33,34,35,131,132,133,137,138,139,140,141,142,143,146,147,153,154,156,158,159,160,161,162,163,164,165], + "ONOFF":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,170], + "BRIGHTNESS":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,48,49,55,56,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,170], + "COLORTEMP":[5,6,7,8,10,11,14,15,19,20,21,22,23,25,26,28,29,30,31,32,33,34,35,80,82,83,85,129,130,131,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,153,154,156,158,159,160,161,162,163,164,165,170], + "RGB":[6,7,8,21,22,23,30,31,32,33,34,35,131,132,133,137,138,139,140,141,142,143,146,147,153,154,156,158,159,160,161,162,163,164,165,170], "MOTION":[37,49,54], "AMBIENT_LIGHT":[37,49,54], - "WIFICONTROL":[36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165], + "WIFICONTROL":[36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,170], "PLUG":[64,65,66,67,68], "FAN":[81], "MULTIELEMENT":{'67':2} From 2e135e7ddd2b5ca2903ce042ea0eaf28e2cbe1b7 Mon Sep 17 00:00:00 2001 From: network-guy Date: Wed, 3 Jan 2024 12:44:34 -0600 Subject: [PATCH 02/13] Add support for 4" full-color downlights --- custom_components/cync_lights/cync_hub.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index eeb85cc..c3891be 100644 --- a/custom_components/cync_lights/cync_hub.py +++ b/custom_components/cync_lights/cync_hub.py @@ -16,13 +16,13 @@ API_DEVICE_INFO = "https://api.gelighting.com/v2/product/{product_id}/device/{device_id}/property" Capabilities = { - "ONOFF":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,170], - "BRIGHTNESS":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,48,49,55,56,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,170], - "COLORTEMP":[5,6,7,8,10,11,14,15,19,20,21,22,23,25,26,28,29,30,31,32,33,34,35,80,82,83,85,129,130,131,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,153,154,156,158,159,160,161,162,163,164,165,170], - "RGB":[6,7,8,21,22,23,30,31,32,33,34,35,131,132,133,137,138,139,140,141,142,143,146,147,153,154,156,158,159,160,161,162,163,164,165,170], + "ONOFF":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,169,170], + "BRIGHTNESS":[1,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,48,49,55,56,80,81,82,83,85,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,169,170], + "COLORTEMP":[5,6,7,8,10,11,14,15,19,20,21,22,23,25,26,28,29,30,31,32,33,34,35,80,82,83,85,129,130,131,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,153,154,156,158,159,160,161,162,163,164,165,169,170], + "RGB":[6,7,8,21,22,23,30,31,32,33,34,35,131,132,133,137,138,139,140,141,142,143,146,147,153,154,156,158,159,160,161,162,163,164,165,169,170], "MOTION":[37,49,54], "AMBIENT_LIGHT":[37,49,54], - "WIFICONTROL":[36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,170], + "WIFICONTROL":[36,37,38,39,40,48,49,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,80,81,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164,165,169,170], "PLUG":[64,65,66,67,68], "FAN":[81], "MULTIELEMENT":{'67':2} From 4f39fba97bccd17cc523fb362d4eb19a5728e2aa Mon Sep 17 00:00:00 2001 From: network-guy Date: Wed, 3 Jan 2024 12:46:41 -0600 Subject: [PATCH 03/13] Update hacs.json --- hacs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacs.json b/hacs.json index 1dff19e..9186a00 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,5 @@ { - "name": "Cync Lights Custom Integration", + "name": "Cync Lights Custom Integration (Forked)", "domains": ["light"], "render_readme": true } From 392f256a571bf7040cf0bff27aa9e3822ae11ec8 Mon Sep 17 00:00:00 2001 From: network-guy Date: Mon, 20 May 2024 21:38:07 -0500 Subject: [PATCH 04/13] Update switch.py Change async_write_ha_state to schedule_update_ha_state --- custom_components/cync_lights/switch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/cync_lights/switch.py b/custom_components/cync_lights/switch.py index 613063b..d06f284 100644 --- a/custom_components/cync_lights/switch.py +++ b/custom_components/cync_lights/switch.py @@ -37,7 +37,7 @@ def __init__(self, cync_switch) -> None: async def async_added_to_hass(self) -> None: """Run when this Entity has been added to HA.""" - self.cync_switch.register(self.async_write_ha_state) + self.cync_switch.register(self.schedule_update_ha_state) async def async_will_remove_from_hass(self) -> None: """Entity being removed from hass.""" @@ -79,4 +79,4 @@ async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the outlet.""" - await self.cync_switch.turn_off() \ No newline at end of file + await self.cync_switch.turn_off() From 618a2eeab19f7d3075331752e899f434165bd1f2 Mon Sep 17 00:00:00 2001 From: network-guy Date: Mon, 20 May 2024 21:45:16 -0500 Subject: [PATCH 05/13] Update light.py --- custom_components/cync_lights/light.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/cync_lights/light.py b/custom_components/cync_lights/light.py index 8776140..925924a 100644 --- a/custom_components/cync_lights/light.py +++ b/custom_components/cync_lights/light.py @@ -42,7 +42,7 @@ def __init__(self, room) -> None: async def async_added_to_hass(self) -> None: """Run when this Entity has been added to HA.""" - self.room.register(self.async_write_ha_state) + self.room.register(self.schedule_update_ha_state) async def async_will_remove_from_hass(self) -> None: """Entity being removed from hass.""" @@ -250,4 +250,4 @@ async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the light.""" - await self.cync_switch.turn_off() \ No newline at end of file + await self.cync_switch.turn_off() From bb82cf8f0cc22c49b7ab91fd2ee570633a12b704 Mon Sep 17 00:00:00 2001 From: network-guy Date: Mon, 20 May 2024 21:52:51 -0500 Subject: [PATCH 06/13] Update fan.py --- custom_components/cync_lights/fan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/cync_lights/fan.py b/custom_components/cync_lights/fan.py index c85a20b..01c6d4b 100644 --- a/custom_components/cync_lights/fan.py +++ b/custom_components/cync_lights/fan.py @@ -37,7 +37,7 @@ def __init__(self, cync_switch) -> None: async def async_added_to_hass(self) -> None: """Run when this Entity has been added to HA.""" - self.cync_switch.register(self.async_write_ha_state) + self.cync_switch.register(self.schedule_update_ha_state) async def async_will_remove_from_hass(self) -> None: """Entity being removed from hass.""" @@ -101,4 +101,4 @@ async def async_set_percentage(self, percentage: int) -> None: if percentage == 0: await self.async_turn_off() else: - await self.cync_switch.turn_on(None,percentage*255/100,None) \ No newline at end of file + await self.cync_switch.turn_on(None,percentage*255/100,None) From 85f52a271ede9b1f3058ea844fbacb82a0ec427f Mon Sep 17 00:00:00 2001 From: network-guy Date: Mon, 20 May 2024 21:53:41 -0500 Subject: [PATCH 07/13] Update binary_sensor.py --- custom_components/cync_lights/binary_sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/cync_lights/binary_sensor.py b/custom_components/cync_lights/binary_sensor.py index e45dcb8..bacf889 100644 --- a/custom_components/cync_lights/binary_sensor.py +++ b/custom_components/cync_lights/binary_sensor.py @@ -38,7 +38,7 @@ def __init__(self, motion_sensor) -> None: async def async_added_to_hass(self) -> None: """Run when this Entity has been added to HA.""" - self.motion_sensor.register(self.async_write_ha_state) + self.motion_sensor.register(self.schedule_update_ha_state) async def async_will_remove_from_hass(self) -> None: """Entity being removed from hass.""" @@ -85,7 +85,7 @@ def __init__(self, ambient_light_sensor) -> None: async def async_added_to_hass(self) -> None: """Run when this Entity has been added to HA.""" - self.ambient_light_sensor.register(self.async_write_ha_state) + self.ambient_light_sensor.register(self.schedule_update_ha_state) async def async_will_remove_from_hass(self) -> None: """Entity being removed from hass.""" From 04a716dbb714eb1a569a433a5de7d553b7697941 Mon Sep 17 00:00:00 2001 From: network-guy Date: Mon, 20 May 2024 21:54:45 -0500 Subject: [PATCH 08/13] Update light.py --- custom_components/cync_lights/light.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/cync_lights/light.py b/custom_components/cync_lights/light.py index 925924a..68fe6ba 100644 --- a/custom_components/cync_lights/light.py +++ b/custom_components/cync_lights/light.py @@ -157,7 +157,7 @@ def __init__(self, cync_switch) -> None: async def async_added_to_hass(self) -> None: """Run when this Entity has been added to HA.""" - self.cync_switch.register(self.async_write_ha_state) + self.cync_switch.register(self.schedule_update_ha_state) async def async_will_remove_from_hass(self) -> None: """Entity being removed from hass.""" From 79feb9ca729fa1dc42e67ac51ec2a638d821f02c Mon Sep 17 00:00:00 2001 From: network-guy Date: Sat, 25 May 2024 13:56:47 -0500 Subject: [PATCH 09/13] Update cync_hub.py Turn on switch if brightness or color are set. --- custom_components/cync_lights/cync_hub.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index c3891be..2959ccc 100644 --- a/custom_components/cync_lights/cync_hub.py +++ b/custom_components/cync_lights/cync_hub.py @@ -470,6 +470,8 @@ def update_room(self): _rgb['b'] = round(sum([self.hub.cync_switches[device_id].rgb['b'] for device_id in self.switches_support_rgb] + [self.hub.cync_rooms[room_id].rgb['b'] for room_id in self.groups_support_rgb])/(len(self.switches_support_rgb) + len(self.groups_support_rgb))) _rgb['active'] = True in ([self.hub.cync_switches[device_id].rgb['active'] for device_id in self.switches_support_rgb] + [self.hub.cync_rooms[room_id].rgb['active'] for room_id in self.groups_support_rgb]) + if _brightness != self.brightness or _color_temp != self.color_temp or _rgb != self.rgb: + _power_state = True if _power_state != self.power_state or _brightness != self.brightness or _color_temp != self.color_temp or _rgb != self.rgb: self.power_state = _power_state self.brightness = _brightness From 5668a09fc064937a4c2b197cfc20068bbb30decb Mon Sep 17 00:00:00 2001 From: network-guy Date: Sat, 25 May 2024 14:05:10 -0500 Subject: [PATCH 10/13] Revert previous commit --- custom_components/cync_lights/cync_hub.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index 2959ccc..c3891be 100644 --- a/custom_components/cync_lights/cync_hub.py +++ b/custom_components/cync_lights/cync_hub.py @@ -470,8 +470,6 @@ def update_room(self): _rgb['b'] = round(sum([self.hub.cync_switches[device_id].rgb['b'] for device_id in self.switches_support_rgb] + [self.hub.cync_rooms[room_id].rgb['b'] for room_id in self.groups_support_rgb])/(len(self.switches_support_rgb) + len(self.groups_support_rgb))) _rgb['active'] = True in ([self.hub.cync_switches[device_id].rgb['active'] for device_id in self.switches_support_rgb] + [self.hub.cync_rooms[room_id].rgb['active'] for room_id in self.groups_support_rgb]) - if _brightness != self.brightness or _color_temp != self.color_temp or _rgb != self.rgb: - _power_state = True if _power_state != self.power_state or _brightness != self.brightness or _color_temp != self.color_temp or _rgb != self.rgb: self.power_state = _power_state self.brightness = _brightness From 5bee56f345edcbc9c6aaf5c1a63282f5d4784206 Mon Sep 17 00:00:00 2001 From: network-guy Date: Sat, 25 May 2024 14:39:35 -0500 Subject: [PATCH 11/13] Update cync_hub.py Test color temp change --- custom_components/cync_lights/cync_hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index c3891be..851904d 100644 --- a/custom_components/cync_lights/cync_hub.py +++ b/custom_components/cync_lights/cync_hub.py @@ -311,7 +311,7 @@ def turn_off(self,switch_id,mesh_id,seq): self.loop.call_soon_threadsafe(self.send_request,power_request) def set_color_temp(self,color_temp,switch_id,mesh_id,seq): - color_temp_request = bytes.fromhex('730000001e') + int(switch_id).to_bytes(4,'big') + int(seq).to_bytes(2,'big') + bytes.fromhex('007e00000000f8e20c000000000000') + mesh_id + bytes.fromhex('e2000005') + color_temp.to_bytes(1,'big') + ((469 + int(mesh_id[0]) + int(mesh_id[1]) + color_temp)%256).to_bytes(1,'big') + bytes.fromhex('7e') + color_temp_request = bytes.fromhex('730000001e') + int(switch_id).to_bytes(4,'big') + int(seq).to_bytes(2,'big') + bytes.fromhex('007e00000000f8e20c000000000000') + mesh_id + bytes.fromhex('e2000005') + (1).to_bytes(1,'big') + color_temp.to_bytes(1,'big') + ((469 + int(mesh_id[0]) + int(mesh_id[1]) + color_temp)%256).to_bytes(1,'big') + bytes.fromhex('7e') self.loop.call_soon_threadsafe(self.send_request,color_temp_request) def get_seq_num(self): From e5cd5b5a6282400c6cc044b9dcc26289c74f6f5d Mon Sep 17 00:00:00 2001 From: network-guy Date: Sat, 25 May 2024 14:43:32 -0500 Subject: [PATCH 12/13] Update cync_hub.py --- custom_components/cync_lights/cync_hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index 851904d..c3891be 100644 --- a/custom_components/cync_lights/cync_hub.py +++ b/custom_components/cync_lights/cync_hub.py @@ -311,7 +311,7 @@ def turn_off(self,switch_id,mesh_id,seq): self.loop.call_soon_threadsafe(self.send_request,power_request) def set_color_temp(self,color_temp,switch_id,mesh_id,seq): - color_temp_request = bytes.fromhex('730000001e') + int(switch_id).to_bytes(4,'big') + int(seq).to_bytes(2,'big') + bytes.fromhex('007e00000000f8e20c000000000000') + mesh_id + bytes.fromhex('e2000005') + (1).to_bytes(1,'big') + color_temp.to_bytes(1,'big') + ((469 + int(mesh_id[0]) + int(mesh_id[1]) + color_temp)%256).to_bytes(1,'big') + bytes.fromhex('7e') + color_temp_request = bytes.fromhex('730000001e') + int(switch_id).to_bytes(4,'big') + int(seq).to_bytes(2,'big') + bytes.fromhex('007e00000000f8e20c000000000000') + mesh_id + bytes.fromhex('e2000005') + color_temp.to_bytes(1,'big') + ((469 + int(mesh_id[0]) + int(mesh_id[1]) + color_temp)%256).to_bytes(1,'big') + bytes.fromhex('7e') self.loop.call_soon_threadsafe(self.send_request,color_temp_request) def get_seq_num(self): From 135b81b6f2b591579c5ff4fcf6668b1a454b351e Mon Sep 17 00:00:00 2001 From: network-guy Date: Sat, 25 May 2024 14:48:49 -0500 Subject: [PATCH 13/13] Update cync_hub.py --- custom_components/cync_lights/cync_hub.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index c3891be..e6be1b9 100644 --- a/custom_components/cync_lights/cync_hub.py +++ b/custom_components/cync_lights/cync_hub.py @@ -417,6 +417,7 @@ async def turn_on(self, attr_rgb, attr_br, attr_ct) -> None: self.hub.combo_control(True, self.brightness, 254, attr_rgb, controller, self.mesh_id, seq) elif attr_ct is not None: ct = round(100*(self.max_mireds - attr_ct)/(self.max_mireds - self.min_mireds)) + self.hub.turn_on(controller, self.mesh_id, seq) self.hub.set_color_temp(ct, controller, self.mesh_id, seq) else: self.hub.turn_on(controller, self.mesh_id, seq)