Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update capabilities to include 6" full-color downlights #83

Merged
merged 13 commits into from
Jun 21, 2024
4 changes: 2 additions & 2 deletions custom_components/cync_lights/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down
11 changes: 6 additions & 5 deletions custom_components/cync_lights/cync_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/cync_lights/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)
await self.cync_switch.turn_on(None,percentage*255/100,None)
6 changes: 3 additions & 3 deletions custom_components/cync_lights/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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()
await self.cync_switch.turn_off()
4 changes: 2 additions & 2 deletions custom_components/cync_lights/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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()
await self.cync_switch.turn_off()
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Cync Lights Custom Integration",
"name": "Cync Lights Custom Integration (Forked)",
"domains": ["light"],
"render_readme": true
}