Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ The following devices have been tested and confirmed as working. If your device

- **Plugs**: P100, P105, P110, P110M, P115, P125M, P135, TP10, TP15
- **Power Strips**: P210M, P300, P304M, P306, P316M, TP25
- **Wall Switches**: S210, S220, S500, S500D, S505, S505D, TS15
- **Wall Switches**: S210, S220, S500, S500D, S505, S505D, S515D, TS15
- **Bulbs**: L430C, L430P, L510B, L510E, L530B, L530E, L535E, L630
- **Light Strips**: L900-10, L900-5, L920-5, L930-5
- **Cameras**: C100, C101, C110, C210, C220, C225, C325WB, C460, C520WS, C720, TC40, TC65, TC70
Expand Down
2 changes: 2 additions & 0 deletions SUPPORTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ All Tapo devices require authentication.<br>Hub-Connected Devices may work acros
- Hardware: 1.0 (US) / Firmware: 1.0.2
- **S505D**
- Hardware: 1.0 (US) / Firmware: 1.1.0
- **S515D**
- Hardware: 1.6 (US) / Firmware: 1.0.4
- **TS15**
- Hardware: 1.0 (US) / Firmware: 1.2.2

Expand Down
13 changes: 5 additions & 8 deletions kasa/smart/modules/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,14 @@ async def _post_update_hook(self) -> None:
self._supported | EnergyInterface.ModuleFeature.VOLTAGE_CURRENT
)

if (power := self._energy.get("current_power")) is not None or (
power := data.get("get_emeter_data", {}).get("power_mw")
) is not None:
if (power := data.get("get_emeter_data", {}).get("power_mw")) is not None:
self._current_consumption = power / 1_000
# Fallback if get_energy_usage does not provide current_power,
# which can happen on some newer devices (e.g. P304M).
# This may not be valid scenario as it pre-dates trying get_emeter_data
Comment on lines -41 to -43
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the comment? Does it not apply anymore?

Looking at the whole code flow with all different conditionals, it makes sense to do some cleaning up here?

elif (
power := self.data.get("get_current_power", {}).get("current_power")
power := data.get("get_current_power", {}).get("current_power")
) is not None:
self._current_consumption = power
elif (power := self._energy.get("current_power")) is not None:
self._current_consumption = power / 1_000
else:
self._current_consumption = None

Expand All @@ -63,7 +60,7 @@ def query(self) -> dict:
def optional_response_keys(self) -> list[str]:
"""Return optional response keys for the module."""
if self.supported_version > 1:
return ["get_energy_usage"]
return ["get_energy_usage", "get_current_power"]
return []

@property
Expand Down
5 changes: 3 additions & 2 deletions tests/device_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"S500D",
"S505",
"S505D",
"S515D",
"TS15",
}
SWITCHES = {*SWITCHES_IOT, *SWITCHES_SMART}
Expand All @@ -119,7 +120,7 @@
STRIPS = {*STRIPS_IOT, *STRIPS_SMART}

DIMMERS_IOT = {"ES20M", "HS220", "KS220", "KS220M", "KS230", "KP405"}
DIMMERS_SMART = {"HS220", "KS225", "S500D", "P135"}
DIMMERS_SMART = {"HS220", "KS225", "S500D", "S505D", "S515D", "P135"}
DIMMERS = {
*DIMMERS_IOT,
*DIMMERS_SMART,
Expand All @@ -143,7 +144,7 @@
VACUUMS_SMART = {"RV20"}

WITH_EMETER_IOT = {"EP25", "HS110", "HS300", "KP115", "KP125", *BULBS_IOT}
WITH_EMETER_SMART = {"P110", "P110M", "P115", "KP125M", "EP25", "P304M"}
WITH_EMETER_SMART = {"P110", "P110M", "P115", "KP125M", "EP25", "P304M", "S515D"}
WITH_EMETER = {*WITH_EMETER_IOT, *WITH_EMETER_SMART}

DIMMABLE = {*BULBS, *DIMMERS}
Expand Down
Loading
Loading