-
-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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
TPLink Kasa Integration: KL430 - Persistent Effect Behavior #69039
TPLink Kasa Integration: KL430 - Persistent Effect Behavior #69039
Comments
tplink documentation |
Hey there @rytilahti, @TheGardenMonkey, mind taking a look at this issue as it has been labeled with an integration ( |
Maybe @bdraco has an idea what's wrong. |
I can replicate the issue. Unfortunately I don't think there is enough information to fix it. This is the state when a color is set and then turned off
This is the state when an effect is set and its turned off
They are identical unless I missed something |
We might be able to fix it if there is a I think we have to wait for modularize for that |
|
If the top one is coming out of color, why does it have name rainbow? I agree they're identical but is that because it's hanging onto the effect name? |
Thats the data from the device itself so its returning the effect that was previously set. |
We might need to do something like this to augment the turn off |
I'm out of time for today. I'll have to look when I get back home Monday |
@SergeantPup if you can get dumps on how the app is turning it on and off locally without the cloud that would give me a head start |
I reverted off beta for my own sanity so there's no rush. I took tomorrow off anyway and I'll get you the data dump. Thank you for confirming replication of issue. |
I was looking for the instructions for the dump (because I knew I saw them in other threads) and I think somebody already came to a conclusion on the effects:
I learned some additional behavior that may point to the problem via Alexa: What this tells me: I have the packet information but I'm not sure how you want me to get it to you. |
You can email it to nick@koston.org |
I sent it over. Let me know if there's anything else I can do to help. |
Here is the problem The app sends We send: |
This fixes the lib to not clear the effect when turning back on diff --git a/kasa/smartbulb.py b/kasa/smartbulb.py
index e5dcfbe..c2d0953 100644
--- a/kasa/smartbulb.py
+++ b/kasa/smartbulb.py
@@ -34,6 +34,9 @@ TPLINK_KELVIN = {
r"KL430": ColorTempRange(2500, 9000),
}
+
+NON_COLOR_MODE_FLAGS = {"transition_period", "on_off"}
+
_LOGGER = logging.getLogger(__name__)
@@ -211,6 +214,12 @@ class SmartBulb(SmartDevice):
if "on_off" not in state:
state["on_off"] = 1
+ # If we are turning on without any color mode flags,
+ # we do not want to set ignore_default to ensure
+ # we restore the previous state.
+ if state["on_off"] and NON_COLOR_MODE_FLAGS.issuperset(state):
+ state["ignore_default"] = 0
+ else:
# This is necessary to allow turning on into a specific state
state["ignore_default"] = 1
This fixes the color temp not being able to be set when an effect is in progress diff --git a/homeassistant/components/tplink/light.py b/homeassistant/components/tplink/light.py
index 89b954491e..22d2f2563f 100644
--- a/homeassistant/components/tplink/light.py
+++ b/homeassistant/components/tplink/light.py
@@ -352,6 +352,11 @@ class TPLinkSmartLightStrip(TPLinkSmartBulb):
"""Turn the light on."""
brightness, transition = self._async_extract_brightness_transition(**kwargs)
if ATTR_COLOR_TEMP in kwargs:
+ if self.effect:
+ # If there is an effect in progress
+ # we have to set an HSV value to clear the effect
+ # before we can set a color temp
+ await self.device.set_hsv(0, 0, brightness)
await self._async_set_color_temp(
int(kwargs[ATTR_COLOR_TEMP]), brightness, transition
)
@@ -359,20 +364,6 @@ class TPLinkSmartLightStrip(TPLinkSmartBulb):
await self._async_set_hsv(kwargs[ATTR_HS_COLOR], brightness, transition)
elif ATTR_EFFECT in kwargs:
await self.device.set_effect(kwargs[ATTR_EFFECT])
- elif (
- self.device.is_off
- and self.device.effect
- and self.device.effect["enable"] == 0
- and self.device.effect["name"]
- ):
- if not self.device.effect["custom"]:
- await self.device.set_effect(self.device.effect["name"])
- elif self._last_custom_effect:
- await self.device.set_custom_effect(self._last_custom_effect)
- # The device does not remember custom effects
- # so we must set a default value or it can never turn back on
- else:
- await self.device.set_hsv(0, 0, 100, transition=transition)
else:
await self._async_turn_on_with_brightness(brightness, transition)
|
I need to pull out some of the bulbs and test that it doesn't break anything |
confirmed ok with the bulbs also custom effects now get restored 👍 |
* Ensure state is restored when turning back on Fixes home-assistant/core#69039 * Update kasa/tests/test_bulb.py Co-authored-by: Teemu R. <tpr@iki.fi> Co-authored-by: Teemu R. <tpr@iki.fi>
The problem
The defect has been replicated consistently on KL430 Hardware V2 Firmware 1.0.9 (approximately 16 devices) AND KL430 Hardware V1 Firmware 1.0.10. (approximately 22 devices). I previously reported that it was not happening on Firmware 1.0.10; however, upon further investigation the problem is occurring with all strips, it's just that the Firmware 1.0.10 come out of the effect with the adaptive lighting integration whereas Firmware 1.0.9 does not come out of the effect even with adaptive lighting.
For the purpose of these tests, I have removed adaptive lighting on the KL430's.
Reproduction steps on KL430 Hardware V1 Firmware 1.0.9 and KL430 Hardware V2 Firmware 1.0.10:
What version of Home Assistant Core has the issue?
2022.4.0b0
What was the last working version of Home Assistant Core?
New Feature Functionality
What type of installation are you running?
Home Assistant OS
Integration causing the issue
TPLink Kasa
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tplink/
Diagnostics information
Isolated to KL430 effects. If effects are never used/selected, it's not a problem.
Example YAML snippet
NA
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: