From cdcbb87d9760597cc7b3b9056d55fe1553ee6bd3 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Mon, 31 Jan 2022 03:09:07 +0100 Subject: [PATCH] Bump python-kasa to 0.4.1 for tplink integration (#64123) Co-authored-by: J. Nick Koston --- homeassistant/components/tplink/__init__.py | 2 +- homeassistant/components/tplink/light.py | 9 +++++---- homeassistant/components/tplink/manifest.json | 2 +- homeassistant/components/tplink/switch.py | 9 +++++---- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/tplink/__init__.py b/homeassistant/components/tplink/__init__.py index c2ada4190b3..e6b4c4aceab 100644 --- a/homeassistant/components/tplink/__init__.py +++ b/homeassistant/components/tplink/__init__.py @@ -96,7 +96,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: device: SmartDevice = hass_data[entry.entry_id].device if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS): hass_data.pop(entry.entry_id) - await device.protocol.close() + await device.protocol.close() # type: ignore return unload_ok diff --git a/homeassistant/components/tplink/light.py b/homeassistant/components/tplink/light.py index ad423e84fa5..6efabe537f7 100644 --- a/homeassistant/components/tplink/light.py +++ b/homeassistant/components/tplink/light.py @@ -2,9 +2,9 @@ from __future__ import annotations import logging -from typing import Any +from typing import Any, cast -from kasa import SmartDevice +from kasa import SmartBulb from homeassistant.components.light import ( ATTR_BRIGHTNESS, @@ -41,7 +41,7 @@ async def async_setup_entry( ) -> None: """Set up switches.""" coordinator: TPLinkDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] - device = coordinator.device + device = cast(SmartBulb, coordinator.device) if device.is_bulb or device.is_light_strip or device.is_dimmer: async_add_entities([TPLinkSmartBulb(device, coordinator)]) @@ -50,10 +50,11 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity): """Representation of a TPLink Smart Bulb.""" coordinator: TPLinkDataUpdateCoordinator + device: SmartBulb def __init__( self, - device: SmartDevice, + device: SmartBulb, coordinator: TPLinkDataUpdateCoordinator, ) -> None: """Initialize the switch.""" diff --git a/homeassistant/components/tplink/manifest.json b/homeassistant/components/tplink/manifest.json index 2da05abc35e..5e0b98c4ddb 100644 --- a/homeassistant/components/tplink/manifest.json +++ b/homeassistant/components/tplink/manifest.json @@ -3,7 +3,7 @@ "name": "TP-Link Kasa Smart", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/tplink", - "requirements": ["python-kasa==0.4.0"], + "requirements": ["python-kasa==0.4.1"], "codeowners": ["@rytilahti", "@thegardenmonkey"], "dependencies": ["network"], "quality_scale": "platinum", diff --git a/homeassistant/components/tplink/switch.py b/homeassistant/components/tplink/switch.py index eb1094b7675..823d37267d6 100644 --- a/homeassistant/components/tplink/switch.py +++ b/homeassistant/components/tplink/switch.py @@ -2,9 +2,9 @@ from __future__ import annotations import logging -from typing import Any +from typing import Any, cast -from kasa import SmartDevice +from kasa import SmartDevice, SmartPlug from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry @@ -27,7 +27,7 @@ async def async_setup_entry( ) -> None: """Set up switches.""" coordinator: TPLinkDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] - device = coordinator.device + device = cast(SmartPlug, coordinator.device) if not device.is_plug and not device.is_strip: return entities: list = [] @@ -48,11 +48,12 @@ class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity): """Representation of switch for the LED of a TPLink Smart Plug.""" coordinator: TPLinkDataUpdateCoordinator + device: SmartPlug _attr_entity_category = EntityCategory.CONFIG def __init__( - self, device: SmartDevice, coordinator: TPLinkDataUpdateCoordinator + self, device: SmartPlug, coordinator: TPLinkDataUpdateCoordinator ) -> None: """Initialize the LED switch.""" super().__init__(device, coordinator) diff --git a/requirements_all.txt b/requirements_all.txt index a8709e3c6ff..5628e197e2c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1939,7 +1939,7 @@ python-join-api==0.0.6 python-juicenet==1.0.2 # homeassistant.components.tplink -python-kasa==0.4.0 +python-kasa==0.4.1 # homeassistant.components.lirc # python-lirc==1.2.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 560d5e36e31..c2cae070fd4 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1200,7 +1200,7 @@ python-izone==1.2.3 python-juicenet==1.0.2 # homeassistant.components.tplink -python-kasa==0.4.0 +python-kasa==0.4.1 # homeassistant.components.xiaomi_miio python-miio==0.5.9.2