Skip to content

Commit

Permalink
Merge branch 'dev' into bump_pyheos
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsayre authored Jan 11, 2025
2 parents eef3f30 + 52c57eb commit b6b71a9
Show file tree
Hide file tree
Showing 26 changed files with 1,535 additions and 135 deletions.
4 changes: 2 additions & 2 deletions CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions homeassistant/components/habitica/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@
},
"constitution": {
"default": "mdi:run-fast"
},
"food_total": {
"default": "mdi:candy",
"state": {
"0": "mdi:candy-off"
}
},
"eggs_total": {
"default": "mdi:egg",
"state": {
"0": "mdi:egg-off"
}
},
"hatching_potions_total": {
"default": "mdi:flask-round-bottom"
},
"saddle": {
"default": "mdi:horse"
},
"quest_scrolls": {
"default": "mdi:script-text-outline"
}
},
"switch": {
Expand Down
45 changes: 44 additions & 1 deletion homeassistant/components/habitica/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .const import ASSETS_URL
from .entity import HabiticaBase
from .types import HabiticaConfigEntry
from .util import get_attribute_points, get_attributes_total
from .util import get_attribute_points, get_attributes_total, inventory_list

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -73,6 +73,11 @@ class HabiticaSensorEntity(StrEnum):
INTELLIGENCE = "intelligence"
CONSTITUTION = "constitution"
PERCEPTION = "perception"
EGGS_TOTAL = "eggs_total"
HATCHING_POTIONS_TOTAL = "hatching_potions_total"
FOOD_TOTAL = "food_total"
SADDLE = "saddle"
QUEST_SCROLLS = "quest_scrolls"


SENSOR_DESCRIPTIONS: tuple[HabiticaSensorEntityDescription, ...] = (
Expand Down Expand Up @@ -179,6 +184,44 @@ class HabiticaSensorEntity(StrEnum):
suggested_display_precision=0,
native_unit_of_measurement="CON",
),
HabiticaSensorEntityDescription(
key=HabiticaSensorEntity.EGGS_TOTAL,
translation_key=HabiticaSensorEntity.EGGS_TOTAL,
value_fn=lambda user, _: sum(n for n in user.items.eggs.values()),
entity_picture="Pet_Egg_Egg.png",
attributes_fn=lambda user, content: inventory_list(user, content, "eggs"),
),
HabiticaSensorEntityDescription(
key=HabiticaSensorEntity.HATCHING_POTIONS_TOTAL,
translation_key=HabiticaSensorEntity.HATCHING_POTIONS_TOTAL,
value_fn=lambda user, _: sum(n for n in user.items.hatchingPotions.values()),
entity_picture="Pet_HatchingPotion_RoyalPurple.png",
attributes_fn=(
lambda user, content: inventory_list(user, content, "hatchingPotions")
),
),
HabiticaSensorEntityDescription(
key=HabiticaSensorEntity.FOOD_TOTAL,
translation_key=HabiticaSensorEntity.FOOD_TOTAL,
value_fn=(
lambda user, _: sum(n for k, n in user.items.food.items() if k != "Saddle")
),
entity_picture="Pet_Food_Strawberry.png",
attributes_fn=lambda user, content: inventory_list(user, content, "food"),
),
HabiticaSensorEntityDescription(
key=HabiticaSensorEntity.SADDLE,
translation_key=HabiticaSensorEntity.SADDLE,
value_fn=lambda user, _: user.items.food.get("Saddle", 0),
entity_picture="Pet_Food_Saddle.png",
),
HabiticaSensorEntityDescription(
key=HabiticaSensorEntity.QUEST_SCROLLS,
translation_key=HabiticaSensorEntity.QUEST_SCROLLS,
value_fn=(lambda user, _: sum(n for n in user.items.quests.values())),
entity_picture="inventory_quest_scroll_dustbunnies.png",
attributes_fn=lambda user, content: inventory_list(user, content, "quests"),
),
)


Expand Down
20 changes: 20 additions & 0 deletions homeassistant/components/habitica/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,26 @@
"name": "[%key:component::habitica::entity::sensor::strength::state_attributes::buffs::name%]"
}
}
},
"eggs_total": {
"name": "Eggs",
"unit_of_measurement": "eggs"
},
"hatching_potions_total": {
"name": "Hatching potions",
"unit_of_measurement": "potions"
},
"food_total": {
"name": "Pet food",
"unit_of_measurement": "foods"
},
"saddle": {
"name": "Saddles",
"unit_of_measurement": "saddles"
},
"quest_scrolls": {
"name": "Quest scrolls",
"unit_of_measurement": "scrolls"
}
},
"switch": {
Expand Down
11 changes: 11 additions & 0 deletions homeassistant/components/habitica/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,14 @@ def get_attributes_total(user: UserData, content: ContentData, attribute: str) -
return floor(
sum(value for value in get_attribute_points(user, content, attribute).values())
)


def inventory_list(
user: UserData, content: ContentData, item_type: str
) -> dict[str, int]:
"""List inventory items of given type."""
return {
getattr(content, item_type)[k].text: v
for k, v in getattr(user.items, item_type, {}).items()
if k != "Saddle"
}
3 changes: 1 addition & 2 deletions homeassistant/components/lametric/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class LaMetricNumberEntityDescription(NumberEntityDescription):
LaMetricNumberEntityDescription(
key="brightness",
translation_key="brightness",
name="Brightness",
entity_category=EntityCategory.CONFIG,
native_step=1,
native_min_value=0,
Expand All @@ -45,11 +44,11 @@ class LaMetricNumberEntityDescription(NumberEntityDescription):
LaMetricNumberEntityDescription(
key="volume",
translation_key="volume",
name="Volume",
entity_category=EntityCategory.CONFIG,
native_step=1,
native_min_value=0,
native_max_value=100,
native_unit_of_measurement=PERCENTAGE,
has_fn=lambda device: bool(device.audio and device.audio.available),
value_fn=lambda device: device.audio.volume if device.audio else 0,
set_value_fn=lambda api, volume: api.audio(volume=int(volume)),
Expand Down
8 changes: 8 additions & 0 deletions homeassistant/components/lametric/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
"name": "Dismiss all notifications"
}
},
"number": {
"brightness": {
"name": "Brightness"
},
"volume": {
"name": "Volume"
}
},
"sensor": {
"rssi": {
"name": "Wi-Fi signal"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nest/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"pubsub": {
"title": "Configure Google Cloud Pub/Sub",
"description": "Home Assistant uses Cloud Pub/Sub receive realtime Nest device updates. Nest servers publish updates to a Pub/Sub topic and Home Assistant receives the updates through a Pub/Sub subscription.\n\n1. Visit the [Device Access Console]({device_access_console_url}) and ensure a Pub/Sub topic is configured.\n2. Visit the [Cloud Console]({url}) to find your Google Cloud Project ID and confirm it is correct below.\n3. The next step will attempt to auto-discover Pub/Sub topics and subscriptions.\n\nSee the integration documentation for [more info]({more_info_url}).",
"description": "Home Assistant uses Cloud Pub/Sub receive realtime Nest device updates. Nest servers publish updates to a Pub/Sub topic and Home Assistant receives the updates through a Pub/Sub subscription.\n\n1. Visit the [Device Access Console]({device_access_console_url}) and ensure a Pub/Sub topic is configured.\n1. Visit the [Cloud Console]({url}) to find your Google Cloud Project ID and confirm it is correct below.\n1. The next step will attempt to auto-discover Pub/Sub topics and subscriptions.\n\nSee the integration documentation for [more info]({more_info_url}).",
"data": {
"cloud_project_id": "[%key:component::nest::config::step::cloud_project::data::cloud_project_id%]"
}
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/netgear/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@
key="type",
translation_key="link_type",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
"link_rate": SensorEntityDescription(
key="link_rate",
translation_key="link_rate",
native_unit_of_measurement="Mbps",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
"signal": SensorEntityDescription(
key="signal",
translation_key="signal_strength",
native_unit_of_measurement=PERCENTAGE,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
"ssid": SensorEntityDescription(
key="ssid",
Expand All @@ -69,6 +72,7 @@
key="conn_ap_mac",
translation_key="access_point_mac",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
}

Expand Down Expand Up @@ -326,8 +330,6 @@ def new_device_callback() -> None:
class NetgearSensorEntity(NetgearDeviceEntity, SensorEntity):
"""Representation of a device connected to a Netgear router."""

_attr_entity_registry_enabled_default = False

def __init__(
self,
coordinator: DataUpdateCoordinator,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/onvif/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "onvif",
"name": "ONVIF",
"codeowners": ["@hunterjm"],
"codeowners": ["@hunterjm", "@jterrace"],
"config_flow": true,
"dependencies": ["ffmpeg"],
"dhcp": [{ "registered_devices": true }],
Expand Down
88 changes: 54 additions & 34 deletions homeassistant/components/onvif/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from collections.abc import Callable, Coroutine
import dataclasses
import datetime
from typing import Any

Expand Down Expand Up @@ -370,22 +371,56 @@ async def async_parse_vehicle_detector(uid: str, msg) -> Event | None:
return None


@PARSERS.register("tns1:RuleEngine/TPSmartEventDetector/TPSmartEvent")
_TAPO_EVENT_TEMPLATES: dict[str, Event] = {
"IsVehicle": Event(
uid="",
name="Vehicle Detection",
platform="binary_sensor",
device_class="motion",
),
"IsPeople": Event(
uid="", name="Person Detection", platform="binary_sensor", device_class="motion"
),
"IsLineCross": Event(
uid="",
name="Line Detector Crossed",
platform="binary_sensor",
device_class="motion",
),
"IsTamper": Event(
uid="", name="Tamper Detection", platform="binary_sensor", device_class="tamper"
),
"IsIntrusion": Event(
uid="",
name="Intrusion Detection",
platform="binary_sensor",
device_class="safety",
),
}


@PARSERS.register("tns1:RuleEngine/CellMotionDetector/Intrusion")
@PARSERS.register("tns1:RuleEngine/CellMotionDetector/LineCross")
@PARSERS.register("tns1:RuleEngine/CellMotionDetector/People")
@PARSERS.register("tns1:RuleEngine/CellMotionDetector/Tamper")
@PARSERS.register("tns1:RuleEngine/CellMotionDetector/TpSmartEvent")
@PARSERS.register("tns1:RuleEngine/PeopleDetector/People")
@PARSERS.register("tns1:RuleEngine/TPSmartEventDetector/TPSmartEvent")
async def async_parse_tplink_detector(uid: str, msg) -> Event | None:
"""Handle parsing tplink smart event messages.
Topic: tns1:RuleEngine/TPSmartEventDetector/TPSmartEvent
Topic: tns1:RuleEngine/CellMotionDetector/Intrusion
Topic: tns1:RuleEngine/CellMotionDetector/LineCross
Topic: tns1:RuleEngine/CellMotionDetector/People
Topic: tns1:RuleEngine/CellMotionDetector/Tamper
Topic: tns1:RuleEngine/CellMotionDetector/TpSmartEvent
Topic: tns1:RuleEngine/PeopleDetector/People
Topic: tns1:RuleEngine/TPSmartEventDetector/TPSmartEvent
"""
video_source = ""
video_analytics = ""
rule = ""
topic = ""
vehicle = False
person = False
enabled = False
try:
video_source = ""
video_analytics = ""
rule = ""
topic, payload = extract_message(msg)
for source in payload.Source.SimpleItem:
if source.Name == "VideoSourceConfigurationToken":
Expand All @@ -396,34 +431,19 @@ async def async_parse_tplink_detector(uid: str, msg) -> Event | None:
rule = source.Value

for item in payload.Data.SimpleItem:
if item.Name == "IsVehicle":
vehicle = True
enabled = item.Value == "true"
if item.Name == "IsPeople":
person = True
enabled = item.Value == "true"
event_template = _TAPO_EVENT_TEMPLATES.get(item.Name, None)
if event_template is None:
continue

return dataclasses.replace(
event_template,
uid=f"{uid}_{topic}_{video_source}_{video_analytics}_{rule}",
value=item.Value == "true",
)

except (AttributeError, KeyError):
return None

if vehicle:
return Event(
f"{uid}_{topic}_{video_source}_{video_analytics}_{rule}",
"Vehicle Detection",
"binary_sensor",
"motion",
None,
enabled,
)
if person:
return Event(
f"{uid}_{topic}_{video_source}_{video_analytics}_{rule}",
"Person Detection",
"binary_sensor",
"motion",
None,
enabled,
)

return None


Expand Down
8 changes: 8 additions & 0 deletions homeassistant/components/switcher_kis/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
"temperature": {
"name": "Current temperature"
}
},
"switch": {
"child_lock": {
"name": "Child lock"
},
"multi_child_lock": {
"name": "Child lock {cover_id}"
}
}
},
"services": {
Expand Down
Loading

0 comments on commit b6b71a9

Please sign in to comment.