Skip to content

Commit

Permalink
Merge pull request #641 from petretiandrea/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
petretiandrea authored Dec 10, 2023
2 parents a06940f + 49e2756 commit d728515
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ The core of the integration is provied by [plugp100](https://github.com/petretia
[![License][license-shield]](LICENSE)
[![BuyMeCoffee][buymecoffeebadge]][buymecoffee]

## Warning!!!
## Warnings

### Tapo protocol

Tapo is updating it's devices with a new firmware which use a new protocol called KLAP. This integration support it's but if you running older version your devices maybe cannot works. So please keep this integration up to date by using HACS!

### Local Integration

Although the integration works using LAN, the tapo device needs internet access to synchronize with tapo cloud, especially for credentials, a missing internet access could lead into "Invalida authentication error". Also a static IP must be set for device.

## Warning!!!
### Authentication

For some unknown reason email with capital letter thrown an "Invalid authentication" error. So before open an new issue check your email address on Tapo App Settings. If contains capital letter, the integration won't work. I've opened an issue that explain this [#122](https://github.com/petretiandrea/home-assistant-tapo-p100/issues/122), I will fix asap. As workaround you can create a new account using all lower-case in your email address.

Expand All @@ -33,6 +39,7 @@ For some unknown reason email with capital letter thrown an "Invalid authenticat
- [x] support for `T31x` temperature and humidity sensor hub's device
- [x] support for `T100` motion sensor hub's device
- [x] support for `T110` smart door hub's device
- [x] support for `S220`, `S210` switch hub's device
- [x] partial support for `S200B` button hub's device (actually no events are reported to HA)
- [x] support for tapo powerstrip (`P300`). A special thanks go to @alxlk to support me with max one-time contribution which allows me to buy the device
- [x] support for tapo switch (`P100`, `P110`, `P105`, `P115`, `P125`, `P110M`)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tapo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

NAME = "tapo"
DOMAIN = "tapo"
VERSION = "2.12.0"
VERSION = "2.12.1"

SUPPORTED_HUB_DEVICE_MODEL = ["h100", "kh100", "h200"]
SUPPORTED_HUB_ALARM = "h100"
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tapo/coordinators.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
from plugp100.api.hub.hub_device import HubDevice
from plugp100.api.ledstrip_device import LedStripDevice
from plugp100.api.light_device import LightDevice
from plugp100.api.plug_device import EnergyInfo
from plugp100.api.plug_device import PlugDevice
from plugp100.api.plug_device import PowerInfo
from plugp100.api.power_strip_device import PowerStripDevice
from plugp100.api.tapo_client import TapoClient
from plugp100.common.functional.tri import Failure
from plugp100.common.functional.tri import Try
from plugp100.responses.energy_info import EnergyInfo
from plugp100.responses.power_info import PowerInfo
from plugp100.responses.child_device_list import PowerStripChild
from plugp100.responses.device_state import DeviceInfo as TapoDeviceInfo
from plugp100.responses.device_state import LedStripDeviceState
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tapo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"domain": "tapo",
"name": "TP-Link Tapo",
"config_flow": true,
"version": "2.12.0",
"version": "2.12.1",
"iot_class": "local_polling",
"documentation": "https://github.com/petretiandrea/home-assistant-tapo-p100",
"issue_tracker": "https://github.com/petretiandrea/home-assistant-tapo-p100/issues",
"requirements": ["plugp100==3.14.0"],
"requirements": ["plugp100==3.14.1"],
"dependencies": [],
"integration_type": "device",
"codeowners": ["@petretiandrea"]
Expand Down
16 changes: 12 additions & 4 deletions custom_components/tapo/sensors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT
from homeassistant.const import TIME_MINUTES
from homeassistant.helpers.typing import StateType
from plugp100.api.plug_device import EnergyInfo
from plugp100.api.plug_device import PowerInfo
from plugp100.responses.energy_info import EnergyInfo
from plugp100.responses.power_info import PowerInfo
from plugp100.responses.device_state import DeviceInfo


Expand Down Expand Up @@ -107,7 +107,11 @@ def get_config(self) -> SensorConfig:
)

def get_value(self, coordinator: TapoCoordinator) -> StateType:
return coordinator.get_state_of(EnergyInfo).today_runtime
if coordinator.has_capability(EnergyInfo):
sensor = coordinator.get_state_of(EnergyInfo)
if sensor is not None:
return sensor.today_runtime
return None


class MonthRuntimeSensorSource(TapoSensorSource):
Expand All @@ -120,4 +124,8 @@ def get_config(self) -> SensorConfig:
)

def get_value(self, coordinator: TapoCoordinator) -> StateType:
return coordinator.get_state_of(EnergyInfo).month_runtime
if coordinator.has_capability(EnergyInfo):
sensor = coordinator.get_state_of(EnergyInfo)
if sensor is not None:
return sensor.month_runtime
return None
4 changes: 2 additions & 2 deletions custom_components/tapo/setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from plugp100.api.tapo_client import TapoClient
from plugp100.common.credentials import AuthCredential
from plugp100.discovery.local_device_finder import LocalDeviceFinder
Expand Down Expand Up @@ -93,7 +93,7 @@ async def connect_tapo_client(
_LOGGGER.debug("Re-using setup API to create a coordinator")
else:
_LOGGGER.debug("Creating new API to create a coordinator for %s", unique_id)
session = async_get_clientsession(hass)
session = async_create_clientsession(hass)
host, port = get_host_port(ip_address)
api = TapoClient.create(
credentials, address=host, port=port, http_session=session
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
homeassistant==2023.8.3
plugp100==3.14.0
plugp100==3.14.1
pre-commit==3.3.3
reorder-python-imports==3.10.0
flake8==6.1.0
Expand Down

0 comments on commit d728515

Please sign in to comment.