Skip to content

Commit

Permalink
Merge pull request #671 from petretiandrea/release/2.13.0
Browse files Browse the repository at this point in the history
Release 2.13.0
  • Loading branch information
petretiandrea authored Jan 6, 2024
2 parents 6bd9d13 + 744605e commit cb4c0d2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ For some unknown reason email with capital letter thrown an "Invalid authenticat
- [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`)
- [x] support for tapo light bulb with or without color (`L530`, `L510`, `L520`, `L630`, `L610`)
- [x] support for tapo light bulb with or without color (`L530`, `L510`, `L520`, `L630`, `L610`, `L530B`)
- [x] support for tapo light strip with or without color (`L900`)
- [x] partial support for tapo light strip (`L920`, `L930` (including light effects)). Only RGB works not the addressable feature of strip.
- [x] support for energy monitoring (`P110`, `P115`, `P110M`)
Expand Down
8 changes: 7 additions & 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.2"
VERSION = "2.13.0"

SUPPORTED_HUB_DEVICE_MODEL = ["h100", "kh100", "h200"]
SUPPORTED_HUB_ALARM = "h100"
Expand Down Expand Up @@ -39,6 +39,12 @@
"s505": [ColorMode.ONOFF],
"ts15": [ColorMode.ONOFF],
"l535": [ColorMode.ONOFF, ColorMode.BRIGHTNESS, ColorMode.COLOR_TEMP, ColorMode.HS],
"l535b": [
ColorMode.ONOFF,
ColorMode.BRIGHTNESS,
ColorMode.COLOR_TEMP,
ColorMode.HS,
],
}
SUPPORTED_DEVICE_AS_LED_STRIP = ["l930", "l920", "l900"]

Expand Down
6 changes: 4 additions & 2 deletions custom_components/tapo/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from homeassistant.components.light import ATTR_HS_COLOR
from homeassistant.components.light import ColorMode
from homeassistant.components.light import LightEntity
from homeassistant.components.light import SUPPORT_EFFECT
from homeassistant.components.light import LightEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -82,7 +82,9 @@ def __init__(
self._attr_min_color_temp_kelvin = 2500
self._attr_max_mireds = kelvin_to_mired(self._attr_min_color_temp_kelvin)
self._attr_min_mireds = kelvin_to_mired(self._attr_max_color_temp_kelvin)
self._attr_supported_features = SUPPORT_EFFECT if self._effects else 0
self._attr_supported_features = (
LightEntityFeature.EFFECT if self._effects else 0
)
self._attr_supported_color_modes = color_modes
self._attr_effect_list = list(self._effects.keys()) if self._effects else None

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.2",
"version": "2.13.0",
"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==4.0.1"],
"requirements": ["plugp100==4.0.3"],
"dependencies": [],
"integration_type": "device",
"codeowners": ["@petretiandrea"]
Expand Down
37 changes: 16 additions & 21 deletions custom_components/tapo/sensors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,23 @@
from custom_components.tapo.sensors.tapo_sensor_source import TapoSensorSource
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.components.sensor import SensorStateClass
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING
from homeassistant.const import DEVICE_CLASS_ENERGY
from homeassistant.const import DEVICE_CLASS_POWER
from homeassistant.const import DEVICE_CLASS_SIGNAL_STRENGTH
from homeassistant.const import ENERGY_KILO_WATT_HOUR
from homeassistant.const import POWER_WATT
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT
from homeassistant.const import TIME_MINUTES
from homeassistant.const import UnitOfEnergy
from homeassistant.const import UnitOfPower
from homeassistant.const import UnitOfTime
from homeassistant.helpers.typing import StateType
from plugp100.responses.device_state import DeviceInfo
from plugp100.responses.energy_info import EnergyInfo
from plugp100.responses.power_info import PowerInfo
from plugp100.responses.device_state import DeviceInfo


class TodayEnergySensorSource(TapoSensorSource):
def get_config(self) -> SensorConfig:
return SensorConfig(
"today energy",
DEVICE_CLASS_ENERGY,
STATE_CLASS_TOTAL_INCREASING,
ENERGY_KILO_WATT_HOUR,
SensorDeviceClass.ENERGY,
SensorStateClass.TOTAL_INCREASING,
UnitOfEnergy.KILO_WATT_HOUR,
)

def get_value(self, coordinator: TapoCoordinator) -> StateType:
Expand All @@ -37,9 +32,9 @@ class MonthEnergySensorSource(TapoSensorSource):
def get_config(self) -> SensorConfig:
return SensorConfig(
"month energy",
DEVICE_CLASS_ENERGY,
STATE_CLASS_TOTAL_INCREASING,
ENERGY_KILO_WATT_HOUR,
SensorDeviceClass.ENERGY,
SensorStateClass.TOTAL_INCREASING,
UnitOfEnergy.KILO_WATT_HOUR,
)

def get_value(self, coordinator: TapoCoordinator) -> StateType:
Expand Down Expand Up @@ -67,9 +62,9 @@ class CurrentEnergySensorSource(TapoSensorSource):
def get_config(self) -> SensorConfig:
return SensorConfig(
"current power",
DEVICE_CLASS_POWER,
STATE_CLASS_MEASUREMENT,
POWER_WATT,
SensorDeviceClass.POWER,
SensorStateClass.MEASUREMENT,
UnitOfPower.WATT,
)

def get_value(self, coordinator: TapoCoordinator) -> StateType:
Expand All @@ -84,7 +79,7 @@ class SignalSensorSource(TapoSensorSource):
def get_config(self) -> SensorConfig:
return SensorConfig(
name="signal level",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
state_class=None,
unit_measure=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
is_diagnostic=True,
Expand All @@ -103,7 +98,7 @@ def get_config(self) -> SensorConfig:
"today runtime",
SensorDeviceClass.DURATION,
SensorStateClass.TOTAL_INCREASING,
TIME_MINUTES,
UnitOfTime.MINUTES,
)

def get_value(self, coordinator: TapoCoordinator) -> StateType:
Expand All @@ -120,7 +115,7 @@ def get_config(self) -> SensorConfig:
"month runtime",
SensorDeviceClass.DURATION,
SensorStateClass.TOTAL_INCREASING,
TIME_MINUTES,
UnitOfTime.MINUTES,
)

def get_value(self, coordinator: TapoCoordinator) -> StateType:
Expand Down
6 changes: 3 additions & 3 deletions custom_components/tapo/setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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
from plugp100.discovery.arp_lookup import ArpLookup

_LOGGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -112,10 +112,10 @@ async def try_track_ip_address(
try:
if adapter is not None:
target_network = get_network_of(adapter)
device = await LocalDeviceFinder.scan_one(
device_ip = await ArpLookup.lookup(
mac.replace("-", ":"), target_network, timeout=5
)
return device.get_or_else(last_known_ip)
return device_ip.get_or_else(last_known_ip)
else:
_LOGGGER.warning(
"No adapter found for %s with last ip %s", mac, last_known_ip
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==4.0.1
plugp100==4.0.3
pre-commit==3.3.3
reorder-python-imports==3.10.0
flake8==6.1.0
Expand Down

0 comments on commit cb4c0d2

Please sign in to comment.