Add LightEffect module for smart light strips (#918)

Implements the `light_strip_lighting_effect` components for
`smart` devices. Uses a new list of effects captured from a L900 which
are similar to the `iot` effects but include some additional properties
and a few extra effects.

Assumes that a device only implements `light_strip_lighting_effect` or
`light_effect` but not both.
This commit is contained in:
Steven B
2024-05-15 06:16:57 +01:00
committed by GitHub
parent 67b5d7de83
commit 133a839f22
8 changed files with 572 additions and 19 deletions

View File

@@ -176,7 +176,7 @@ class FakeSmartTransport(BaseTransport):
"Method %s not implemented for children" % child_method
)
def _set_light_effect(self, info, params):
def _set_dynamic_light_effect(self, info, params):
"""Set or remove values as per the device behaviour."""
info["get_device_info"]["dynamic_light_effect_enable"] = params["enable"]
info["get_dynamic_light_effect_rules"]["enable"] = params["enable"]
@@ -189,6 +189,13 @@ class FakeSmartTransport(BaseTransport):
if "current_rule_id" in info["get_dynamic_light_effect_rules"]:
del info["get_dynamic_light_effect_rules"]["current_rule_id"]
def _set_light_strip_effect(self, info, params):
"""Set or remove values as per the device behaviour."""
info["get_device_info"]["lighting_effect"]["enable"] = params["enable"]
info["get_device_info"]["lighting_effect"]["name"] = params["name"]
info["get_device_info"]["lighting_effect"]["id"] = params["id"]
info["get_lighting_effect"] = copy.deepcopy(params)
def _set_led_info(self, info, params):
"""Set or remove values as per the device behaviour."""
info["get_led_info"]["led_status"] = params["led_rule"] != "never"
@@ -244,7 +251,10 @@ class FakeSmartTransport(BaseTransport):
elif method in ["set_qs_info", "fw_download"]:
return {"error_code": 0}
elif method == "set_dynamic_light_effect_rule_enable":
self._set_light_effect(info, params)
self._set_dynamic_light_effect(info, params)
return {"error_code": 0}
elif method == "set_lighting_effect":
self._set_light_strip_effect(info, params)
return {"error_code": 0}
elif method == "set_led_info":
self._set_led_info(info, params)