Skip to content

Commit

Permalink
Filter out irrelevant entities on SMO20 devices in myuplink (home-ass…
Browse files Browse the repository at this point in the history
  • Loading branch information
astrandb authored Mar 15, 2024
1 parent c69ab42 commit eb1f37e
Show file tree
Hide file tree
Showing 7 changed files with 13,533 additions and 3 deletions.
16 changes: 16 additions & 0 deletions homeassistant/components/myuplink/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ def find_matching_platform(
return Platform.SENSOR

return Platform.SENSOR


def skip_entity(model: str, device_point: DevicePoint) -> bool:
"""Check if entity should be skipped for this device model."""
if model == "SMO 20":
if len(device_point.smart_home_categories) > 0 or device_point.parameter_id in (
"40940",
"47011",
"47015",
"47028",
"47032",
"50004",
):
return False
return True
return False
4 changes: 3 additions & 1 deletion homeassistant/components/myuplink/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from . import MyUplinkDataCoordinator
from .const import DOMAIN
from .entity import MyUplinkEntity
from .helpers import find_matching_platform
from .helpers import find_matching_platform, skip_entity

DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, NumberEntityDescription] = {
"DM": NumberEntityDescription(
Expand Down Expand Up @@ -65,6 +65,8 @@ async def async_setup_entry(
# Setup device point number entities
for device_id, point_data in coordinator.data.points.items():
for point_id, device_point in point_data.items():
if skip_entity(device_point.category, device_point):
continue
description = get_description(device_point)
if find_matching_platform(device_point, description) == Platform.NUMBER:
entities.append(
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/myuplink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from . import MyUplinkDataCoordinator
from .const import DOMAIN
from .entity import MyUplinkEntity
from .helpers import find_matching_platform
from .helpers import find_matching_platform, skip_entity

DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
"°C": SensorEntityDescription(
Expand Down Expand Up @@ -155,6 +155,8 @@ async def async_setup_entry(
# Setup device point sensors
for device_id, point_data in coordinator.data.points.items():
for point_id, device_point in point_data.items():
if skip_entity(device_point.category, device_point):
continue
if find_matching_platform(device_point) == Platform.SENSOR:
description = get_description(device_point)
entity_class = MyUplinkDevicePointSensor
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/myuplink/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from . import MyUplinkDataCoordinator
from .const import DOMAIN
from .entity import MyUplinkEntity
from .helpers import find_matching_platform
from .helpers import find_matching_platform, skip_entity

CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SwitchEntityDescription]] = {
"NIBEF": {
Expand Down Expand Up @@ -58,6 +58,8 @@ async def async_setup_entry(
# Setup device point switches
for device_id, point_data in coordinator.data.points.items():
for point_id, device_point in point_data.items():
if skip_entity(device_point.category, device_point):
continue
if find_matching_platform(device_point) == Platform.SWITCH:
description = get_description(device_point)

Expand Down
Loading

0 comments on commit eb1f37e

Please sign in to comment.