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.""" diff --git a/custom_components/cync_lights/cync_hub.py b/custom_components/cync_lights/cync_hub.py index eadb556..e6be1b9 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,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], + "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} @@ -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) 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) diff --git a/custom_components/cync_lights/light.py b/custom_components/cync_lights/light.py index 8776140..68fe6ba 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.""" @@ -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.""" @@ -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() 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() 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 }