mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-13 19:08:02 +00:00
Add transition support for SmartDimmer (#69)
* Adds a transition param to set_brightness(), turn_on(), and turn_off() that specifies the duration in milliseconds that the dimmer switch will take to transition to the new state. * Fixes bug where set_brightness(0) was allowed even though the dimmer does not support it. Now brightness values of 0 are coerced to 1 to be consistent with bulbs (which do support brightness values of 0).
This commit is contained in:
@@ -315,6 +315,15 @@ class FakeTransportProtocol(TPLinkSmartHomeProtocol):
|
||||
_LOGGER.debug("Setting brightness to %s", x)
|
||||
self.proto["system"]["get_sysinfo"]["brightness"] = x["brightness"]
|
||||
|
||||
def set_hs220_dimmer_transition(self, x, *args):
|
||||
_LOGGER.debug("Setting dimmer transition to %s", x)
|
||||
brightness = x["brightness"]
|
||||
if brightness == 0:
|
||||
self.proto["system"]["get_sysinfo"]["relay_state"] = 0
|
||||
else:
|
||||
self.proto["system"]["get_sysinfo"]["relay_state"] = 1
|
||||
self.proto["system"]["get_sysinfo"]["brightness"] = x["brightness"]
|
||||
|
||||
def transition_light_state(self, x, *args):
|
||||
_LOGGER.debug("Setting light state to %s", x)
|
||||
light_state = self.proto["system"]["get_sysinfo"]["light_state"]
|
||||
@@ -392,7 +401,10 @@ class FakeTransportProtocol(TPLinkSmartHomeProtocol):
|
||||
"set_timezone": None,
|
||||
},
|
||||
# HS220 brightness, different setter and getter
|
||||
"smartlife.iot.dimmer": {"set_brightness": set_hs220_brightness},
|
||||
"smartlife.iot.dimmer": {
|
||||
"set_brightness": set_hs220_brightness,
|
||||
"set_dimmer_transition": set_hs220_dimmer_transition,
|
||||
},
|
||||
}
|
||||
|
||||
async def query(self, host, request, port=9999):
|
||||
|
Reference in New Issue
Block a user