mirror of
https://github.com/home-assistant/core.git
synced 2026-02-24 11:11:16 +01:00
Compare commits
17 Commits
infrared
...
matter_cle
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d97424a22 | ||
|
|
76114c9ded | ||
|
|
0334dad2f8 | ||
|
|
2dd65172b0 | ||
|
|
4532fd379e | ||
|
|
578b2b3d43 | ||
|
|
9bb2f56fbe | ||
|
|
a7d209f1f5 | ||
|
|
83d73dce5c | ||
|
|
d84f81daf2 | ||
|
|
79d4f5c8cf | ||
|
|
e9e1abb604 | ||
|
|
9a97541253 | ||
|
|
fd39f3c431 | ||
|
|
2cc4a77746 | ||
|
|
d7ef65e562 | ||
|
|
e765c1652c |
@@ -34,7 +34,6 @@ base_platforms: &base_platforms
|
||||
- homeassistant/components/humidifier/**
|
||||
- homeassistant/components/image/**
|
||||
- homeassistant/components/image_processing/**
|
||||
- homeassistant/components/infrared/**
|
||||
- homeassistant/components/lawn_mower/**
|
||||
- homeassistant/components/light/**
|
||||
- homeassistant/components/lock/**
|
||||
|
||||
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@@ -37,7 +37,7 @@ on:
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
CACHE_VERSION: 3
|
||||
CACHE_VERSION: 2
|
||||
UV_CACHE_VERSION: 1
|
||||
MYPY_CACHE_VERSION: 1
|
||||
HA_SHORT_VERSION: "2026.3"
|
||||
|
||||
@@ -289,7 +289,6 @@ homeassistant.components.imgw_pib.*
|
||||
homeassistant.components.immich.*
|
||||
homeassistant.components.incomfort.*
|
||||
homeassistant.components.inels.*
|
||||
homeassistant.components.infrared.*
|
||||
homeassistant.components.input_button.*
|
||||
homeassistant.components.input_select.*
|
||||
homeassistant.components.input_text.*
|
||||
@@ -584,7 +583,6 @@ homeassistant.components.vacuum.*
|
||||
homeassistant.components.vallox.*
|
||||
homeassistant.components.valve.*
|
||||
homeassistant.components.velbus.*
|
||||
homeassistant.components.velux.*
|
||||
homeassistant.components.vivotek.*
|
||||
homeassistant.components.vlc_telnet.*
|
||||
homeassistant.components.vodafone_station.*
|
||||
@@ -614,7 +612,6 @@ homeassistant.components.yale_smart_alarm.*
|
||||
homeassistant.components.yalexs_ble.*
|
||||
homeassistant.components.youtube.*
|
||||
homeassistant.components.zeroconf.*
|
||||
homeassistant.components.zinvolt.*
|
||||
homeassistant.components.zodiac.*
|
||||
homeassistant.components.zone.*
|
||||
homeassistant.components.zwave_js.*
|
||||
|
||||
14
CODEOWNERS
generated
14
CODEOWNERS
generated
@@ -403,8 +403,8 @@ build.json @home-assistant/supervisor
|
||||
/tests/components/duke_energy/ @hunterjm
|
||||
/homeassistant/components/duotecno/ @cereal2nd
|
||||
/tests/components/duotecno/ @cereal2nd
|
||||
/homeassistant/components/dwd_weather_warnings/ @runningman84 @stephan192
|
||||
/tests/components/dwd_weather_warnings/ @runningman84 @stephan192
|
||||
/homeassistant/components/dwd_weather_warnings/ @runningman84 @stephan192 @andarotajo
|
||||
/tests/components/dwd_weather_warnings/ @runningman84 @stephan192 @andarotajo
|
||||
/homeassistant/components/dynalite/ @ziv1234
|
||||
/tests/components/dynalite/ @ziv1234
|
||||
/homeassistant/components/eafm/ @Jc2k
|
||||
@@ -794,8 +794,6 @@ build.json @home-assistant/supervisor
|
||||
/tests/components/inels/ @epdevlab
|
||||
/homeassistant/components/influxdb/ @mdegat01 @Robbie1221
|
||||
/tests/components/influxdb/ @mdegat01 @Robbie1221
|
||||
/homeassistant/components/infrared/ @home-assistant/core
|
||||
/tests/components/infrared/ @home-assistant/core
|
||||
/homeassistant/components/inkbird/ @bdraco
|
||||
/tests/components/inkbird/ @bdraco
|
||||
/homeassistant/components/input_boolean/ @home-assistant/core
|
||||
@@ -1084,8 +1082,6 @@ build.json @home-assistant/supervisor
|
||||
/tests/components/mutesync/ @currentoor
|
||||
/homeassistant/components/my/ @home-assistant/core
|
||||
/tests/components/my/ @home-assistant/core
|
||||
/homeassistant/components/myneomitis/ @l-pr
|
||||
/tests/components/myneomitis/ @l-pr
|
||||
/homeassistant/components/mysensors/ @MartinHjelmare @functionpointer
|
||||
/tests/components/mysensors/ @MartinHjelmare @functionpointer
|
||||
/homeassistant/components/mystrom/ @fabaff
|
||||
@@ -1884,8 +1880,8 @@ build.json @home-assistant/supervisor
|
||||
/tests/components/webostv/ @thecode
|
||||
/homeassistant/components/websocket_api/ @home-assistant/core
|
||||
/tests/components/websocket_api/ @home-assistant/core
|
||||
/homeassistant/components/weheat/ @barryvdh
|
||||
/tests/components/weheat/ @barryvdh
|
||||
/homeassistant/components/weheat/ @jesperraemaekers
|
||||
/tests/components/weheat/ @jesperraemaekers
|
||||
/homeassistant/components/wemo/ @esev
|
||||
/tests/components/wemo/ @esev
|
||||
/homeassistant/components/whirlpool/ @abmantis @mkmer
|
||||
@@ -1963,8 +1959,6 @@ build.json @home-assistant/supervisor
|
||||
/tests/components/zha/ @dmulcahey @adminiuga @puddly @TheJulianJES
|
||||
/homeassistant/components/zimi/ @markhannon
|
||||
/tests/components/zimi/ @markhannon
|
||||
/homeassistant/components/zinvolt/ @joostlek
|
||||
/tests/components/zinvolt/ @joostlek
|
||||
/homeassistant/components/zodiac/ @JulienTant
|
||||
/tests/components/zodiac/ @JulienTant
|
||||
/homeassistant/components/zone/ @home-assistant/core
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import dataclass
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
@@ -39,6 +40,17 @@ class RestoreBackupFileContent:
|
||||
restore_homeassistant: bool
|
||||
|
||||
|
||||
def password_to_key(password: str) -> bytes:
|
||||
"""Generate a AES Key from password.
|
||||
|
||||
Matches the implementation in supervisor.backups.utils.password_to_key.
|
||||
"""
|
||||
key: bytes = password.encode()
|
||||
for _ in range(100):
|
||||
key = hashlib.sha256(key).digest()
|
||||
return key[:16]
|
||||
|
||||
|
||||
def restore_backup_file_content(config_dir: Path) -> RestoreBackupFileContent | None:
|
||||
"""Return the contents of the restore backup file."""
|
||||
instruction_path = config_dir.joinpath(RESTORE_BACKUP_FILE)
|
||||
@@ -84,14 +96,15 @@ def _extract_backup(
|
||||
"""Extract the backup file to the config directory."""
|
||||
with (
|
||||
TemporaryDirectory() as tempdir,
|
||||
securetar.SecureTarArchive(
|
||||
securetar.SecureTarFile(
|
||||
restore_content.backup_file_path,
|
||||
gzip=False,
|
||||
mode="r",
|
||||
) as ostf,
|
||||
):
|
||||
ostf.tar.extractall(
|
||||
ostf.extractall(
|
||||
path=Path(tempdir, "extracted"),
|
||||
members=securetar.secure_path(ostf.tar),
|
||||
members=securetar.secure_path(ostf),
|
||||
filter="fully_trusted",
|
||||
)
|
||||
backup_meta_file = Path(tempdir, "extracted", "backup.json")
|
||||
@@ -113,7 +126,10 @@ def _extract_backup(
|
||||
f"homeassistant.tar{'.gz' if backup_meta['compressed'] else ''}",
|
||||
),
|
||||
gzip=backup_meta["compressed"],
|
||||
password=restore_content.password,
|
||||
key=password_to_key(restore_content.password)
|
||||
if restore_content.password is not None
|
||||
else None,
|
||||
mode="r",
|
||||
) as istf:
|
||||
istf.extractall(
|
||||
path=Path(tempdir, "homeassistant"),
|
||||
|
||||
@@ -23,7 +23,6 @@ from .coordinator import AirOSConfigEntry, AirOSDataUpdateCoordinator
|
||||
|
||||
_PLATFORMS: list[Platform] = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.BUTTON,
|
||||
Platform.SENSOR,
|
||||
]
|
||||
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
"""AirOS button component for Home Assistant."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from airos.exceptions import AirOSException
|
||||
|
||||
from homeassistant.components.button import (
|
||||
ButtonDeviceClass,
|
||||
ButtonEntity,
|
||||
ButtonEntityDescription,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from .coordinator import DOMAIN, AirOSConfigEntry, AirOSDataUpdateCoordinator
|
||||
from .entity import AirOSEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PARALLEL_UPDATES = 0
|
||||
|
||||
REBOOT_BUTTON = ButtonEntityDescription(
|
||||
key="reboot",
|
||||
device_class=ButtonDeviceClass.RESTART,
|
||||
entity_registry_enabled_default=False,
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: AirOSConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the AirOS button from a config entry."""
|
||||
async_add_entities([AirOSRebootButton(config_entry.runtime_data, REBOOT_BUTTON)])
|
||||
|
||||
|
||||
class AirOSRebootButton(AirOSEntity, ButtonEntity):
|
||||
"""Button to reboot device."""
|
||||
|
||||
entity_description: ButtonEntityDescription
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: AirOSDataUpdateCoordinator,
|
||||
description: ButtonEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the AirOS client button."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = f"{coordinator.data.derived.mac}_{description.key}"
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Handle the button press to reboot the device."""
|
||||
try:
|
||||
await self.coordinator.airos_device.login()
|
||||
result = await self.coordinator.airos_device.reboot()
|
||||
|
||||
except AirOSException as err:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="cannot_connect",
|
||||
) from err
|
||||
|
||||
if not result:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="reboot_failed",
|
||||
) from None
|
||||
@@ -2,20 +2,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Mapping
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from airos.discovery import airos_discover_devices
|
||||
from airos.exceptions import (
|
||||
AirOSConnectionAuthenticationError,
|
||||
AirOSConnectionSetupError,
|
||||
AirOSDataMissingError,
|
||||
AirOSDeviceConnectionError,
|
||||
AirOSEndpointError,
|
||||
AirOSKeyDataMissingError,
|
||||
AirOSListenerError,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
@@ -40,27 +36,15 @@ from homeassistant.helpers.selector import (
|
||||
TextSelectorType,
|
||||
)
|
||||
|
||||
from .const import (
|
||||
DEFAULT_SSL,
|
||||
DEFAULT_USERNAME,
|
||||
DEFAULT_VERIFY_SSL,
|
||||
DEVICE_NAME,
|
||||
DOMAIN,
|
||||
HOSTNAME,
|
||||
IP_ADDRESS,
|
||||
MAC_ADDRESS,
|
||||
SECTION_ADVANCED_SETTINGS,
|
||||
)
|
||||
from .const import DEFAULT_SSL, DEFAULT_VERIFY_SSL, DOMAIN, SECTION_ADVANCED_SETTINGS
|
||||
from .coordinator import AirOS8
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# Discovery duration in seconds, airOS announces every 20 seconds
|
||||
DISCOVER_INTERVAL: int = 30
|
||||
|
||||
STEP_DISCOVERY_DATA_SCHEMA = vol.Schema(
|
||||
STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_USERNAME, default=DEFAULT_USERNAME): str,
|
||||
vol.Required(CONF_HOST): str,
|
||||
vol.Required(CONF_USERNAME, default="ubnt"): str,
|
||||
vol.Required(CONF_PASSWORD): str,
|
||||
vol.Required(SECTION_ADVANCED_SETTINGS): section(
|
||||
vol.Schema(
|
||||
@@ -74,10 +58,6 @@ STEP_DISCOVERY_DATA_SCHEMA = vol.Schema(
|
||||
}
|
||||
)
|
||||
|
||||
STEP_MANUAL_DATA_SCHEMA = STEP_DISCOVERY_DATA_SCHEMA.extend(
|
||||
{vol.Required(CONF_HOST): str}
|
||||
)
|
||||
|
||||
|
||||
class AirOSConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Ubiquiti airOS."""
|
||||
@@ -85,29 +65,14 @@ class AirOSConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
VERSION = 2
|
||||
MINOR_VERSION = 1
|
||||
|
||||
_discovery_task: asyncio.Task | None = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize the config flow."""
|
||||
super().__init__()
|
||||
self.airos_device: AirOS8
|
||||
self.errors: dict[str, str] = {}
|
||||
self.discovered_devices: dict[str, dict[str, Any]] = {}
|
||||
self.discovery_abort_reason: str | None = None
|
||||
self.selected_device_info: dict[str, Any] = {}
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
self.errors = {}
|
||||
|
||||
return self.async_show_menu(
|
||||
step_id="user", menu_options=["discovery", "manual"]
|
||||
)
|
||||
|
||||
async def async_step_manual(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the manual input of host and credentials."""
|
||||
self.errors = {}
|
||||
@@ -119,7 +84,7 @@ class AirOSConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
data=validated_info["data"],
|
||||
)
|
||||
return self.async_show_form(
|
||||
step_id="manual", data_schema=STEP_MANUAL_DATA_SCHEMA, errors=self.errors
|
||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=self.errors
|
||||
)
|
||||
|
||||
async def _validate_and_get_device_info(
|
||||
@@ -255,163 +220,3 @@ class AirOSConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
),
|
||||
errors=self.errors,
|
||||
)
|
||||
|
||||
async def async_step_discovery(
|
||||
self,
|
||||
discovery_info: dict[str, Any] | None = None,
|
||||
) -> ConfigFlowResult:
|
||||
"""Start the discovery process."""
|
||||
if self._discovery_task and self._discovery_task.done():
|
||||
self._discovery_task = None
|
||||
|
||||
# Handle appropriate 'errors' as abort through progress_done
|
||||
if self.discovery_abort_reason:
|
||||
return self.async_show_progress_done(
|
||||
next_step_id=self.discovery_abort_reason
|
||||
)
|
||||
|
||||
# Abort through progress_done if no devices were found
|
||||
if not self.discovered_devices:
|
||||
_LOGGER.debug(
|
||||
"No (new or unconfigured) airOS devices found during discovery"
|
||||
)
|
||||
return self.async_show_progress_done(
|
||||
next_step_id="discovery_no_devices"
|
||||
)
|
||||
|
||||
# Skip selecting a device if only one new/unconfigured device was found
|
||||
if len(self.discovered_devices) == 1:
|
||||
self.selected_device_info = list(self.discovered_devices.values())[0]
|
||||
return self.async_show_progress_done(next_step_id="configure_device")
|
||||
|
||||
return self.async_show_progress_done(next_step_id="select_device")
|
||||
|
||||
if not self._discovery_task:
|
||||
self.discovered_devices = {}
|
||||
self._discovery_task = self.hass.async_create_task(
|
||||
self._async_run_discovery_with_progress()
|
||||
)
|
||||
|
||||
# Show the progress bar and wait for discovery to complete
|
||||
return self.async_show_progress(
|
||||
step_id="discovery",
|
||||
progress_action="discovering",
|
||||
progress_task=self._discovery_task,
|
||||
description_placeholders={"seconds": str(DISCOVER_INTERVAL)},
|
||||
)
|
||||
|
||||
async def async_step_select_device(
|
||||
self,
|
||||
discovery_info: dict[str, Any] | None = None,
|
||||
) -> ConfigFlowResult:
|
||||
"""Select a discovered device."""
|
||||
if discovery_info is not None:
|
||||
selected_mac = discovery_info[MAC_ADDRESS]
|
||||
self.selected_device_info = self.discovered_devices[selected_mac]
|
||||
return await self.async_step_configure_device()
|
||||
|
||||
list_options = {
|
||||
mac: f"{device.get(HOSTNAME, mac)} ({device.get(IP_ADDRESS, DEVICE_NAME)})"
|
||||
for mac, device in self.discovered_devices.items()
|
||||
}
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="select_device",
|
||||
data_schema=vol.Schema({vol.Required(MAC_ADDRESS): vol.In(list_options)}),
|
||||
)
|
||||
|
||||
async def async_step_configure_device(
|
||||
self,
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> ConfigFlowResult:
|
||||
"""Configure the selected device."""
|
||||
self.errors = {}
|
||||
|
||||
if user_input is not None:
|
||||
config_data = {
|
||||
**user_input,
|
||||
CONF_HOST: self.selected_device_info[IP_ADDRESS],
|
||||
}
|
||||
validated_info = await self._validate_and_get_device_info(config_data)
|
||||
|
||||
if validated_info:
|
||||
return self.async_create_entry(
|
||||
title=validated_info["title"],
|
||||
data=validated_info["data"],
|
||||
)
|
||||
|
||||
device_name = self.selected_device_info.get(
|
||||
HOSTNAME, self.selected_device_info.get(IP_ADDRESS, DEVICE_NAME)
|
||||
)
|
||||
return self.async_show_form(
|
||||
step_id="configure_device",
|
||||
data_schema=STEP_DISCOVERY_DATA_SCHEMA,
|
||||
errors=self.errors,
|
||||
description_placeholders={"device_name": device_name},
|
||||
)
|
||||
|
||||
async def _async_run_discovery_with_progress(self) -> None:
|
||||
"""Run discovery with an embedded progress update loop."""
|
||||
progress_bar = self.hass.async_create_task(self._async_update_progress_bar())
|
||||
|
||||
known_mac_addresses = {
|
||||
entry.unique_id.lower()
|
||||
for entry in self.hass.config_entries.async_entries(DOMAIN)
|
||||
if entry.unique_id
|
||||
}
|
||||
|
||||
try:
|
||||
devices = await airos_discover_devices(DISCOVER_INTERVAL)
|
||||
except AirOSEndpointError:
|
||||
self.discovery_abort_reason = "discovery_detect_error"
|
||||
except AirOSListenerError:
|
||||
self.discovery_abort_reason = "discovery_listen_error"
|
||||
except Exception:
|
||||
self.discovery_abort_reason = "discovery_failed"
|
||||
_LOGGER.exception("An error occurred during discovery")
|
||||
else:
|
||||
self.discovered_devices = {
|
||||
mac_addr: info
|
||||
for mac_addr, info in devices.items()
|
||||
if mac_addr.lower() not in known_mac_addresses
|
||||
}
|
||||
_LOGGER.debug(
|
||||
"Discovery task finished. Found %s new devices",
|
||||
len(self.discovered_devices),
|
||||
)
|
||||
finally:
|
||||
progress_bar.cancel()
|
||||
|
||||
async def _async_update_progress_bar(self) -> None:
|
||||
"""Update progress bar every second."""
|
||||
try:
|
||||
for i in range(DISCOVER_INTERVAL):
|
||||
progress = (i + 1) / DISCOVER_INTERVAL
|
||||
self.async_update_progress(progress)
|
||||
await asyncio.sleep(1)
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
|
||||
async def async_step_discovery_no_devices(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Abort if discovery finds no (unconfigured) devices."""
|
||||
return self.async_abort(reason="no_devices_found")
|
||||
|
||||
async def async_step_discovery_listen_error(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Abort if discovery is unable to listen on the port."""
|
||||
return self.async_abort(reason="listen_error")
|
||||
|
||||
async def async_step_discovery_detect_error(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Abort if discovery receives incorrect broadcasts."""
|
||||
return self.async_abort(reason="detect_error")
|
||||
|
||||
async def async_step_discovery_failed(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Abort if discovery fails for other reasons."""
|
||||
return self.async_abort(reason="discovery_failed")
|
||||
|
||||
@@ -12,10 +12,3 @@ DEFAULT_VERIFY_SSL = False
|
||||
DEFAULT_SSL = True
|
||||
|
||||
SECTION_ADVANCED_SETTINGS = "advanced_settings"
|
||||
|
||||
# Discovery related
|
||||
DEFAULT_USERNAME = "ubnt"
|
||||
HOSTNAME = "hostname"
|
||||
IP_ADDRESS = "ip_address"
|
||||
MAC_ADDRESS = "mac_address"
|
||||
DEVICE_NAME = "airOS device"
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_polling",
|
||||
"quality_scale": "silver",
|
||||
"requirements": ["airos==0.6.4"]
|
||||
"requirements": ["airos==0.6.3"]
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
"config": {
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"detect_error": "Unable to process discovered devices data, check the documentation for supported devices",
|
||||
"discovery_failed": "Unable to start discovery, check logs for details",
|
||||
"listen_error": "Unable to start listening for devices",
|
||||
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]",
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
||||
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
|
||||
"unique_id_mismatch": "Re-authentication should be used for the same device not a new one"
|
||||
@@ -17,36 +13,37 @@
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
"flow_title": "Ubiquiti airOS device",
|
||||
"progress": {
|
||||
"connecting": "Connecting to the airOS device",
|
||||
"discovering": "Listening for any airOS devices for {seconds} seconds"
|
||||
},
|
||||
"step": {
|
||||
"configure_device": {
|
||||
"reauth_confirm": {
|
||||
"data": {
|
||||
"password": "[%key:common::config_flow::data::password%]",
|
||||
"username": "[%key:common::config_flow::data::username%]"
|
||||
"password": "[%key:common::config_flow::data::password%]"
|
||||
},
|
||||
"data_description": {
|
||||
"password": "[%key:component::airos::config::step::manual::data_description::password%]",
|
||||
"username": "[%key:component::airos::config::step::manual::data_description::username%]"
|
||||
"password": "[%key:component::airos::config::step::user::data_description::password%]"
|
||||
}
|
||||
},
|
||||
"reconfigure": {
|
||||
"data": {
|
||||
"password": "[%key:common::config_flow::data::password%]"
|
||||
},
|
||||
"data_description": {
|
||||
"password": "[%key:component::airos::config::step::user::data_description::password%]"
|
||||
},
|
||||
"description": "Enter the username and password for {device_name}",
|
||||
"sections": {
|
||||
"advanced_settings": {
|
||||
"data": {
|
||||
"ssl": "[%key:component::airos::config::step::manual::sections::advanced_settings::data::ssl%]",
|
||||
"ssl": "[%key:component::airos::config::step::user::sections::advanced_settings::data::ssl%]",
|
||||
"verify_ssl": "[%key:common::config_flow::data::verify_ssl%]"
|
||||
},
|
||||
"data_description": {
|
||||
"ssl": "[%key:component::airos::config::step::manual::sections::advanced_settings::data_description::ssl%]",
|
||||
"verify_ssl": "[%key:component::airos::config::step::manual::sections::advanced_settings::data_description::verify_ssl%]"
|
||||
"ssl": "[%key:component::airos::config::step::user::sections::advanced_settings::data_description::ssl%]",
|
||||
"verify_ssl": "[%key:component::airos::config::step::user::sections::advanced_settings::data_description::verify_ssl%]"
|
||||
},
|
||||
"name": "[%key:component::airos::config::step::manual::sections::advanced_settings::name%]"
|
||||
"name": "[%key:component::airos::config::step::user::sections::advanced_settings::name%]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"manual": {
|
||||
"user": {
|
||||
"data": {
|
||||
"host": "[%key:common::config_flow::data::host%]",
|
||||
"password": "[%key:common::config_flow::data::password%]",
|
||||
@@ -70,49 +67,6 @@
|
||||
"name": "Advanced settings"
|
||||
}
|
||||
}
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"data": {
|
||||
"password": "[%key:common::config_flow::data::password%]"
|
||||
},
|
||||
"data_description": {
|
||||
"password": "[%key:component::airos::config::step::manual::data_description::password%]"
|
||||
}
|
||||
},
|
||||
"reconfigure": {
|
||||
"data": {
|
||||
"password": "[%key:common::config_flow::data::password%]"
|
||||
},
|
||||
"data_description": {
|
||||
"password": "[%key:component::airos::config::step::manual::data_description::password%]"
|
||||
},
|
||||
"sections": {
|
||||
"advanced_settings": {
|
||||
"data": {
|
||||
"ssl": "[%key:component::airos::config::step::manual::sections::advanced_settings::data::ssl%]",
|
||||
"verify_ssl": "[%key:common::config_flow::data::verify_ssl%]"
|
||||
},
|
||||
"data_description": {
|
||||
"ssl": "[%key:component::airos::config::step::manual::sections::advanced_settings::data_description::ssl%]",
|
||||
"verify_ssl": "[%key:component::airos::config::step::manual::sections::advanced_settings::data_description::verify_ssl%]"
|
||||
},
|
||||
"name": "[%key:component::airos::config::step::manual::sections::advanced_settings::name%]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"select_device": {
|
||||
"data": {
|
||||
"mac_address": "Select the device to configure"
|
||||
},
|
||||
"data_description": {
|
||||
"mac_address": "Select the device MAC address"
|
||||
}
|
||||
},
|
||||
"user": {
|
||||
"menu_options": {
|
||||
"discovery": "Listen for airOS devices on the network",
|
||||
"manual": "Manually configure airOS device"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -203,9 +157,6 @@
|
||||
},
|
||||
"key_data_missing": {
|
||||
"message": "Key data not returned from device"
|
||||
},
|
||||
"reboot_failed": {
|
||||
"message": "The device did not accept the reboot request. Try again, or check your device web interface for errors."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
"name": "Go to preset"
|
||||
},
|
||||
"ptz_control": {
|
||||
"description": "Moves (pan/tilt) and/or zooms a PTZ camera.",
|
||||
"description": "Moves (pan/tilt) and/or zoom a PTZ camera.",
|
||||
"fields": {
|
||||
"entity_id": {
|
||||
"description": "[%key:component::amcrest::services::enable_recording::fields::entity_id::description%]",
|
||||
|
||||
@@ -38,6 +38,7 @@ def get_app_entity_description(
|
||||
translation_key="apps",
|
||||
name=name_slug,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
native_unit_of_measurement="active installations",
|
||||
value_fn=lambda data: data.apps.get(name_slug),
|
||||
)
|
||||
|
||||
@@ -51,6 +52,7 @@ def get_core_integration_entity_description(
|
||||
translation_key="core_integrations",
|
||||
name=name,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
native_unit_of_measurement="active installations",
|
||||
value_fn=lambda data: data.core_integrations.get(domain),
|
||||
)
|
||||
|
||||
@@ -64,6 +66,7 @@ def get_custom_integration_entity_description(
|
||||
translation_key="custom_integrations",
|
||||
translation_placeholders={"custom_integration_domain": domain},
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
native_unit_of_measurement="active installations",
|
||||
value_fn=lambda data: data.custom_integrations.get(domain),
|
||||
)
|
||||
|
||||
@@ -74,6 +77,7 @@ GENERAL_SENSORS = [
|
||||
translation_key="total_active_installations",
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
native_unit_of_measurement="active installations",
|
||||
value_fn=lambda data: data.active_installations,
|
||||
),
|
||||
AnalyticsSensorEntityDescription(
|
||||
@@ -81,6 +85,7 @@ GENERAL_SENSORS = [
|
||||
translation_key="total_reports_integrations",
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
native_unit_of_measurement="active installations",
|
||||
value_fn=lambda data: data.reports_integrations,
|
||||
),
|
||||
]
|
||||
|
||||
@@ -24,23 +24,14 @@
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"apps": {
|
||||
"unit_of_measurement": "active installations"
|
||||
},
|
||||
"core_integrations": {
|
||||
"unit_of_measurement": "[%key:component::analytics_insights::entity::sensor::apps::unit_of_measurement%]"
|
||||
},
|
||||
"custom_integrations": {
|
||||
"name": "{custom_integration_domain} (custom)",
|
||||
"unit_of_measurement": "[%key:component::analytics_insights::entity::sensor::apps::unit_of_measurement%]"
|
||||
"name": "{custom_integration_domain} (custom)"
|
||||
},
|
||||
"total_active_installations": {
|
||||
"name": "Total active installations",
|
||||
"unit_of_measurement": "[%key:component::analytics_insights::entity::sensor::apps::unit_of_measurement%]"
|
||||
"name": "Total active installations"
|
||||
},
|
||||
"total_reports_integrations": {
|
||||
"name": "Total reported integrations",
|
||||
"unit_of_measurement": "[%key:component::analytics_insights::entity::sensor::apps::unit_of_measurement%]"
|
||||
"name": "Total reported integrations"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -132,21 +132,11 @@ class ContentDetails:
|
||||
"""Native data for AssistantContent."""
|
||||
|
||||
citation_details: list[CitationDetails] = field(default_factory=list)
|
||||
thinking_signature: str | None = None
|
||||
redacted_thinking: str | None = None
|
||||
|
||||
def has_content(self) -> bool:
|
||||
"""Check if there is any text content."""
|
||||
"""Check if there is any content."""
|
||||
return any(detail.length > 0 for detail in self.citation_details)
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
"""Check if there is any thinking content or citations."""
|
||||
return (
|
||||
self.thinking_signature is not None
|
||||
or self.redacted_thinking is not None
|
||||
or self.has_citations()
|
||||
)
|
||||
|
||||
def has_citations(self) -> bool:
|
||||
"""Check if there are any citations."""
|
||||
return any(detail.citations for detail in self.citation_details)
|
||||
@@ -256,28 +246,29 @@ def _convert_content(
|
||||
content=[],
|
||||
)
|
||||
)
|
||||
elif isinstance(messages[-1]["content"], str):
|
||||
messages[-1]["content"] = [
|
||||
TextBlockParam(type="text", text=messages[-1]["content"]),
|
||||
]
|
||||
|
||||
if isinstance(content.native, ContentDetails):
|
||||
if content.native.thinking_signature:
|
||||
messages[-1]["content"].append( # type: ignore[union-attr]
|
||||
ThinkingBlockParam(
|
||||
type="thinking",
|
||||
thinking=content.thinking_content or "",
|
||||
signature=content.native.thinking_signature,
|
||||
)
|
||||
if isinstance(content.native, ThinkingBlock):
|
||||
messages[-1]["content"].append( # type: ignore[union-attr]
|
||||
ThinkingBlockParam(
|
||||
type="thinking",
|
||||
thinking=content.thinking_content or "",
|
||||
signature=content.native.signature,
|
||||
)
|
||||
if content.native.redacted_thinking:
|
||||
messages[-1]["content"].append( # type: ignore[union-attr]
|
||||
RedactedThinkingBlockParam(
|
||||
type="redacted_thinking",
|
||||
data=content.native.redacted_thinking,
|
||||
)
|
||||
)
|
||||
elif isinstance(content.native, RedactedThinkingBlock):
|
||||
redacted_thinking_block = RedactedThinkingBlockParam(
|
||||
type="redacted_thinking",
|
||||
data=content.native.data,
|
||||
)
|
||||
if isinstance(messages[-1]["content"], str):
|
||||
messages[-1]["content"] = [
|
||||
TextBlockParam(type="text", text=messages[-1]["content"]),
|
||||
redacted_thinking_block,
|
||||
]
|
||||
else:
|
||||
messages[-1]["content"].append( # type: ignore[attr-defined]
|
||||
redacted_thinking_block
|
||||
)
|
||||
|
||||
if content.content:
|
||||
current_index = 0
|
||||
for detail in (
|
||||
@@ -318,7 +309,6 @@ def _convert_content(
|
||||
text=content.content[current_index:],
|
||||
)
|
||||
)
|
||||
|
||||
if content.tool_calls:
|
||||
messages[-1]["content"].extend( # type: ignore[union-attr]
|
||||
[
|
||||
@@ -338,14 +328,6 @@ def _convert_content(
|
||||
for tool_call in content.tool_calls
|
||||
]
|
||||
)
|
||||
|
||||
if (
|
||||
isinstance(messages[-1]["content"], list)
|
||||
and len(messages[-1]["content"]) == 1
|
||||
and messages[-1]["content"][0]["type"] == "text"
|
||||
):
|
||||
# If there is only one text block, simplify the content to a string
|
||||
messages[-1]["content"] = messages[-1]["content"][0]["text"]
|
||||
else:
|
||||
# Note: We don't pass SystemContent here as its passed to the API as the prompt
|
||||
raise TypeError(f"Unexpected content type: {type(content)}")
|
||||
@@ -397,7 +379,8 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
content_details = ContentDetails()
|
||||
content_details.add_citation_detail()
|
||||
input_usage: Usage | None = None
|
||||
first_block: bool = True
|
||||
has_native = False
|
||||
first_block: bool
|
||||
|
||||
async for response in stream:
|
||||
LOGGER.debug("Received response: %s", response)
|
||||
@@ -418,12 +401,13 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
current_tool_args = ""
|
||||
if response.content_block.name == output_tool:
|
||||
if first_block or content_details.has_content():
|
||||
if content_details:
|
||||
if content_details.has_citations():
|
||||
content_details.delete_empty()
|
||||
yield {"native": content_details}
|
||||
content_details = ContentDetails()
|
||||
content_details.add_citation_detail()
|
||||
yield {"role": "assistant"}
|
||||
has_native = False
|
||||
first_block = False
|
||||
elif isinstance(response.content_block, TextBlock):
|
||||
if ( # Do not start a new assistant content just for citations, concatenate consecutive blocks with citations instead.
|
||||
@@ -434,11 +418,12 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
and content_details.has_content()
|
||||
)
|
||||
):
|
||||
if content_details:
|
||||
if content_details.has_citations():
|
||||
content_details.delete_empty()
|
||||
yield {"native": content_details}
|
||||
content_details = ContentDetails()
|
||||
yield {"role": "assistant"}
|
||||
has_native = False
|
||||
first_block = False
|
||||
content_details.add_citation_detail()
|
||||
if response.content_block.text:
|
||||
@@ -447,13 +432,14 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
)
|
||||
yield {"content": response.content_block.text}
|
||||
elif isinstance(response.content_block, ThinkingBlock):
|
||||
if first_block or content_details.thinking_signature:
|
||||
if content_details:
|
||||
if first_block or has_native:
|
||||
if content_details.has_citations():
|
||||
content_details.delete_empty()
|
||||
yield {"native": content_details}
|
||||
content_details = ContentDetails()
|
||||
content_details.add_citation_detail()
|
||||
yield {"role": "assistant"}
|
||||
has_native = False
|
||||
first_block = False
|
||||
elif isinstance(response.content_block, RedactedThinkingBlock):
|
||||
LOGGER.debug(
|
||||
@@ -461,15 +447,17 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
"encrypted for safety reasons. This doesn’t affect the quality of "
|
||||
"responses"
|
||||
)
|
||||
if first_block or content_details.redacted_thinking:
|
||||
if content_details:
|
||||
if has_native:
|
||||
if content_details.has_citations():
|
||||
content_details.delete_empty()
|
||||
yield {"native": content_details}
|
||||
content_details = ContentDetails()
|
||||
content_details.add_citation_detail()
|
||||
yield {"role": "assistant"}
|
||||
has_native = False
|
||||
first_block = False
|
||||
content_details.redacted_thinking = response.content_block.data
|
||||
yield {"native": response.content_block}
|
||||
has_native = True
|
||||
elif isinstance(response.content_block, ServerToolUseBlock):
|
||||
current_tool_block = ServerToolUseBlockParam(
|
||||
type="server_tool_use",
|
||||
@@ -479,7 +467,7 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
)
|
||||
current_tool_args = ""
|
||||
elif isinstance(response.content_block, WebSearchToolResultBlock):
|
||||
if content_details:
|
||||
if content_details.has_citations():
|
||||
content_details.delete_empty()
|
||||
yield {"native": content_details}
|
||||
content_details = ContentDetails()
|
||||
@@ -522,16 +510,19 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
else:
|
||||
current_tool_args += response.delta.partial_json
|
||||
elif isinstance(response.delta, TextDelta):
|
||||
if response.delta.text:
|
||||
content_details.citation_details[-1].length += len(
|
||||
response.delta.text
|
||||
)
|
||||
yield {"content": response.delta.text}
|
||||
content_details.citation_details[-1].length += len(response.delta.text)
|
||||
yield {"content": response.delta.text}
|
||||
elif isinstance(response.delta, ThinkingDelta):
|
||||
if response.delta.thinking:
|
||||
yield {"thinking_content": response.delta.thinking}
|
||||
yield {"thinking_content": response.delta.thinking}
|
||||
elif isinstance(response.delta, SignatureDelta):
|
||||
content_details.thinking_signature = response.delta.signature
|
||||
yield {
|
||||
"native": ThinkingBlock(
|
||||
type="thinking",
|
||||
thinking="",
|
||||
signature=response.delta.signature,
|
||||
)
|
||||
}
|
||||
has_native = True
|
||||
elif isinstance(response.delta, CitationsDelta):
|
||||
content_details.add_citation(response.delta.citation)
|
||||
elif isinstance(response, RawContentBlockStopEvent):
|
||||
@@ -558,7 +549,7 @@ async def _transform_stream( # noqa: C901 - This is complex, but better to have
|
||||
if response.delta.stop_reason == "refusal":
|
||||
raise HomeAssistantError("Potential policy violation detected")
|
||||
elif isinstance(response, RawMessageStopEvent):
|
||||
if content_details:
|
||||
if content_details.has_citations():
|
||||
content_details.delete_empty()
|
||||
yield {"native": content_details}
|
||||
content_details = ContentDetails()
|
||||
|
||||
@@ -10,7 +10,15 @@ rules:
|
||||
Integration does not poll.
|
||||
brands: done
|
||||
common-modules: done
|
||||
config-flow-test-coverage: done
|
||||
config-flow-test-coverage:
|
||||
status: todo
|
||||
comment: |
|
||||
* Remove integration setup from the config flow init test
|
||||
* Make `mock_setup_entry` a separate fixture
|
||||
* Use the mock_config_entry fixture in `test_duplicate_entry`
|
||||
* `test_duplicate_entry`: Patch `homeassistant.components.anthropic.config_flow.anthropic.resources.models.AsyncModels.list`
|
||||
* Fix docstring and name for `test_form_invalid_auth` (does not only test auth)
|
||||
* In `test_form_invalid_auth`, make sure the test run until CREATE_ENTRY to test that the flow is able to recover
|
||||
config-flow: done
|
||||
dependency-transparency: done
|
||||
docs-actions:
|
||||
|
||||
@@ -64,6 +64,6 @@ class AtagSensor(AtagEntity, SensorEntity):
|
||||
return self.coordinator.atag.report[self._id].state
|
||||
|
||||
@property
|
||||
def icon(self) -> str:
|
||||
def icon(self):
|
||||
"""Return icon."""
|
||||
return self.coordinator.atag.report[self._id].icon
|
||||
|
||||
@@ -33,5 +33,3 @@ EXCLUDE_DATABASE_FROM_BACKUP = [
|
||||
"home-assistant_v2.db",
|
||||
"home-assistant_v2.db-wal",
|
||||
]
|
||||
|
||||
SECURETAR_CREATE_VERSION = 2
|
||||
|
||||
@@ -20,9 +20,13 @@ import time
|
||||
from typing import IO, TYPE_CHECKING, Any, Protocol, TypedDict, cast
|
||||
|
||||
import aiohttp
|
||||
from securetar import SecureTarArchive, atomic_contents_add
|
||||
from securetar import SecureTarFile, atomic_contents_add
|
||||
|
||||
from homeassistant.backup_restore import RESTORE_BACKUP_FILE, RESTORE_BACKUP_RESULT_FILE
|
||||
from homeassistant.backup_restore import (
|
||||
RESTORE_BACKUP_FILE,
|
||||
RESTORE_BACKUP_RESULT_FILE,
|
||||
password_to_key,
|
||||
)
|
||||
from homeassistant.const import __version__ as HAVERSION
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import (
|
||||
@@ -56,7 +60,6 @@ from .const import (
|
||||
EXCLUDE_DATABASE_FROM_BACKUP,
|
||||
EXCLUDE_FROM_BACKUP,
|
||||
LOGGER,
|
||||
SECURETAR_CREATE_VERSION,
|
||||
)
|
||||
from .models import (
|
||||
AddonInfo,
|
||||
@@ -1855,22 +1858,20 @@ class CoreBackupReaderWriter(BackupReaderWriter):
|
||||
|
||||
return False
|
||||
|
||||
with SecureTarArchive(
|
||||
tar_file_path,
|
||||
"w",
|
||||
bufsize=BUF_SIZE,
|
||||
create_version=SECURETAR_CREATE_VERSION,
|
||||
password=password,
|
||||
) as outer_secure_tarfile:
|
||||
outer_secure_tarfile = SecureTarFile(
|
||||
tar_file_path, "w", gzip=False, bufsize=BUF_SIZE
|
||||
)
|
||||
with outer_secure_tarfile as outer_secure_tarfile_tarfile:
|
||||
raw_bytes = json_bytes(backup_data)
|
||||
fileobj = io.BytesIO(raw_bytes)
|
||||
tar_info = tarfile.TarInfo(name="./backup.json")
|
||||
tar_info.size = len(raw_bytes)
|
||||
tar_info.mtime = int(time.time())
|
||||
outer_secure_tarfile.tar.addfile(tar_info, fileobj=fileobj)
|
||||
with outer_secure_tarfile.create_tar(
|
||||
outer_secure_tarfile_tarfile.addfile(tar_info, fileobj=fileobj)
|
||||
with outer_secure_tarfile.create_inner_tar(
|
||||
"./homeassistant.tar.gz",
|
||||
gzip=True,
|
||||
key=password_to_key(password) if password is not None else None,
|
||||
) as core_tar:
|
||||
atomic_contents_add(
|
||||
tar_file=core_tar,
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"integration_type": "service",
|
||||
"iot_class": "calculated",
|
||||
"quality_scale": "internal",
|
||||
"requirements": ["cronsim==2.7", "securetar==2026.2.0"],
|
||||
"requirements": ["cronsim==2.7", "securetar==2025.2.1"],
|
||||
"single_config_entry": true
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import copy
|
||||
from dataclasses import dataclass, replace
|
||||
from io import BytesIO
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path, PurePath
|
||||
from queue import SimpleQueue
|
||||
import tarfile
|
||||
@@ -15,14 +16,9 @@ import threading
|
||||
from typing import IO, Any, cast
|
||||
|
||||
import aiohttp
|
||||
from securetar import (
|
||||
SecureTarArchive,
|
||||
SecureTarError,
|
||||
SecureTarFile,
|
||||
SecureTarReadError,
|
||||
SecureTarRootKeyContext,
|
||||
)
|
||||
from securetar import SecureTarError, SecureTarFile, SecureTarReadError
|
||||
|
||||
from homeassistant.backup_restore import password_to_key
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -33,7 +29,7 @@ from homeassistant.util.async_iterator import (
|
||||
)
|
||||
from homeassistant.util.json import JsonObjectType, json_loads_object
|
||||
|
||||
from .const import BUF_SIZE, LOGGER, SECURETAR_CREATE_VERSION
|
||||
from .const import BUF_SIZE, LOGGER
|
||||
from .models import AddonInfo, AgentBackup, Folder
|
||||
|
||||
|
||||
@@ -136,23 +132,17 @@ def suggested_filename(backup: AgentBackup) -> str:
|
||||
|
||||
|
||||
def validate_password(path: Path, password: str | None) -> bool:
|
||||
"""Validate the password.
|
||||
|
||||
This assumes every inner tar is encrypted with the same secure tar version and
|
||||
same password.
|
||||
"""
|
||||
with SecureTarArchive(
|
||||
path, "r", bufsize=BUF_SIZE, password=password
|
||||
) as backup_file:
|
||||
"""Validate the password."""
|
||||
with tarfile.open(path, "r:", bufsize=BUF_SIZE) as backup_file:
|
||||
compressed = False
|
||||
ha_tar_name = "homeassistant.tar"
|
||||
try:
|
||||
ha_tar = backup_file.tar.extractfile(ha_tar_name)
|
||||
ha_tar = backup_file.extractfile(ha_tar_name)
|
||||
except KeyError:
|
||||
compressed = True
|
||||
ha_tar_name = "homeassistant.tar.gz"
|
||||
try:
|
||||
ha_tar = backup_file.tar.extractfile(ha_tar_name)
|
||||
ha_tar = backup_file.extractfile(ha_tar_name)
|
||||
except KeyError:
|
||||
LOGGER.error("No homeassistant.tar or homeassistant.tar.gz found")
|
||||
return False
|
||||
@@ -160,12 +150,13 @@ def validate_password(path: Path, password: str | None) -> bool:
|
||||
with SecureTarFile(
|
||||
path, # Not used
|
||||
gzip=compressed,
|
||||
password=password,
|
||||
key=password_to_key(password) if password is not None else None,
|
||||
mode="r",
|
||||
fileobj=ha_tar,
|
||||
):
|
||||
# If we can read the tar file, the password is correct
|
||||
return True
|
||||
except tarfile.ReadError, SecureTarReadError:
|
||||
except tarfile.ReadError:
|
||||
LOGGER.debug("Invalid password")
|
||||
return False
|
||||
except Exception: # noqa: BLE001
|
||||
@@ -177,23 +168,22 @@ def validate_password_stream(
|
||||
input_stream: IO[bytes],
|
||||
password: str | None,
|
||||
) -> None:
|
||||
"""Validate the password.
|
||||
|
||||
This assumes every inner tar is encrypted with the same secure tar version and
|
||||
same password.
|
||||
"""
|
||||
with SecureTarArchive(
|
||||
fileobj=input_stream,
|
||||
mode="r",
|
||||
bufsize=BUF_SIZE,
|
||||
streaming=True,
|
||||
password=password,
|
||||
) as input_archive:
|
||||
for obj in input_archive.tar:
|
||||
"""Decrypt a backup."""
|
||||
with (
|
||||
tarfile.open(fileobj=input_stream, mode="r|", bufsize=BUF_SIZE) as input_tar,
|
||||
):
|
||||
for obj in input_tar:
|
||||
if not obj.name.endswith((".tar", ".tgz", ".tar.gz")):
|
||||
continue
|
||||
with input_archive.extract_tar(obj) as decrypted:
|
||||
if decrypted.plaintext_size is None:
|
||||
istf = SecureTarFile(
|
||||
None, # Not used
|
||||
gzip=False,
|
||||
key=password_to_key(password) if password is not None else None,
|
||||
mode="r",
|
||||
fileobj=input_tar.extractfile(obj),
|
||||
)
|
||||
with istf.decrypt(obj) as decrypted:
|
||||
if istf.securetar_header.plaintext_size is None:
|
||||
raise UnsupportedSecureTarVersion
|
||||
try:
|
||||
decrypted.read(1) # Read a single byte to trigger the decryption
|
||||
@@ -222,25 +212,21 @@ def decrypt_backup(
|
||||
password: str | None,
|
||||
on_done: Callable[[Exception | None], None],
|
||||
minimum_size: int,
|
||||
key_context: SecureTarRootKeyContext,
|
||||
nonces: NonceGenerator,
|
||||
) -> None:
|
||||
"""Decrypt a backup."""
|
||||
error: Exception | None = None
|
||||
try:
|
||||
try:
|
||||
with (
|
||||
SecureTarArchive(
|
||||
fileobj=input_stream,
|
||||
mode="r",
|
||||
bufsize=BUF_SIZE,
|
||||
streaming=True,
|
||||
password=password,
|
||||
) as input_archive,
|
||||
tarfile.open(
|
||||
fileobj=input_stream, mode="r|", bufsize=BUF_SIZE
|
||||
) as input_tar,
|
||||
tarfile.open(
|
||||
fileobj=output_stream, mode="w|", bufsize=BUF_SIZE
|
||||
) as output_tar,
|
||||
):
|
||||
_decrypt_backup(backup, input_archive, output_tar)
|
||||
_decrypt_backup(backup, input_tar, output_tar, password)
|
||||
except (DecryptError, SecureTarError, tarfile.TarError) as err:
|
||||
LOGGER.warning("Error decrypting backup: %s", err)
|
||||
error = err
|
||||
@@ -262,18 +248,19 @@ def decrypt_backup(
|
||||
|
||||
def _decrypt_backup(
|
||||
backup: AgentBackup,
|
||||
input_archive: SecureTarArchive,
|
||||
input_tar: tarfile.TarFile,
|
||||
output_tar: tarfile.TarFile,
|
||||
password: str | None,
|
||||
) -> None:
|
||||
"""Decrypt a backup."""
|
||||
expected_archives = _get_expected_archives(backup)
|
||||
for obj in input_archive.tar:
|
||||
for obj in input_tar:
|
||||
# We compare with PurePath to avoid issues with different path separators,
|
||||
# for example when backup.json is added as "./backup.json"
|
||||
object_path = PurePath(obj.name)
|
||||
if object_path == PurePath("backup.json"):
|
||||
# Rewrite the backup.json file to indicate that the backup is decrypted
|
||||
if not (reader := input_archive.tar.extractfile(obj)):
|
||||
if not (reader := input_tar.extractfile(obj)):
|
||||
raise DecryptError
|
||||
metadata = json_loads_object(reader.read())
|
||||
metadata["protected"] = False
|
||||
@@ -285,15 +272,21 @@ def _decrypt_backup(
|
||||
prefix, _, suffix = object_path.name.partition(".")
|
||||
if suffix not in ("tar", "tgz", "tar.gz"):
|
||||
LOGGER.debug("Unknown file %s will not be decrypted", obj.name)
|
||||
output_tar.addfile(obj, input_archive.tar.extractfile(obj))
|
||||
output_tar.addfile(obj, input_tar.extractfile(obj))
|
||||
continue
|
||||
if prefix not in expected_archives:
|
||||
LOGGER.debug("Unknown inner tar file %s will not be decrypted", obj.name)
|
||||
output_tar.addfile(obj, input_archive.tar.extractfile(obj))
|
||||
output_tar.addfile(obj, input_tar.extractfile(obj))
|
||||
continue
|
||||
with input_archive.extract_tar(obj) as decrypted:
|
||||
# Guard against SecureTar v1 which doesn't store plaintext size
|
||||
if (plaintext_size := decrypted.plaintext_size) is None:
|
||||
istf = SecureTarFile(
|
||||
None, # Not used
|
||||
gzip=False,
|
||||
key=password_to_key(password) if password is not None else None,
|
||||
mode="r",
|
||||
fileobj=input_tar.extractfile(obj),
|
||||
)
|
||||
with istf.decrypt(obj) as decrypted:
|
||||
if (plaintext_size := istf.securetar_header.plaintext_size) is None:
|
||||
raise UnsupportedSecureTarVersion
|
||||
decrypted_obj = copy.deepcopy(obj)
|
||||
decrypted_obj.size = plaintext_size
|
||||
@@ -307,7 +300,7 @@ def encrypt_backup(
|
||||
password: str | None,
|
||||
on_done: Callable[[Exception | None], None],
|
||||
minimum_size: int,
|
||||
key_context: SecureTarRootKeyContext,
|
||||
nonces: NonceGenerator,
|
||||
) -> None:
|
||||
"""Encrypt a backup."""
|
||||
error: Exception | None = None
|
||||
@@ -317,16 +310,11 @@ def encrypt_backup(
|
||||
tarfile.open(
|
||||
fileobj=input_stream, mode="r|", bufsize=BUF_SIZE
|
||||
) as input_tar,
|
||||
SecureTarArchive(
|
||||
fileobj=output_stream,
|
||||
mode="w",
|
||||
bufsize=BUF_SIZE,
|
||||
streaming=True,
|
||||
root_key_context=key_context,
|
||||
create_version=SECURETAR_CREATE_VERSION,
|
||||
) as output_archive,
|
||||
tarfile.open(
|
||||
fileobj=output_stream, mode="w|", bufsize=BUF_SIZE
|
||||
) as output_tar,
|
||||
):
|
||||
_encrypt_backup(backup, input_tar, output_archive)
|
||||
_encrypt_backup(backup, input_tar, output_tar, password, nonces)
|
||||
except (EncryptError, SecureTarError, tarfile.TarError) as err:
|
||||
LOGGER.warning("Error encrypting backup: %s", err)
|
||||
error = err
|
||||
@@ -349,7 +337,9 @@ def encrypt_backup(
|
||||
def _encrypt_backup(
|
||||
backup: AgentBackup,
|
||||
input_tar: tarfile.TarFile,
|
||||
output_archive: SecureTarArchive,
|
||||
output_tar: tarfile.TarFile,
|
||||
password: str | None,
|
||||
nonces: NonceGenerator,
|
||||
) -> None:
|
||||
"""Encrypt a backup."""
|
||||
inner_tar_idx = 0
|
||||
@@ -367,20 +357,29 @@ def _encrypt_backup(
|
||||
updated_metadata_b = json.dumps(metadata).encode()
|
||||
metadata_obj = copy.deepcopy(obj)
|
||||
metadata_obj.size = len(updated_metadata_b)
|
||||
output_archive.tar.addfile(metadata_obj, BytesIO(updated_metadata_b))
|
||||
output_tar.addfile(metadata_obj, BytesIO(updated_metadata_b))
|
||||
continue
|
||||
prefix, _, suffix = object_path.name.partition(".")
|
||||
if suffix not in ("tar", "tgz", "tar.gz"):
|
||||
LOGGER.debug("Unknown file %s will not be encrypted", obj.name)
|
||||
output_archive.tar.addfile(obj, input_tar.extractfile(obj))
|
||||
output_tar.addfile(obj, input_tar.extractfile(obj))
|
||||
continue
|
||||
if prefix not in expected_archives:
|
||||
LOGGER.debug("Unknown inner tar file %s will not be encrypted", obj.name)
|
||||
continue
|
||||
output_archive.import_tar(
|
||||
input_tar.extractfile(obj), obj, derived_key_id=inner_tar_idx
|
||||
istf = SecureTarFile(
|
||||
None, # Not used
|
||||
gzip=False,
|
||||
key=password_to_key(password) if password is not None else None,
|
||||
mode="r",
|
||||
fileobj=input_tar.extractfile(obj),
|
||||
nonce=nonces.get(inner_tar_idx),
|
||||
)
|
||||
inner_tar_idx += 1
|
||||
with istf.encrypt(obj) as encrypted:
|
||||
encrypted_obj = copy.deepcopy(obj)
|
||||
encrypted_obj.size = encrypted.encrypted_size
|
||||
output_tar.addfile(encrypted_obj, encrypted)
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
@@ -392,6 +391,21 @@ class _CipherWorkerStatus:
|
||||
writer: AsyncIteratorWriter
|
||||
|
||||
|
||||
class NonceGenerator:
|
||||
"""Generate nonces for encryption."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize the generator."""
|
||||
self._nonces: dict[int, bytes] = {}
|
||||
|
||||
def get(self, index: int) -> bytes:
|
||||
"""Get a nonce for the given index."""
|
||||
if index not in self._nonces:
|
||||
# Generate a new nonce for the given index
|
||||
self._nonces[index] = os.urandom(16)
|
||||
return self._nonces[index]
|
||||
|
||||
|
||||
class _CipherBackupStreamer:
|
||||
"""Encrypt or decrypt a backup."""
|
||||
|
||||
@@ -403,7 +417,7 @@ class _CipherBackupStreamer:
|
||||
str | None,
|
||||
Callable[[Exception | None], None],
|
||||
int,
|
||||
SecureTarRootKeyContext,
|
||||
NonceGenerator,
|
||||
],
|
||||
None,
|
||||
]
|
||||
@@ -421,7 +435,7 @@ class _CipherBackupStreamer:
|
||||
self._hass = hass
|
||||
self._open_stream = open_stream
|
||||
self._password = password
|
||||
self._key_context = SecureTarRootKeyContext(password)
|
||||
self._nonces = NonceGenerator()
|
||||
|
||||
def size(self) -> int:
|
||||
"""Return the maximum size of the decrypted or encrypted backup."""
|
||||
@@ -452,7 +466,7 @@ class _CipherBackupStreamer:
|
||||
self._password,
|
||||
on_done,
|
||||
self.size(),
|
||||
self._key_context,
|
||||
self._nonces,
|
||||
],
|
||||
)
|
||||
worker_status = _CipherWorkerStatus(
|
||||
|
||||
@@ -74,7 +74,7 @@ class BleBoxLightEntity(BleBoxEntity[blebox_uniapi.light.Light], LightEntity):
|
||||
return self._feature.is_on
|
||||
|
||||
@property
|
||||
def brightness(self) -> int | None:
|
||||
def brightness(self):
|
||||
"""Return the name."""
|
||||
return self._feature.brightness
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
|
||||
from . import BSBLanConfigEntry, BSBLanData
|
||||
from .const import ATTR_TARGET_TEMPERATURE, DOMAIN
|
||||
@@ -112,7 +113,7 @@ class BSBLANClimate(BSBLanEntity, ClimateEntity):
|
||||
return target_temp.value
|
||||
|
||||
@property
|
||||
def _hvac_mode_value(self) -> int | None:
|
||||
def _hvac_mode_value(self) -> int | str | None:
|
||||
"""Return the raw hvac_mode value from the coordinator."""
|
||||
if (hvac_mode := self.coordinator.data.state.hvac_mode) is None:
|
||||
return None
|
||||
@@ -123,14 +124,16 @@ class BSBLANClimate(BSBLanEntity, ClimateEntity):
|
||||
"""Return hvac operation ie. heat, cool mode."""
|
||||
if (hvac_mode_value := self._hvac_mode_value) is None:
|
||||
return None
|
||||
return BSBLAN_TO_HA_HVAC_MODE.get(hvac_mode_value)
|
||||
# BSB-Lan returns integer values: 0=off, 1=auto, 2=eco, 3=heat
|
||||
if isinstance(hvac_mode_value, int):
|
||||
return BSBLAN_TO_HA_HVAC_MODE.get(hvac_mode_value)
|
||||
return try_parse_enum(HVACMode, hvac_mode_value)
|
||||
|
||||
@property
|
||||
def hvac_action(self) -> HVACAction | None:
|
||||
"""Return the current running hvac action."""
|
||||
if (
|
||||
action := self.coordinator.data.state.hvac_action
|
||||
) is None or action.value is None:
|
||||
action = self.coordinator.data.state.hvac_action
|
||||
if not action or not isinstance(action.value, int):
|
||||
return None
|
||||
category = get_hvac_action_category(action.value)
|
||||
return HVACAction(category.name.lower())
|
||||
|
||||
@@ -17,24 +17,24 @@ async def async_get_config_entry_diagnostics(
|
||||
|
||||
# Build diagnostic data from both coordinators
|
||||
diagnostics = {
|
||||
"info": data.info.model_dump(),
|
||||
"device": data.device.model_dump(),
|
||||
"info": data.info.to_dict(),
|
||||
"device": data.device.to_dict(),
|
||||
"fast_coordinator_data": {
|
||||
"state": data.fast_coordinator.data.state.model_dump(),
|
||||
"sensor": data.fast_coordinator.data.sensor.model_dump(),
|
||||
"dhw": data.fast_coordinator.data.dhw.model_dump(),
|
||||
"state": data.fast_coordinator.data.state.to_dict(),
|
||||
"sensor": data.fast_coordinator.data.sensor.to_dict(),
|
||||
"dhw": data.fast_coordinator.data.dhw.to_dict(),
|
||||
},
|
||||
"static": data.static.model_dump(),
|
||||
"static": data.static.to_dict(),
|
||||
}
|
||||
|
||||
# Add DHW config and schedule from slow coordinator if available
|
||||
if data.slow_coordinator.data:
|
||||
slow_data = {}
|
||||
if data.slow_coordinator.data.dhw_config:
|
||||
slow_data["dhw_config"] = data.slow_coordinator.data.dhw_config.model_dump()
|
||||
slow_data["dhw_config"] = data.slow_coordinator.data.dhw_config.to_dict()
|
||||
if data.slow_coordinator.data.dhw_schedule:
|
||||
slow_data["dhw_schedule"] = (
|
||||
data.slow_coordinator.data.dhw_schedule.model_dump()
|
||||
data.slow_coordinator.data.dhw_schedule.to_dict()
|
||||
)
|
||||
if slow_data:
|
||||
diagnostics["slow_coordinator_data"] = slow_data
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["bsblan"],
|
||||
"requirements": ["python-bsblan==5.0.1"],
|
||||
"requirements": ["python-bsblan==4.2.1"],
|
||||
"zeroconf": [
|
||||
{
|
||||
"name": "bsb-lan*",
|
||||
|
||||
@@ -110,11 +110,12 @@ class BSBLANWaterHeater(BSBLanDualCoordinatorEntity, WaterHeaterEntity):
|
||||
@property
|
||||
def current_operation(self) -> str | None:
|
||||
"""Return current operation."""
|
||||
if (
|
||||
operating_mode := self.coordinator.data.dhw.operating_mode
|
||||
) is None or operating_mode.value is None:
|
||||
if (operating_mode := self.coordinator.data.dhw.operating_mode) is None:
|
||||
return None
|
||||
return BSBLAN_TO_HA_OPERATION_MODE.get(operating_mode.value)
|
||||
# The operating_mode.value is an integer (0=Off, 1=On, 2=Eco)
|
||||
if isinstance(operating_mode.value, int):
|
||||
return BSBLAN_TO_HA_OPERATION_MODE.get(operating_mode.value)
|
||||
return None
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> float | None:
|
||||
|
||||
@@ -31,7 +31,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def _convert_image_for_editing(data: bytes) -> tuple[bytes, str]:
|
||||
"""Ensure the image data is in a format accepted by OpenAI image edits."""
|
||||
img: Image.Image
|
||||
stream = io.BytesIO(data)
|
||||
with Image.open(stream) as img:
|
||||
mode = img.mode
|
||||
|
||||
@@ -199,7 +199,7 @@ class Control4Light(Control4Entity, LightEntity):
|
||||
return self.coordinator.data[self._idx][CONTROL4_NON_DIMMER_VAR] > 0
|
||||
|
||||
@property
|
||||
def brightness(self) -> int | None:
|
||||
def brightness(self):
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
if self._is_dimmer:
|
||||
for var in CONTROL4_DIMMER_VARS:
|
||||
|
||||
@@ -132,7 +132,7 @@ class DecoraWifiLight(LightEntity):
|
||||
return self._switch.serial
|
||||
|
||||
@property
|
||||
def brightness(self) -> int:
|
||||
def brightness(self):
|
||||
"""Return the brightness of the dimmer switch."""
|
||||
return int(self._switch.brightness * 255 / 100)
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["pydoods"],
|
||||
"quality_scale": "legacy",
|
||||
"requirements": ["pydoods==1.0.2", "Pillow==12.1.1"]
|
||||
"requirements": ["pydoods==1.0.2", "Pillow==12.0.0"]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"domain": "dwd_weather_warnings",
|
||||
"name": "Deutscher Wetterdienst (DWD) Weather Warnings",
|
||||
"codeowners": ["@runningman84", "@stephan192"],
|
||||
"codeowners": ["@runningman84", "@stephan192", "@andarotajo"],
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/dwd_weather_warnings",
|
||||
"integration_type": "service",
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"integration_type": "hub",
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["sleekxmppfs", "sucks", "deebot_client"],
|
||||
"requirements": ["py-sucks==0.9.11", "deebot-client==18.0.0"]
|
||||
"requirements": ["py-sucks==0.9.11", "deebot-client==17.1.0"]
|
||||
}
|
||||
|
||||
@@ -338,11 +338,11 @@ class EcovacsVacuum(
|
||||
translation_placeholders={"name": name},
|
||||
)
|
||||
|
||||
if command == "spot_area":
|
||||
if command in "spot_area":
|
||||
await self._device.execute_command(
|
||||
self._capability.clean.action.area(
|
||||
CleanMode.SPOT_AREA,
|
||||
params["rooms"],
|
||||
str(params["rooms"]),
|
||||
params.get("cleanings", 1),
|
||||
)
|
||||
)
|
||||
@@ -350,7 +350,7 @@ class EcovacsVacuum(
|
||||
await self._device.execute_command(
|
||||
self._capability.clean.action.area(
|
||||
CleanMode.CUSTOM_AREA,
|
||||
params["coordinates"],
|
||||
str(params["coordinates"]),
|
||||
params.get("cleanings", 1),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -13,12 +13,7 @@ from homeassistant.components.sensor import (
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.const import UnitOfElectricPotential, UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
@@ -64,15 +59,6 @@ SENSORS: tuple[EgaugeSensorEntityDescription, ...] = (
|
||||
available_fn=lambda data, register: register in data.measurements,
|
||||
supported_fn=lambda register_info: register_info.type == RegisterType.VOLTAGE,
|
||||
),
|
||||
EgaugeSensorEntityDescription(
|
||||
key="current",
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
native_value_fn=lambda data, register: data.measurements[register],
|
||||
available_fn=lambda data, register: register in data.measurements,
|
||||
supported_fn=lambda register_info: register_info.type == RegisterType.CURRENT,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"codeowners": [],
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/enocean",
|
||||
"integration_type": "hub",
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["enocean"],
|
||||
"requirements": ["enocean==0.50"],
|
||||
|
||||
@@ -75,7 +75,7 @@ class EufyHomeLight(LightEntity):
|
||||
self._attr_is_on = self._bulb.power
|
||||
|
||||
@property
|
||||
def brightness(self) -> int:
|
||||
def brightness(self):
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
return int(self._brightness * 255 / 100)
|
||||
|
||||
@@ -88,7 +88,7 @@ class EufyHomeLight(LightEntity):
|
||||
)
|
||||
|
||||
@property
|
||||
def hs_color(self) -> tuple[float, float] | None:
|
||||
def hs_color(self):
|
||||
"""Return the color of this light."""
|
||||
return self._hs
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class FitbitApi(ABC):
|
||||
configuration = Configuration()
|
||||
configuration.pool_manager = async_get_clientsession(self._hass)
|
||||
configuration.access_token = token[CONF_ACCESS_TOKEN]
|
||||
return await self._hass.async_add_executor_job(ApiClient, configuration)
|
||||
return ApiClient(configuration)
|
||||
|
||||
async def async_get_user_profile(self) -> FitbitProfile:
|
||||
"""Return the user profile from the API."""
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/forecast_solar",
|
||||
"integration_type": "service",
|
||||
"iot_class": "cloud_polling",
|
||||
"requirements": ["forecast-solar==5.0.0"]
|
||||
"requirements": ["forecast-solar==4.2.0"]
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ class FritzboxDataUpdateCoordinator(DataUpdateCoordinator[FritzboxCoordinatorDat
|
||||
host=self.config_entry.data[CONF_HOST],
|
||||
user=self.config_entry.data[CONF_USERNAME],
|
||||
password=self.config_entry.data[CONF_PASSWORD],
|
||||
timeout=20,
|
||||
)
|
||||
|
||||
try:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"integration_type": "hub",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["pyfritzhome"],
|
||||
"requirements": ["pyfritzhome==0.6.20"],
|
||||
"requirements": ["pyfritzhome==0.6.19"],
|
||||
"ssdp": [
|
||||
{
|
||||
"st": "urn:schemas-upnp-org:device:fritzbox:1"
|
||||
|
||||
@@ -18,7 +18,7 @@ from yarl import URL
|
||||
|
||||
from homeassistant.components import onboarding, websocket_api
|
||||
from homeassistant.components.http import KEY_HASS, HomeAssistantView, StaticPathConfig
|
||||
from homeassistant.components.websocket_api import ERR_NOT_FOUND, ActiveConnection
|
||||
from homeassistant.components.websocket_api import ActiveConnection
|
||||
from homeassistant.config import async_hass_config_yaml
|
||||
from homeassistant.const import (
|
||||
CONF_MODE,
|
||||
@@ -78,16 +78,6 @@ THEMES_STORAGE_VERSION = 1
|
||||
THEMES_SAVE_DELAY = 60
|
||||
DATA_THEMES_STORE: HassKey[Store] = HassKey("frontend_themes_store")
|
||||
DATA_THEMES: HassKey[dict[str, Any]] = HassKey("frontend_themes")
|
||||
|
||||
PANELS_STORAGE_KEY = f"{DOMAIN}_panels"
|
||||
PANELS_STORAGE_VERSION = 1
|
||||
PANELS_SAVE_DELAY = 10
|
||||
DATA_PANELS_STORE: HassKey[Store[dict[str, dict[str, Any]]]] = HassKey(
|
||||
"frontend_panels_store"
|
||||
)
|
||||
DATA_PANELS_CONFIG: HassKey[dict[str, dict[str, Any]]] = HassKey(
|
||||
"frontend_panels_config"
|
||||
)
|
||||
DATA_DEFAULT_THEME = "frontend_default_theme"
|
||||
DATA_DEFAULT_DARK_THEME = "frontend_default_dark_theme"
|
||||
DEFAULT_THEME = "default"
|
||||
@@ -322,11 +312,9 @@ class Panel:
|
||||
self.sidebar_default_visible = sidebar_default_visible
|
||||
|
||||
@callback
|
||||
def to_response(
|
||||
self, config_override: dict[str, Any] | None = None
|
||||
) -> PanelResponse:
|
||||
def to_response(self) -> PanelResponse:
|
||||
"""Panel as dictionary."""
|
||||
response: PanelResponse = {
|
||||
return {
|
||||
"component_name": self.component_name,
|
||||
"icon": self.sidebar_icon,
|
||||
"title": self.sidebar_title,
|
||||
@@ -336,18 +324,6 @@ class Panel:
|
||||
"require_admin": self.require_admin,
|
||||
"config_panel_domain": self.config_panel_domain,
|
||||
}
|
||||
if config_override:
|
||||
if "require_admin" in config_override:
|
||||
response["require_admin"] = config_override["require_admin"]
|
||||
if config_override.get("show_in_sidebar") is False:
|
||||
response["title"] = None
|
||||
response["icon"] = None
|
||||
else:
|
||||
if "icon" in config_override:
|
||||
response["icon"] = config_override["icon"]
|
||||
if "title" in config_override:
|
||||
response["title"] = config_override["title"]
|
||||
return response
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -439,24 +415,12 @@ def _frontend_root(dev_repo_path: str | None) -> pathlib.Path:
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the serving of the frontend."""
|
||||
await async_setup_frontend_storage(hass)
|
||||
|
||||
panels_store = hass.data[DATA_PANELS_STORE] = Store[dict[str, dict[str, Any]]](
|
||||
hass, PANELS_STORAGE_VERSION, PANELS_STORAGE_KEY
|
||||
)
|
||||
loaded: Any = await panels_store.async_load()
|
||||
if not isinstance(loaded, dict):
|
||||
if loaded is not None:
|
||||
_LOGGER.warning("Ignoring invalid panel storage data")
|
||||
loaded = {}
|
||||
hass.data[DATA_PANELS_CONFIG] = loaded
|
||||
|
||||
websocket_api.async_register_command(hass, websocket_get_icons)
|
||||
websocket_api.async_register_command(hass, websocket_get_panels)
|
||||
websocket_api.async_register_command(hass, websocket_get_themes)
|
||||
websocket_api.async_register_command(hass, websocket_get_translations)
|
||||
websocket_api.async_register_command(hass, websocket_get_version)
|
||||
websocket_api.async_register_command(hass, websocket_subscribe_extra_js)
|
||||
websocket_api.async_register_command(hass, websocket_update_panel)
|
||||
hass.http.register_view(ManifestJSONView())
|
||||
|
||||
conf = config.get(DOMAIN, {})
|
||||
@@ -595,7 +559,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
)
|
||||
|
||||
async_register_built_in_panel(hass, "profile")
|
||||
async_register_built_in_panel(hass, "notfound")
|
||||
|
||||
@callback
|
||||
def async_change_listener(
|
||||
@@ -920,18 +883,11 @@ def websocket_get_panels(
|
||||
) -> None:
|
||||
"""Handle get panels command."""
|
||||
user_is_admin = connection.user.is_admin
|
||||
panels_config = hass.data[DATA_PANELS_CONFIG]
|
||||
panels: dict[str, PanelResponse] = {}
|
||||
for panel_key, panel in connection.hass.data[DATA_PANELS].items():
|
||||
config_override = panels_config.get(panel_key)
|
||||
require_admin = (
|
||||
config_override.get("require_admin", panel.require_admin)
|
||||
if config_override
|
||||
else panel.require_admin
|
||||
)
|
||||
if not user_is_admin and require_admin:
|
||||
continue
|
||||
panels[panel_key] = panel.to_response(config_override)
|
||||
panels = {
|
||||
panel_key: panel.to_response()
|
||||
for panel_key, panel in connection.hass.data[DATA_PANELS].items()
|
||||
if user_is_admin or not panel.require_admin
|
||||
}
|
||||
|
||||
connection.send_message(websocket_api.result_message(msg["id"], panels))
|
||||
|
||||
@@ -1030,50 +986,6 @@ def websocket_subscribe_extra_js(
|
||||
connection.send_message(websocket_api.result_message(msg["id"]))
|
||||
|
||||
|
||||
@websocket_api.websocket_command(
|
||||
{
|
||||
vol.Required("type"): "frontend/update_panel",
|
||||
vol.Required("url_path"): str,
|
||||
vol.Optional("title"): vol.Any(cv.string, None),
|
||||
vol.Optional("icon"): vol.Any(cv.icon, None),
|
||||
vol.Optional("require_admin"): vol.Any(cv.boolean, None),
|
||||
vol.Optional("show_in_sidebar"): vol.Any(cv.boolean, None),
|
||||
}
|
||||
)
|
||||
@websocket_api.require_admin
|
||||
@websocket_api.async_response
|
||||
async def websocket_update_panel(
|
||||
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
|
||||
) -> None:
|
||||
"""Handle update panel command."""
|
||||
url_path: str = msg["url_path"]
|
||||
|
||||
if url_path not in hass.data.get(DATA_PANELS, {}):
|
||||
connection.send_error(msg["id"], ERR_NOT_FOUND, "Panel not found")
|
||||
return
|
||||
|
||||
panels_config = hass.data[DATA_PANELS_CONFIG]
|
||||
panel_config = dict(panels_config.get(url_path, {}))
|
||||
|
||||
for key in ("title", "icon", "require_admin", "show_in_sidebar"):
|
||||
if key in msg:
|
||||
if (value := msg[key]) is None:
|
||||
panel_config.pop(key, None)
|
||||
else:
|
||||
panel_config[key] = value
|
||||
|
||||
if panel_config:
|
||||
panels_config[url_path] = panel_config
|
||||
else:
|
||||
panels_config.pop(url_path, None)
|
||||
|
||||
hass.data[DATA_PANELS_STORE].async_delay_save(
|
||||
lambda: hass.data[DATA_PANELS_CONFIG], PANELS_SAVE_DELAY
|
||||
)
|
||||
hass.bus.async_fire(EVENT_PANELS_UPDATED)
|
||||
connection.send_result(msg["id"])
|
||||
|
||||
|
||||
class PanelResponse(TypedDict):
|
||||
"""Represent the panel response type."""
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/generic",
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_push",
|
||||
"requirements": ["av==16.0.1", "Pillow==12.1.1"]
|
||||
"requirements": ["av==16.0.1", "Pillow==12.0.0"]
|
||||
}
|
||||
|
||||
@@ -58,12 +58,11 @@ async def async_setup_entry(
|
||||
class GeonetnzVolcanoSensor(SensorEntity):
|
||||
"""Represents an external event with GeoNet NZ Volcano feed data."""
|
||||
|
||||
_attr_icon = DEFAULT_ICON
|
||||
_attr_native_unit_of_measurement = "alert level"
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(self, config_entry_id, feed_manager, external_id, unit_system):
|
||||
"""Initialize entity with data from feed entry."""
|
||||
self._config_entry_id = config_entry_id
|
||||
self._feed_manager = feed_manager
|
||||
self._external_id = external_id
|
||||
self._attr_unique_id = f"{config_entry_id}_{external_id}"
|
||||
@@ -72,6 +71,8 @@ class GeonetnzVolcanoSensor(SensorEntity):
|
||||
self._distance = None
|
||||
self._latitude = None
|
||||
self._longitude = None
|
||||
self._attribution = None
|
||||
self._alert_level = None
|
||||
self._activity = None
|
||||
self._hazards = None
|
||||
self._feed_last_update = None
|
||||
@@ -123,7 +124,7 @@ class GeonetnzVolcanoSensor(SensorEntity):
|
||||
self._latitude = round(feed_entry.coordinates[0], 5)
|
||||
self._longitude = round(feed_entry.coordinates[1], 5)
|
||||
self._attr_attribution = feed_entry.attribution
|
||||
self._attr_native_value = feed_entry.alert_level
|
||||
self._alert_level = feed_entry.alert_level
|
||||
self._activity = feed_entry.activity
|
||||
self._hazards = feed_entry.hazards
|
||||
self._feed_last_update = dt_util.as_utc(last_update) if last_update else None
|
||||
@@ -132,10 +133,25 @@ class GeonetnzVolcanoSensor(SensorEntity):
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
def native_value(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self._alert_level
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon to use in the frontend, if any."""
|
||||
return DEFAULT_ICON
|
||||
|
||||
@property
|
||||
def name(self) -> str | None:
|
||||
"""Return the name of the entity."""
|
||||
return f"Volcano {self._title}"
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
return "alert level"
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return the device state attributes."""
|
||||
|
||||
@@ -11,10 +11,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"device": {
|
||||
"google_translate": {
|
||||
"name": "Google Translate {lang} {tld}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ from homeassistant.components.tts import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
@@ -27,7 +26,6 @@ from .const import (
|
||||
CONF_TLD,
|
||||
DEFAULT_LANG,
|
||||
DEFAULT_TLD,
|
||||
DOMAIN,
|
||||
MAP_LANG_TLD,
|
||||
SUPPORT_LANGUAGES,
|
||||
SUPPORT_TLD,
|
||||
@@ -68,9 +66,6 @@ async def async_setup_entry(
|
||||
class GoogleTTSEntity(TextToSpeechEntity):
|
||||
"""The Google speech API entity."""
|
||||
|
||||
_attr_supported_languages = SUPPORT_LANGUAGES
|
||||
_attr_supported_options = SUPPORT_OPTIONS
|
||||
|
||||
def __init__(self, config_entry: ConfigEntry, lang: str, tld: str) -> None:
|
||||
"""Init Google TTS service."""
|
||||
if lang in MAP_LANG_TLD:
|
||||
@@ -82,15 +77,20 @@ class GoogleTTSEntity(TextToSpeechEntity):
|
||||
self._attr_name = f"Google Translate {self._lang} {self._tld}"
|
||||
self._attr_unique_id = config_entry.entry_id
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
identifiers={(DOMAIN, config_entry.entry_id)},
|
||||
manufacturer="Google",
|
||||
model="Google Translate TTS",
|
||||
translation_key="google_translate",
|
||||
translation_placeholders={"lang": self._lang, "tld": self._tld},
|
||||
)
|
||||
self._attr_default_language = self._lang
|
||||
@property
|
||||
def default_language(self) -> str:
|
||||
"""Return the default language."""
|
||||
return self._lang
|
||||
|
||||
@property
|
||||
def supported_languages(self) -> list[str]:
|
||||
"""Return list of supported languages."""
|
||||
return SUPPORT_LANGUAGES
|
||||
|
||||
@property
|
||||
def supported_options(self) -> list[str]:
|
||||
"""Return a list of supported options."""
|
||||
return SUPPORT_OPTIONS
|
||||
|
||||
def get_tts_audio(
|
||||
self, message: str, language: str, options: dict[str, Any] | None = None
|
||||
|
||||
@@ -15,7 +15,7 @@ from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
from .const import DISCOVERY_TIMEOUT, DOMAIN
|
||||
from .const import DISCOVERY_TIMEOUT
|
||||
from .coordinator import GoveeLocalApiCoordinator, GoveeLocalConfigEntry
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.LIGHT]
|
||||
@@ -52,11 +52,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoveeLocalConfigEntry) -
|
||||
_LOGGER.error("Start failed, errno: %d", ex.errno)
|
||||
return False
|
||||
_LOGGER.error("Port %s already in use", LISTENING_PORT)
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="port_in_use",
|
||||
translation_placeholders={"port": LISTENING_PORT},
|
||||
) from ex
|
||||
raise ConfigEntryNotReady from ex
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
@@ -65,9 +61,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoveeLocalConfigEntry) -
|
||||
while not coordinator.devices:
|
||||
await asyncio.sleep(delay=1)
|
||||
except TimeoutError as ex:
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN, translation_key="no_devices_found"
|
||||
) from ex
|
||||
raise ConfigEntryNotReady from ex
|
||||
|
||||
entry.runtime_data = coordinator
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
@@ -33,13 +33,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"no_devices_found": {
|
||||
"message": "[%key:common::config_flow::abort::no_devices_found%]"
|
||||
},
|
||||
"port_in_use": {
|
||||
"message": "Port {port} is already in use"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
"abort": {
|
||||
"fw_download_failed": "{firmware_name} firmware for your {model} failed to download. Make sure Home Assistant has internet access and try again.",
|
||||
"fw_install_failed": "{firmware_name} firmware failed to install, check Home Assistant logs for more information.",
|
||||
"not_hassio_thread": "The OpenThread Border Router app can only be installed with Home Assistant OS. If you would like to use the {model} as a Thread border router, please manually set up OpenThread Border Router to communicate with it.",
|
||||
"otbr_addon_already_running": "The OpenThread Border Router app is already running, it cannot be installed again.",
|
||||
"otbr_still_using_stick": "This {model} is in use by the OpenThread Border Router app. If you use the Thread network, make sure you have alternative border routers. Uninstall the app and try again.",
|
||||
"unsupported_firmware": "The radio firmware on your {model} could not be determined. Make sure that no other integration or app is currently trying to communicate with the device. If you are running Home Assistant OS in a virtual machine or in Docker, please make sure that permissions are set correctly for the device.",
|
||||
"not_hassio_thread": "The OpenThread Border Router add-on can only be installed with Home Assistant OS. If you would like to use the {model} as a Thread border router, please manually set up OpenThread Border Router to communicate with it.",
|
||||
"otbr_addon_already_running": "The OpenThread Border Router add-on is already running, it cannot be installed again.",
|
||||
"otbr_still_using_stick": "This {model} is in use by the OpenThread Border Router add-on. If you use the Thread network, make sure you have alternative border routers. Uninstall the add-on and try again.",
|
||||
"unsupported_firmware": "The radio firmware on your {model} could not be determined. Make sure that no other integration or add-on is currently trying to communicate with the device. If you are running Home Assistant OS in a virtual machine or in Docker, please make sure that permissions are set correctly for the device.",
|
||||
"zha_still_using_stick": "This {model} is in use by the Zigbee Home Automation integration. Please migrate your Zigbee network to another adapter or delete the integration and try again."
|
||||
},
|
||||
"progress": {
|
||||
"install_firmware": "Installing {firmware_name} firmware.\n\nDo not make any changes to your hardware or software until this finishes.",
|
||||
"install_otbr_addon": "Installing app",
|
||||
"start_otbr_addon": "Starting app"
|
||||
"install_otbr_addon": "Installing add-on",
|
||||
"start_otbr_addon": "Starting add-on"
|
||||
},
|
||||
"step": {
|
||||
"confirm_otbr": {
|
||||
@@ -34,7 +34,7 @@
|
||||
"title": "Updating adapter"
|
||||
},
|
||||
"otbr_failed": {
|
||||
"description": "The OpenThread Border Router app installation was unsuccessful. Ensure no other software is trying to communicate with the {model}, you have access to the Internet and can install other apps, and try again. Check the Supervisor logs if the problem persists.",
|
||||
"description": "The OpenThread Border Router add-on installation was unsuccessful. Ensure no other software is trying to communicate with the {model}, you have access to the Internet and can install other add-ons, and try again. Check the Supervisor logs if the problem persists.",
|
||||
"title": "Failed to set up OpenThread Border Router"
|
||||
},
|
||||
"pick_firmware": {
|
||||
@@ -89,11 +89,11 @@
|
||||
"silabs_multiprotocol_hardware": {
|
||||
"options": {
|
||||
"abort": {
|
||||
"addon_already_running": "Failed to start the {addon_name} app because it is already running.",
|
||||
"addon_info_failed": "Failed to get {addon_name} app info.",
|
||||
"addon_install_failed": "Failed to install the {addon_name} app.",
|
||||
"addon_already_running": "Failed to start the {addon_name} add-on because it is already running.",
|
||||
"addon_info_failed": "Failed to get {addon_name} add-on info.",
|
||||
"addon_install_failed": "Failed to install the {addon_name} add-on.",
|
||||
"addon_set_config_failed": "Failed to set {addon_name} configuration.",
|
||||
"addon_start_failed": "Failed to start the {addon_name} app.",
|
||||
"addon_start_failed": "Failed to start the {addon_name} add-on.",
|
||||
"not_hassio": "The hardware options can only be configured on Home Assistant OS installations.",
|
||||
"zha_migration_failed": "The ZHA migration did not succeed."
|
||||
},
|
||||
@@ -101,8 +101,8 @@
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
"progress": {
|
||||
"install_addon": "Please wait while the {addon_name} app installation finishes. This can take several minutes.",
|
||||
"start_addon": "Please wait while the {addon_name} app start completes. This may take some seconds."
|
||||
"install_addon": "Please wait while the {addon_name} add-on installation finishes. This can take several minutes.",
|
||||
"start_addon": "Please wait while the {addon_name} add-on start completes. This may take some seconds."
|
||||
},
|
||||
"step": {
|
||||
"addon_installed_other_device": {
|
||||
@@ -129,7 +129,7 @@
|
||||
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::reconfigure_addon::title%]"
|
||||
},
|
||||
"install_addon": {
|
||||
"title": "The Silicon Labs Multiprotocol app installation has started"
|
||||
"title": "The Silicon Labs Multiprotocol add-on installation has started"
|
||||
},
|
||||
"notify_channel_change": {
|
||||
"description": "A Zigbee and Thread channel change has been initiated and will finish in {delay_minutes} minutes.",
|
||||
@@ -143,7 +143,7 @@
|
||||
"title": "Reconfigure IEEE 802.15.4 radio multiprotocol support"
|
||||
},
|
||||
"start_addon": {
|
||||
"title": "The Silicon Labs Multiprotocol app is starting."
|
||||
"title": "The Silicon Labs Multiprotocol add-on is starting."
|
||||
},
|
||||
"uninstall_addon": {
|
||||
"data": {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"otbr_addon_already_running": "[%key:component::homeassistant_hardware::firmware_picker::options::abort::otbr_addon_already_running%]",
|
||||
"otbr_still_using_stick": "[%key:component::homeassistant_hardware::firmware_picker::options::abort::otbr_still_using_stick%]",
|
||||
"read_hw_settings_error": "Failed to read hardware settings",
|
||||
"unsupported_firmware": "The radio firmware on your {model} could not be determined. Make sure that no other integration or app is currently trying to communicate with the device.",
|
||||
"unsupported_firmware": "The radio firmware on your {model} could not be determined. Make sure that no other integration or add-on is currently trying to communicate with the device.",
|
||||
"write_hw_settings_error": "Failed to write hardware settings",
|
||||
"zha_migration_failed": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::abort::zha_migration_failed%]",
|
||||
"zha_still_using_stick": "[%key:component::homeassistant_hardware::firmware_picker::options::abort::zha_still_using_stick%]"
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pyhomematic import HMConnection
|
||||
import voluptuous as vol
|
||||
@@ -216,11 +215,8 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
hass.data[DATA_CONF] = remotes = {}
|
||||
hass.data[DATA_STORE] = set()
|
||||
|
||||
interfaces: dict[str, dict[str, Any]] = conf[CONF_INTERFACES]
|
||||
hosts: dict[str, dict[str, Any]] = conf[CONF_HOSTS]
|
||||
|
||||
# Create hosts-dictionary for pyhomematic
|
||||
for rname, rconfig in interfaces.items():
|
||||
for rname, rconfig in conf[CONF_INTERFACES].items():
|
||||
remotes[rname] = {
|
||||
"ip": rconfig.get(CONF_HOST),
|
||||
"port": rconfig.get(CONF_PORT),
|
||||
@@ -236,7 +232,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"connect": True,
|
||||
}
|
||||
|
||||
for sname, sconfig in hosts.items():
|
||||
for sname, sconfig in conf[CONF_HOSTS].items():
|
||||
remotes[sname] = {
|
||||
"ip": sconfig.get(CONF_HOST),
|
||||
"port": sconfig[CONF_PORT],
|
||||
@@ -262,7 +258,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, hass.data[DATA_HOMEMATIC].stop)
|
||||
|
||||
# Init homematic hubs
|
||||
entity_hubs = [HMHub(hass, homematic, hub_name) for hub_name in hosts]
|
||||
entity_hubs = [HMHub(hass, homematic, hub_name) for hub_name in conf[CONF_HOSTS]]
|
||||
|
||||
def _hm_service_virtualkey(service: ServiceCall) -> None:
|
||||
"""Service to handle virtualkey servicecalls."""
|
||||
@@ -298,7 +294,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
|
||||
def _service_handle_value(service: ServiceCall) -> None:
|
||||
"""Service to call setValue method for HomeMatic system variable."""
|
||||
entity_ids: list[str] | None = service.data.get(ATTR_ENTITY_ID)
|
||||
entity_ids = service.data.get(ATTR_ENTITY_ID)
|
||||
name = service.data[ATTR_NAME]
|
||||
value = service.data[ATTR_VALUE]
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ from pyhomematic import HMConnection
|
||||
from pyhomematic.devicetypes.generic import HMGeneric
|
||||
|
||||
from homeassistant.const import ATTR_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||
from homeassistant.helpers.event import track_time_interval
|
||||
@@ -46,16 +45,15 @@ class HMDevice(Entity):
|
||||
entity_description: EntityDescription | None = None,
|
||||
) -> None:
|
||||
"""Initialize a generic HomeMatic device."""
|
||||
self._attr_name = config.get(ATTR_NAME)
|
||||
self._name = config.get(ATTR_NAME)
|
||||
self._address = config.get(ATTR_ADDRESS)
|
||||
self._interface = config.get(ATTR_INTERFACE)
|
||||
self._channel = config.get(ATTR_CHANNEL)
|
||||
self._state = config.get(ATTR_PARAM)
|
||||
if unique_id := config.get(ATTR_UNIQUE_ID):
|
||||
self._attr_unique_id = unique_id.replace(" ", "_")
|
||||
self._unique_id = config.get(ATTR_UNIQUE_ID)
|
||||
self._data: dict[str, Any] = {}
|
||||
self._connected = False
|
||||
self._attr_available = False
|
||||
self._available = False
|
||||
self._channel_map: dict[str, str] = {}
|
||||
|
||||
if entity_description is not None:
|
||||
@@ -69,6 +67,21 @@ class HMDevice(Entity):
|
||||
"""Load data init callbacks."""
|
||||
self._subscribe_homematic_events()
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique ID. HomeMatic entity IDs are unique by default."""
|
||||
return self._unique_id.replace(" ", "_")
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return true if device is available."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return device specific state attributes."""
|
||||
@@ -103,7 +116,7 @@ class HMDevice(Entity):
|
||||
self._load_data_from_hm()
|
||||
|
||||
# Link events from pyhomematic
|
||||
self._attr_available = not self._hmdevice.UNREACH
|
||||
self._available = not self._hmdevice.UNREACH
|
||||
except Exception as err: # noqa: BLE001
|
||||
self._connected = False
|
||||
_LOGGER.error("Exception while linking %s: %s", self._address, str(err))
|
||||
@@ -119,7 +132,7 @@ class HMDevice(Entity):
|
||||
|
||||
# Availability has changed
|
||||
if self.available != (not self._hmdevice.UNREACH):
|
||||
self._attr_available = not self._hmdevice.UNREACH
|
||||
self._available = not self._hmdevice.UNREACH
|
||||
has_changed = True
|
||||
|
||||
# If it has changed data point, update Home Assistant
|
||||
@@ -200,14 +213,14 @@ class HMHub(Entity):
|
||||
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(self, hass: HomeAssistant, homematic: HMConnection, name: str) -> None:
|
||||
def __init__(self, hass, homematic, name):
|
||||
"""Initialize HomeMatic hub."""
|
||||
self.hass = hass
|
||||
self.entity_id = f"{DOMAIN}.{name.lower()}"
|
||||
self._homematic = homematic
|
||||
self._variables: dict[str, Any] = {}
|
||||
self._variables = {}
|
||||
self._name = name
|
||||
self._state: int | None = None
|
||||
self._state = None
|
||||
|
||||
# Load data
|
||||
track_time_interval(self.hass, self._update_hub, SCAN_INTERVAL_HUB)
|
||||
@@ -217,12 +230,12 @@ class HMHub(Entity):
|
||||
self.hass.add_job(self._update_variables, None)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def state(self) -> int | None:
|
||||
def state(self):
|
||||
"""Return the state of the entity."""
|
||||
return self._state
|
||||
|
||||
@@ -232,7 +245,7 @@ class HMHub(Entity):
|
||||
return self._variables.copy()
|
||||
|
||||
@property
|
||||
def icon(self) -> str:
|
||||
def icon(self):
|
||||
"""Return the icon to use in the frontend, if any."""
|
||||
return "mdi:gradient-vertical"
|
||||
|
||||
|
||||
@@ -344,4 +344,4 @@ class HMSensor(HMDevice, SensorEntity):
|
||||
if self._state:
|
||||
self._data.update({self._state: None})
|
||||
else:
|
||||
_LOGGER.critical("Unable to initialize sensor: %s", self.name)
|
||||
_LOGGER.critical("Unable to initialize sensor: %s", self._name)
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"integration_type": "hub",
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["keyrings.alt", "pyicloud"],
|
||||
"requirements": ["pyicloud==2.4.1"]
|
||||
"requirements": ["pyicloud==2.3.0"]
|
||||
}
|
||||
|
||||
@@ -329,14 +329,14 @@ class IDriveE2BackupAgent(BackupAgent):
|
||||
return self._backup_cache
|
||||
|
||||
backups = {}
|
||||
paginator = self._client.get_paginator("list_objects_v2")
|
||||
metadata_files: list[dict[str, Any]] = []
|
||||
async for page in paginator.paginate(Bucket=self._bucket):
|
||||
metadata_files.extend(
|
||||
obj
|
||||
for obj in page.get("Contents", [])
|
||||
if obj["Key"].endswith(".metadata.json")
|
||||
)
|
||||
response = await cast(Any, self._client).list_objects_v2(Bucket=self._bucket)
|
||||
|
||||
# Filter for metadata files only
|
||||
metadata_files = [
|
||||
obj
|
||||
for obj in response.get("Contents", [])
|
||||
if obj["Key"].endswith(".metadata.json")
|
||||
]
|
||||
|
||||
for metadata_file in metadata_files:
|
||||
try:
|
||||
|
||||
@@ -68,7 +68,7 @@ class IGloLamp(LightEntity):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def brightness(self) -> int:
|
||||
def brightness(self):
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
return int((self._lamp.state()["brightness"] / 200.0) * 255)
|
||||
|
||||
@@ -97,17 +97,17 @@ class IGloLamp(LightEntity):
|
||||
return self._lamp.min_kelvin
|
||||
|
||||
@property
|
||||
def hs_color(self) -> tuple[float, float]:
|
||||
def hs_color(self):
|
||||
"""Return the hs value."""
|
||||
return color_util.color_RGB_to_hs(*self._lamp.state()["rgb"])
|
||||
|
||||
@property
|
||||
def effect(self) -> str:
|
||||
def effect(self):
|
||||
"""Return the current effect."""
|
||||
return self._lamp.state()["effect"]
|
||||
|
||||
@property
|
||||
def effect_list(self) -> list[str]:
|
||||
def effect_list(self):
|
||||
"""Return the list of supported effects."""
|
||||
return self._lamp.effect_list()
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Implementation of the lock platform."""
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
from aiohttp import ClientError
|
||||
from igloohome_api import (
|
||||
@@ -64,7 +63,7 @@ class IgloohomeLockEntity(IgloohomeBaseEntity, LockEntity):
|
||||
)
|
||||
self.bridge_id = bridge_id
|
||||
|
||||
async def async_lock(self, **kwargs: Any) -> None:
|
||||
async def async_lock(self, **kwargs):
|
||||
"""Lock this lock."""
|
||||
try:
|
||||
await self.api.create_bridge_proxied_job(
|
||||
@@ -73,7 +72,7 @@ class IgloohomeLockEntity(IgloohomeBaseEntity, LockEntity):
|
||||
except (ApiException, ClientError) as err:
|
||||
raise HomeAssistantError from err
|
||||
|
||||
async def async_unlock(self, **kwargs: Any) -> None:
|
||||
async def async_unlock(self, **kwargs):
|
||||
"""Unlock this lock."""
|
||||
try:
|
||||
await self.api.create_bridge_proxied_job(
|
||||
@@ -82,7 +81,7 @@ class IgloohomeLockEntity(IgloohomeBaseEntity, LockEntity):
|
||||
except (ApiException, ClientError) as err:
|
||||
raise HomeAssistantError from err
|
||||
|
||||
async def async_open(self, **kwargs: Any) -> None:
|
||||
async def async_open(self, **kwargs):
|
||||
"""Open (unlatch) this lock."""
|
||||
try:
|
||||
await self.api.create_bridge_proxied_job(
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/image_upload",
|
||||
"integration_type": "system",
|
||||
"quality_scale": "internal",
|
||||
"requirements": ["Pillow==12.1.1"]
|
||||
"requirements": ["Pillow==12.0.0"]
|
||||
}
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
"""Provides functionality to interact with infrared devices."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import abstractmethod
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from typing import final
|
||||
|
||||
from infrared_protocols import Command as InfraredCommand
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import Context, HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
__all__ = [
|
||||
"DOMAIN",
|
||||
"InfraredEntity",
|
||||
"InfraredEntityDescription",
|
||||
"async_get_emitters",
|
||||
"async_send_command",
|
||||
]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DATA_COMPONENT: HassKey[EntityComponent[InfraredEntity]] = HassKey(DOMAIN)
|
||||
ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
||||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
|
||||
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the infrared domain."""
|
||||
component = hass.data[DATA_COMPONENT] = EntityComponent[InfraredEntity](
|
||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
|
||||
)
|
||||
await component.async_setup(config)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up a config entry."""
|
||||
return await hass.data[DATA_COMPONENT].async_setup_entry(entry)
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
return await hass.data[DATA_COMPONENT].async_unload_entry(entry)
|
||||
|
||||
|
||||
@callback
|
||||
def async_get_emitters(hass: HomeAssistant) -> list[InfraredEntity]:
|
||||
"""Get all infrared emitters."""
|
||||
component = hass.data.get(DATA_COMPONENT)
|
||||
if component is None:
|
||||
return []
|
||||
|
||||
return list(component.entities)
|
||||
|
||||
|
||||
async def async_send_command(
|
||||
hass: HomeAssistant,
|
||||
entity_uuid: str,
|
||||
command: InfraredCommand,
|
||||
context: Context | None = None,
|
||||
) -> None:
|
||||
"""Send an IR command to the specified infrared entity.
|
||||
|
||||
Raises:
|
||||
HomeAssistantError: If the infrared entity is not found.
|
||||
"""
|
||||
component = hass.data.get(DATA_COMPONENT)
|
||||
if component is None:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="component_not_loaded",
|
||||
)
|
||||
|
||||
ent_reg = er.async_get(hass)
|
||||
entity_id = er.async_validate_entity_id(ent_reg, entity_uuid)
|
||||
entity = component.get_entity(entity_id)
|
||||
if entity is None:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="entity_not_found",
|
||||
translation_placeholders={"entity_id": entity_id},
|
||||
)
|
||||
|
||||
if context is not None:
|
||||
entity.async_set_context(context)
|
||||
|
||||
await entity.async_send_command_internal(command)
|
||||
|
||||
|
||||
class InfraredEntityDescription(EntityDescription, frozen_or_thawed=True):
|
||||
"""Describes infrared entities."""
|
||||
|
||||
|
||||
class InfraredEntity(RestoreEntity):
|
||||
"""Base class for infrared transmitter entities."""
|
||||
|
||||
entity_description: InfraredEntityDescription
|
||||
_attr_should_poll = False
|
||||
_attr_state: None = None
|
||||
|
||||
__last_command_sent: datetime | None = None
|
||||
|
||||
@property
|
||||
@final
|
||||
def state(self) -> str | None:
|
||||
"""Return the entity state."""
|
||||
if (last_command := self.__last_command_sent) is None:
|
||||
return None
|
||||
return last_command.isoformat(timespec="milliseconds")
|
||||
|
||||
@final
|
||||
async def async_send_command_internal(self, command: InfraredCommand) -> None:
|
||||
"""Send an IR command and update state.
|
||||
|
||||
Should not be overridden, handles setting last sent timestamp.
|
||||
"""
|
||||
await self.async_send_command(command)
|
||||
self.__last_command_sent = dt_util.utcnow()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@final
|
||||
async def async_internal_added_to_hass(self) -> None:
|
||||
"""Call when the infrared entity is added to hass."""
|
||||
await super().async_internal_added_to_hass()
|
||||
state = await self.async_get_last_state()
|
||||
if state is not None and state.state is not None:
|
||||
self.__last_command_sent = dt_util.parse_datetime(state.state)
|
||||
|
||||
@abstractmethod
|
||||
async def async_send_command(self, command: InfraredCommand) -> None:
|
||||
"""Send an IR command.
|
||||
|
||||
Args:
|
||||
command: The IR command to send.
|
||||
|
||||
Raises:
|
||||
HomeAssistantError: If transmission fails.
|
||||
"""
|
||||
@@ -1,5 +0,0 @@
|
||||
"""Constants for the Infrared integration."""
|
||||
|
||||
from typing import Final
|
||||
|
||||
DOMAIN: Final = "infrared"
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"entity_component": {
|
||||
"_": {
|
||||
"default": "mdi:led-on"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"domain": "infrared",
|
||||
"name": "Infrared",
|
||||
"codeowners": ["@home-assistant/core"],
|
||||
"documentation": "https://www.home-assistant.io/integrations/infrared",
|
||||
"integration_type": "entity",
|
||||
"quality_scale": "internal",
|
||||
"requirements": ["infrared-protocols==1.0.0"]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"exceptions": {
|
||||
"component_not_loaded": {
|
||||
"message": "Infrared component not loaded"
|
||||
},
|
||||
"entity_not_found": {
|
||||
"message": "Infrared entity `{entity_id}` not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +310,7 @@ class InputDatetime(collection.CollectionEntity, RestoreEntity):
|
||||
return self._config[CONF_HAS_TIME]
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
def icon(self):
|
||||
"""Return the icon to be used for this entity."""
|
||||
return self._config.get(CONF_ICON)
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ class InputNumber(collection.CollectionEntity, RestoreEntity):
|
||||
return self._config.get(CONF_NAME)
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
def icon(self):
|
||||
"""Return the icon to be used for this entity."""
|
||||
return self._config.get(CONF_ICON)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class InsteonDimmerEntity(InsteonEntity, LightEntity):
|
||||
self._attr_supported_color_modes = {ColorMode.ONOFF}
|
||||
|
||||
@property
|
||||
def brightness(self) -> int:
|
||||
def brightness(self):
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
return self._insteon_device_group.value
|
||||
|
||||
|
||||
@@ -451,7 +451,7 @@ class AirPlayDevice(MediaPlayerEntity):
|
||||
return self.device_name
|
||||
|
||||
@property
|
||||
def icon(self) -> str:
|
||||
def icon(self):
|
||||
"""Return the icon to use in the frontend, if any."""
|
||||
if self.selected is True:
|
||||
return "mdi:volume-high"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/kaleidescape",
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_push",
|
||||
"requirements": ["pykaleidescape==1.1.3"],
|
||||
"requirements": ["pykaleidescape==1.1.1"],
|
||||
"ssdp": [
|
||||
{
|
||||
"deviceType": "schemas-upnp-org:device:Basic:1",
|
||||
|
||||
@@ -56,9 +56,7 @@ from .const import DATA_BACKUP_AGENT_LISTENERS, DOMAIN
|
||||
|
||||
COMPONENTS_WITH_DEMO_PLATFORM = [
|
||||
Platform.BUTTON,
|
||||
Platform.FAN,
|
||||
Platform.IMAGE,
|
||||
Platform.INFRARED,
|
||||
Platform.LAWN_MOWER,
|
||||
Platform.LOCK,
|
||||
Platform.NOTIFY,
|
||||
@@ -133,9 +131,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
# Notify backup listeners
|
||||
hass.async_create_task(_notify_backup_listeners(hass), eager_start=False)
|
||||
|
||||
# Reload config entry when subentries are added/removed/updated
|
||||
entry.async_on_unload(entry.add_update_listener(_async_update_listener))
|
||||
|
||||
# Subscribe to labs feature updates for kitchen_sink preview repair
|
||||
entry.async_on_unload(
|
||||
async_subscribe_preview_feature(
|
||||
@@ -152,11 +147,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Reload config entry on update (e.g. subentry added/removed)."""
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload config entry."""
|
||||
# Notify backup listeners
|
||||
|
||||
@@ -8,23 +8,18 @@ from typing import Any
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.infrared import (
|
||||
DOMAIN as INFRARED_DOMAIN,
|
||||
async_get_emitters,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
ConfigSubentryFlow,
|
||||
OptionsFlow,
|
||||
OptionsFlowWithReload,
|
||||
SubentryFlowResult,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.selector import EntitySelector, EntitySelectorConfig
|
||||
|
||||
from .const import CONF_INFRARED_ENTITY_ID, DOMAIN
|
||||
from . import DOMAIN
|
||||
|
||||
CONF_BOOLEAN = "bool"
|
||||
CONF_INT = "int"
|
||||
@@ -49,10 +44,7 @@ class KitchenSinkConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
cls, config_entry: ConfigEntry
|
||||
) -> dict[str, type[ConfigSubentryFlow]]:
|
||||
"""Return subentries supported by this handler."""
|
||||
return {
|
||||
"entity": SubentryFlowHandler,
|
||||
"infrared_fan": InfraredFanSubentryFlowHandler,
|
||||
}
|
||||
return {"entity": SubentryFlowHandler}
|
||||
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Set the config entry up from yaml."""
|
||||
@@ -73,7 +65,7 @@ class KitchenSinkConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
|
||||
class OptionsFlowHandler(OptionsFlow):
|
||||
class OptionsFlowHandler(OptionsFlowWithReload):
|
||||
"""Handle options."""
|
||||
|
||||
async def async_step_init(
|
||||
@@ -154,7 +146,7 @@ class SubentryFlowHandler(ConfigSubentryFlow):
|
||||
"""Reconfigure a sensor."""
|
||||
if user_input is not None:
|
||||
title = user_input.pop("name")
|
||||
return self.async_update_and_abort(
|
||||
return self.async_update_reload_and_abort(
|
||||
self._get_entry(),
|
||||
self._get_reconfigure_subentry(),
|
||||
data=user_input,
|
||||
@@ -170,35 +162,3 @@ class SubentryFlowHandler(ConfigSubentryFlow):
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class InfraredFanSubentryFlowHandler(ConfigSubentryFlow):
|
||||
"""Handle infrared fan subentry flow."""
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> SubentryFlowResult:
|
||||
"""User flow to add an infrared fan."""
|
||||
|
||||
entities = async_get_emitters(self.hass)
|
||||
if not entities:
|
||||
return self.async_abort(reason="no_emitters")
|
||||
|
||||
if user_input is not None:
|
||||
title = user_input.pop("name")
|
||||
return self.async_create_entry(data=user_input, title=title)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Required("name"): str,
|
||||
vol.Required(CONF_INFRARED_ENTITY_ID): EntitySelector(
|
||||
EntitySelectorConfig(
|
||||
domain=INFRARED_DOMAIN,
|
||||
include_entities=[entity.entity_id for entity in entities],
|
||||
)
|
||||
),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
@@ -7,7 +7,6 @@ from collections.abc import Callable
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
DOMAIN = "kitchen_sink"
|
||||
CONF_INFRARED_ENTITY_ID = "infrared_entity_id"
|
||||
DATA_BACKUP_AGENT_LISTENERS: HassKey[list[Callable[[], None]]] = HassKey(
|
||||
f"{DOMAIN}.backup_agent_listeners"
|
||||
)
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
"""Demo platform that offers a fake infrared fan entity."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import infrared_protocols
|
||||
|
||||
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
||||
from homeassistant.components.infrared import async_send_command
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import Event, EventStateChangedData, HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
|
||||
from .const import CONF_INFRARED_ENTITY_ID, DOMAIN
|
||||
|
||||
PARALLEL_UPDATES = 0
|
||||
|
||||
DUMMY_FAN_ADDRESS = 0x1234
|
||||
DUMMY_CMD_POWER_ON = 0x01
|
||||
DUMMY_CMD_POWER_OFF = 0x02
|
||||
DUMMY_CMD_SPEED_LOW = 0x03
|
||||
DUMMY_CMD_SPEED_MEDIUM = 0x04
|
||||
DUMMY_CMD_SPEED_HIGH = 0x05
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the demo infrared fan platform."""
|
||||
for subentry_id, subentry in config_entry.subentries.items():
|
||||
if subentry.subentry_type != "infrared_fan":
|
||||
continue
|
||||
async_add_entities(
|
||||
[
|
||||
DemoInfraredFan(
|
||||
subentry_id=subentry_id,
|
||||
device_name=subentry.title,
|
||||
infrared_entity_id=subentry.data[CONF_INFRARED_ENTITY_ID],
|
||||
)
|
||||
],
|
||||
config_subentry_id=subentry_id,
|
||||
)
|
||||
|
||||
|
||||
class DemoInfraredFan(FanEntity):
|
||||
"""Representation of a demo infrared fan entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
_attr_should_poll = False
|
||||
_attr_assumed_state = True
|
||||
_attr_speed_count = 3
|
||||
_attr_supported_features = (
|
||||
FanEntityFeature.SET_SPEED
|
||||
| FanEntityFeature.TURN_OFF
|
||||
| FanEntityFeature.TURN_ON
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
subentry_id: str,
|
||||
device_name: str,
|
||||
infrared_entity_id: str,
|
||||
) -> None:
|
||||
"""Initialize the demo infrared fan entity."""
|
||||
self._infrared_entity_id = infrared_entity_id
|
||||
self._attr_unique_id = subentry_id
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, subentry_id)},
|
||||
name=device_name,
|
||||
)
|
||||
self._attr_percentage = 0
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Subscribe to infrared entity state changes."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@callback
|
||||
def _async_ir_state_changed(event: Event[EventStateChangedData]) -> None:
|
||||
"""Handle infrared entity state changes."""
|
||||
new_state = event.data["new_state"]
|
||||
self._attr_available = (
|
||||
new_state is not None and new_state.state != STATE_UNAVAILABLE
|
||||
)
|
||||
self.async_write_ha_state()
|
||||
|
||||
self.async_on_remove(
|
||||
async_track_state_change_event(
|
||||
self.hass, [self._infrared_entity_id], _async_ir_state_changed
|
||||
)
|
||||
)
|
||||
|
||||
# Set initial availability based on current infrared entity state
|
||||
ir_state = self.hass.states.get(self._infrared_entity_id)
|
||||
self._attr_available = (
|
||||
ir_state is not None and ir_state.state != STATE_UNAVAILABLE
|
||||
)
|
||||
|
||||
async def _send_command(self, command_code: int) -> None:
|
||||
"""Send an IR command using the NEC protocol."""
|
||||
command = infrared_protocols.NECCommand(
|
||||
address=DUMMY_FAN_ADDRESS,
|
||||
command=command_code,
|
||||
modulation=38000,
|
||||
)
|
||||
await async_send_command(
|
||||
self.hass, self._infrared_entity_id, command, context=self._context
|
||||
)
|
||||
|
||||
async def async_turn_on(
|
||||
self,
|
||||
percentage: int | None = None,
|
||||
preset_mode: str | None = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Turn on the fan."""
|
||||
if percentage is not None:
|
||||
await self.async_set_percentage(percentage)
|
||||
return
|
||||
await self._send_command(DUMMY_CMD_POWER_ON)
|
||||
self._attr_percentage = 33
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the fan."""
|
||||
await self._send_command(DUMMY_CMD_POWER_OFF)
|
||||
self._attr_percentage = 0
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_percentage(self, percentage: int) -> None:
|
||||
"""Set the speed percentage of the fan."""
|
||||
if percentage == 0:
|
||||
await self.async_turn_off()
|
||||
return
|
||||
|
||||
if percentage <= 33:
|
||||
await self._send_command(DUMMY_CMD_SPEED_LOW)
|
||||
elif percentage <= 66:
|
||||
await self._send_command(DUMMY_CMD_SPEED_MEDIUM)
|
||||
else:
|
||||
await self._send_command(DUMMY_CMD_SPEED_HIGH)
|
||||
|
||||
self._attr_percentage = percentage
|
||||
self.async_write_ha_state()
|
||||
@@ -1,65 +0,0 @@
|
||||
"""Demo platform that offers a fake infrared entity."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import infrared_protocols
|
||||
|
||||
from homeassistant.components import persistent_notification
|
||||
from homeassistant.components.infrared import InfraredEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
PARALLEL_UPDATES = 0
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the demo infrared platform."""
|
||||
async_add_entities(
|
||||
[
|
||||
DemoInfrared(
|
||||
unique_id="ir_transmitter",
|
||||
device_name="IR Blaster",
|
||||
entity_name="Infrared Transmitter",
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class DemoInfrared(InfraredEntity):
|
||||
"""Representation of a demo infrared entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
unique_id: str,
|
||||
device_name: str,
|
||||
entity_name: str,
|
||||
) -> None:
|
||||
"""Initialize the demo infrared entity."""
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, unique_id)},
|
||||
name=device_name,
|
||||
)
|
||||
self._attr_name = entity_name
|
||||
|
||||
async def async_send_command(self, command: infrared_protocols.Command) -> None:
|
||||
"""Send an IR command."""
|
||||
timings = [
|
||||
interval
|
||||
for timing in command.get_raw_timings()
|
||||
for interval in (timing.high_us, -timing.low_us)
|
||||
]
|
||||
persistent_notification.async_create(
|
||||
self.hass, str(timings), title="Infrared Command"
|
||||
)
|
||||
@@ -101,8 +101,6 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
for subentry_id, subentry in config_entry.subentries.items():
|
||||
if subentry.subentry_type != "entity":
|
||||
continue
|
||||
async_add_entities(
|
||||
[
|
||||
DemoSensor(
|
||||
|
||||
@@ -32,24 +32,6 @@
|
||||
"description": "Reconfigure the sensor"
|
||||
}
|
||||
}
|
||||
},
|
||||
"infrared_fan": {
|
||||
"abort": {
|
||||
"no_emitters": "No infrared transmitter entities found. Please set up an infrared device first."
|
||||
},
|
||||
"entry_type": "Infrared fan",
|
||||
"initiate_flow": {
|
||||
"user": "Add infrared fan"
|
||||
},
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"infrared_entity_id": "Infrared transmitter",
|
||||
"name": "[%key:common::config_flow::data::name%]"
|
||||
},
|
||||
"description": "Select an infrared transmitter to control the fan."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"device": {
|
||||
|
||||
@@ -6,11 +6,7 @@ import logging
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import (
|
||||
device_registry as dr,
|
||||
entity_registry as er,
|
||||
issue_registry as ir,
|
||||
)
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import (
|
||||
@@ -84,21 +80,6 @@ async def async_setup_entry(
|
||||
lhm_coordinator = LibreHardwareMonitorCoordinator(hass, config_entry)
|
||||
await lhm_coordinator.async_config_entry_first_refresh()
|
||||
|
||||
if lhm_coordinator.data.is_deprecated_version:
|
||||
issue_id = f"deprecated_api_{config_entry.entry_id}"
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
issue_id,
|
||||
breaks_in_ha_version="2026.9.0",
|
||||
is_fixable=False,
|
||||
severity=ir.IssueSeverity.WARNING,
|
||||
translation_key="deprecated_api",
|
||||
translation_placeholders={
|
||||
"lhm_releases_url": "https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/releases"
|
||||
},
|
||||
)
|
||||
|
||||
config_entry.runtime_data = lhm_coordinator
|
||||
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers import device_registry as dr, issue_registry as ir
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||
from homeassistant.helpers.device_registry import DeviceEntry
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
@@ -50,7 +50,7 @@ class LibreHardwareMonitorCoordinator(DataUpdateCoordinator[LibreHardwareMonitor
|
||||
config_entry=config_entry,
|
||||
update_interval=timedelta(seconds=DEFAULT_SCAN_INTERVAL),
|
||||
)
|
||||
self._entry_id = config_entry.entry_id
|
||||
|
||||
self._api = LibreHardwareMonitorClient(
|
||||
host=config_entry.data[CONF_HOST],
|
||||
port=config_entry.data[CONF_PORT],
|
||||
@@ -59,14 +59,13 @@ class LibreHardwareMonitorCoordinator(DataUpdateCoordinator[LibreHardwareMonitor
|
||||
session=async_create_clientsession(hass),
|
||||
)
|
||||
device_entries: list[DeviceEntry] = dr.async_entries_for_config_entry(
|
||||
registry=dr.async_get(self.hass), config_entry_id=self._entry_id
|
||||
registry=dr.async_get(self.hass), config_entry_id=config_entry.entry_id
|
||||
)
|
||||
self._previous_devices: dict[DeviceId, DeviceName] = {
|
||||
DeviceId(next(iter(device.identifiers))[1]): DeviceName(device.name)
|
||||
for device in device_entries
|
||||
if device.identifiers and device.name
|
||||
}
|
||||
self._is_deprecated_version: bool | None = None
|
||||
|
||||
async def _async_update_data(self) -> LibreHardwareMonitorData:
|
||||
try:
|
||||
@@ -81,12 +80,6 @@ class LibreHardwareMonitorCoordinator(DataUpdateCoordinator[LibreHardwareMonitor
|
||||
except LibreHardwareMonitorNoDevicesError as err:
|
||||
raise UpdateFailed("No sensor data available, will retry") from err
|
||||
|
||||
# Check whether user has upgraded LHM from a deprecated version while the integration is running
|
||||
if self._is_deprecated_version and not lhm_data.is_deprecated_version:
|
||||
# Clear deprecation issue
|
||||
ir.async_delete_issue(self.hass, DOMAIN, f"deprecated_api_{self._entry_id}")
|
||||
self._is_deprecated_version = lhm_data.is_deprecated_version
|
||||
|
||||
await self._async_handle_changes_in_devices(
|
||||
dict(lhm_data.main_device_ids_and_names)
|
||||
)
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
"integration_type": "device",
|
||||
"iot_class": "local_polling",
|
||||
"quality_scale": "silver",
|
||||
"requirements": ["librehardwaremonitor-api==1.10.1"]
|
||||
"requirements": ["librehardwaremonitor-api==1.9.1"]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ from __future__ import annotations
|
||||
from typing import Any
|
||||
|
||||
from librehardwaremonitor_api.model import LibreHardwareMonitorSensorData
|
||||
from librehardwaremonitor_api.sensor_type import SensorType
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@@ -54,8 +53,12 @@ class LibreHardwareMonitorSensor(
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._attr_name: str = sensor_data.name
|
||||
|
||||
self._set_state(coordinator.data.is_deprecated_version, sensor_data)
|
||||
self._attr_native_value: str | None = sensor_data.value
|
||||
self._attr_extra_state_attributes: dict[str, Any] = {
|
||||
STATE_MIN_VALUE: sensor_data.min,
|
||||
STATE_MAX_VALUE: sensor_data.max,
|
||||
}
|
||||
self._attr_native_unit_of_measurement = sensor_data.unit
|
||||
self._attr_unique_id: str = f"{entry_id}_{sensor_data.sensor_id}"
|
||||
|
||||
self._sensor_id: str = sensor_data.sensor_id
|
||||
@@ -67,36 +70,15 @@ class LibreHardwareMonitorSensor(
|
||||
model=sensor_data.device_type,
|
||||
)
|
||||
|
||||
def _set_state(
|
||||
self,
|
||||
is_deprecated_lhm_version: bool,
|
||||
sensor_data: LibreHardwareMonitorSensorData,
|
||||
) -> None:
|
||||
value = sensor_data.value
|
||||
min_value = sensor_data.min
|
||||
max_value = sensor_data.max
|
||||
unit = sensor_data.unit
|
||||
|
||||
if not is_deprecated_lhm_version and sensor_data.type == SensorType.THROUGHPUT:
|
||||
# Temporary fix: convert the B/s value to KB/s to not break existing entries
|
||||
# This will be migrated properly once SensorDeviceClass is introduced
|
||||
value = f"{(float(value) / 1024):.1f}" if value else None
|
||||
min_value = f"{(float(min_value) / 1024):.1f}" if min_value else None
|
||||
max_value = f"{(float(max_value) / 1024):.1f}" if max_value else None
|
||||
unit = "KB/s"
|
||||
|
||||
self._attr_native_value: str | None = value
|
||||
self._attr_extra_state_attributes: dict[str, Any] = {
|
||||
STATE_MIN_VALUE: min_value,
|
||||
STATE_MAX_VALUE: max_value,
|
||||
}
|
||||
self._attr_native_unit_of_measurement = unit
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
if sensor_data := self.coordinator.data.sensor_data.get(self._sensor_id):
|
||||
self._set_state(self.coordinator.data.is_deprecated_version, sensor_data)
|
||||
self._attr_native_value = sensor_data.value
|
||||
self._attr_extra_state_attributes = {
|
||||
STATE_MIN_VALUE: sensor_data.min,
|
||||
STATE_MAX_VALUE: sensor_data.max,
|
||||
}
|
||||
else:
|
||||
self._attr_native_value = None
|
||||
|
||||
|
||||
@@ -33,11 +33,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"deprecated_api": {
|
||||
"description": "Your version of Libre Hardware Monitor is deprecated and may not provide stable sensor data. To fix this issue:\n\n1. Download version 0.9.5 or later from {lhm_releases_url}\n2. Close Libre Hardware Monitor on your computer\n3. Install or extract the new version and start Libre Hardware Monitor again (you might have to re-enable the remote web server)\n4. Home Assistant will detect the new version and this issue will clear automatically",
|
||||
"title": "Deprecated Libre Hardware Monitor version"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ from collections.abc import Callable, Coroutine
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Generic
|
||||
|
||||
from pylitterbot import FeederRobot, LitterRobot3, LitterRobot4, LitterRobot5, Robot
|
||||
from pylitterbot import FeederRobot, LitterRobot3, LitterRobot4, Robot
|
||||
|
||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||
from homeassistant.const import EntityCategory
|
||||
@@ -24,24 +24,20 @@ class RobotButtonEntityDescription(ButtonEntityDescription, Generic[_WhiskerEnti
|
||||
press_fn: Callable[[_WhiskerEntityT], Coroutine[Any, Any, bool]]
|
||||
|
||||
|
||||
ROBOT_BUTTON_MAP: dict[tuple[type[Robot], ...], RobotButtonEntityDescription] = {
|
||||
(LitterRobot3, LitterRobot5): RobotButtonEntityDescription[
|
||||
LitterRobot3 | LitterRobot5
|
||||
](
|
||||
ROBOT_BUTTON_MAP: dict[type[Robot], RobotButtonEntityDescription] = {
|
||||
LitterRobot3: RobotButtonEntityDescription[LitterRobot3](
|
||||
key="reset_waste_drawer",
|
||||
translation_key="reset_waste_drawer",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
press_fn=lambda robot: robot.reset_waste_drawer(),
|
||||
),
|
||||
(LitterRobot4, LitterRobot5): RobotButtonEntityDescription[
|
||||
LitterRobot4 | LitterRobot5
|
||||
](
|
||||
LitterRobot4: RobotButtonEntityDescription[LitterRobot4](
|
||||
key="reset",
|
||||
translation_key="reset",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
press_fn=lambda robot: robot.reset(),
|
||||
),
|
||||
(FeederRobot,): RobotButtonEntityDescription[FeederRobot](
|
||||
FeederRobot: RobotButtonEntityDescription[FeederRobot](
|
||||
key="give_snack",
|
||||
translation_key="give_snack",
|
||||
press_fn=lambda robot: robot.give_snack(),
|
||||
|
||||
@@ -65,7 +65,7 @@ class LitterRobotDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
||||
except LitterRobotLoginException as ex:
|
||||
raise ConfigEntryAuthFailed("Invalid credentials") from ex
|
||||
except LitterRobotException as ex:
|
||||
raise UpdateFailed("Unable to connect to Whisker API") from ex
|
||||
raise UpdateFailed("Unable to connect to Litter-Robot API") from ex
|
||||
|
||||
def litter_robots(self) -> Generator[LitterRobot]:
|
||||
"""Get Litter-Robots from the account."""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"domain": "litterrobot",
|
||||
"name": "Whisker",
|
||||
"name": "Litter-Robot",
|
||||
"codeowners": ["@natekspencer", "@tkdrob"],
|
||||
"config_flow": true,
|
||||
"dhcp": [
|
||||
@@ -13,5 +13,5 @@
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["pylitterbot"],
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["pylitterbot==2025.1.0"]
|
||||
"requirements": ["pylitterbot==2025.0.0"]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ from collections.abc import Callable, Coroutine
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Generic, TypeVar
|
||||
|
||||
from pylitterbot import FeederRobot, LitterRobot, LitterRobot4, LitterRobot5, Robot
|
||||
from pylitterbot import FeederRobot, LitterRobot, LitterRobot4, Robot
|
||||
from pylitterbot.robot.litterrobot4 import BrightnessLevel, NightLightMode
|
||||
|
||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||
@@ -32,11 +32,9 @@ class RobotSelectEntityDescription(
|
||||
select_fn: Callable[[_WhiskerEntityT, str], Coroutine[Any, Any, bool]]
|
||||
|
||||
|
||||
ROBOT_SELECT_MAP: dict[
|
||||
type[Robot] | tuple[type[Robot], ...], tuple[RobotSelectEntityDescription, ...]
|
||||
] = {
|
||||
ROBOT_SELECT_MAP: dict[type[Robot], tuple[RobotSelectEntityDescription, ...]] = {
|
||||
LitterRobot: (
|
||||
RobotSelectEntityDescription[LitterRobot, int](
|
||||
RobotSelectEntityDescription[LitterRobot, int]( # type: ignore[type-abstract] # only used for isinstance check
|
||||
key="cycle_delay",
|
||||
translation_key="cycle_delay",
|
||||
unit_of_measurement=UnitOfTime.MINUTES,
|
||||
@@ -45,8 +43,8 @@ ROBOT_SELECT_MAP: dict[
|
||||
select_fn=lambda robot, opt: robot.set_wait_time(int(opt)),
|
||||
),
|
||||
),
|
||||
(LitterRobot4, LitterRobot5): (
|
||||
RobotSelectEntityDescription[LitterRobot4 | LitterRobot5, str](
|
||||
LitterRobot4: (
|
||||
RobotSelectEntityDescription[LitterRobot4, str](
|
||||
key="globe_brightness",
|
||||
translation_key="globe_brightness",
|
||||
current_fn=(
|
||||
@@ -63,7 +61,7 @@ ROBOT_SELECT_MAP: dict[
|
||||
)
|
||||
),
|
||||
),
|
||||
RobotSelectEntityDescription[LitterRobot4 | LitterRobot5, str](
|
||||
RobotSelectEntityDescription[LitterRobot4, str](
|
||||
key="globe_light",
|
||||
translation_key="globe_light",
|
||||
current_fn=(
|
||||
@@ -80,7 +78,7 @@ ROBOT_SELECT_MAP: dict[
|
||||
)
|
||||
),
|
||||
),
|
||||
RobotSelectEntityDescription[LitterRobot4 | LitterRobot5, str](
|
||||
RobotSelectEntityDescription[LitterRobot4, str](
|
||||
key="panel_brightness",
|
||||
translation_key="brightness_level",
|
||||
current_fn=(
|
||||
|
||||
@@ -7,7 +7,7 @@ from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Any, Generic
|
||||
|
||||
from pylitterbot import FeederRobot, LitterRobot, LitterRobot4, LitterRobot5, Pet, Robot
|
||||
from pylitterbot import FeederRobot, LitterRobot, LitterRobot4, Pet, Robot
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
@@ -44,10 +44,8 @@ class RobotSensorEntityDescription(SensorEntityDescription, Generic[_WhiskerEnti
|
||||
value_fn: Callable[[_WhiskerEntityT], float | datetime | str | None]
|
||||
|
||||
|
||||
ROBOT_SENSOR_MAP: dict[
|
||||
type[Robot] | tuple[type[Robot], ...], list[RobotSensorEntityDescription]
|
||||
] = {
|
||||
LitterRobot: [
|
||||
ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
|
||||
LitterRobot: [ # type: ignore[type-abstract] # only used for isinstance check
|
||||
RobotSensorEntityDescription[LitterRobot](
|
||||
key="waste_drawer_level",
|
||||
translation_key="waste_drawer",
|
||||
@@ -147,9 +145,7 @@ ROBOT_SENSOR_MAP: dict[
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
(LitterRobot4, LitterRobot5): [
|
||||
RobotSensorEntityDescription[LitterRobot4 | LitterRobot5](
|
||||
RobotSensorEntityDescription[LitterRobot4](
|
||||
key="litter_level",
|
||||
translation_key="litter_level",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
@@ -157,7 +153,7 @@ ROBOT_SENSOR_MAP: dict[
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda robot: robot.litter_level,
|
||||
),
|
||||
RobotSensorEntityDescription[LitterRobot4 | LitterRobot5](
|
||||
RobotSensorEntityDescription[LitterRobot4](
|
||||
key="pet_weight",
|
||||
translation_key="pet_weight",
|
||||
native_unit_of_measurement=UnitOfMass.POUNDS,
|
||||
|
||||
@@ -107,20 +107,36 @@ class APIData:
|
||||
class AirSensor(SensorEntity):
|
||||
"""Single authority air sensor."""
|
||||
|
||||
_attr_icon = "mdi:cloud-outline"
|
||||
ICON = "mdi:cloud-outline"
|
||||
|
||||
def __init__(self, name, api_data):
|
||||
"""Initialize the sensor."""
|
||||
self._attr_name = self._key = name
|
||||
self._name = name
|
||||
self._api_data = api_data
|
||||
self._site_data = None
|
||||
self._state = None
|
||||
self._updated = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def site_data(self):
|
||||
"""Return the dict of sites data."""
|
||||
return self._site_data
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend, if any."""
|
||||
return self.ICON
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return other details about the sensor state."""
|
||||
@@ -135,7 +151,7 @@ class AirSensor(SensorEntity):
|
||||
sites_status: list = []
|
||||
self._api_data.update()
|
||||
if self._api_data.data:
|
||||
self._site_data = self._api_data.data[self._key]
|
||||
self._site_data = self._api_data.data[self._name]
|
||||
self._updated = self._site_data[0]["updated"]
|
||||
sites_status.extend(
|
||||
site["pollutants_status"]
|
||||
@@ -144,9 +160,9 @@ class AirSensor(SensorEntity):
|
||||
)
|
||||
|
||||
if sites_status:
|
||||
self._attr_native_value = max(set(sites_status), key=sites_status.count)
|
||||
self._state = max(set(sites_status), key=sites_status.count)
|
||||
else:
|
||||
self._attr_native_value = None
|
||||
self._state = None
|
||||
|
||||
|
||||
def parse_species(species_data):
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["matrix_client"],
|
||||
"quality_scale": "legacy",
|
||||
"requirements": ["matrix-nio==0.25.2", "Pillow==12.1.1", "aiofiles==24.1.0"]
|
||||
"requirements": ["matrix-nio==0.25.2", "Pillow==12.0.0", "aiofiles==24.1.0"]
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/matter",
|
||||
"integration_type": "hub",
|
||||
"iot_class": "local_push",
|
||||
"requirements": ["matter-python-client==0.4.1"],
|
||||
"requirements": ["python-matter-server==8.1.2"],
|
||||
"zeroconf": ["_matter._tcp.local.", "_matterc._udp.local."]
|
||||
}
|
||||
|
||||
@@ -498,7 +498,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
custom_clusters.InovelliCluster.Attributes.LEDIndicatorIntensityOff,
|
||||
),
|
||||
product_id=(2, 16),
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.NUMBER,
|
||||
@@ -515,7 +514,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
custom_clusters.InovelliCluster.Attributes.LEDIndicatorIntensityOn,
|
||||
),
|
||||
product_id=(2, 16),
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.NUMBER,
|
||||
|
||||
@@ -908,7 +908,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
clusters.ElectricalPowerMeasurement.Attributes.ApparentPower,
|
||||
),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -925,7 +924,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
clusters.ElectricalPowerMeasurement.Attributes.ReactivePower,
|
||||
),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -941,7 +939,6 @@ DISCOVERY_SCHEMAS = [
|
||||
),
|
||||
entity_class=MatterSensor,
|
||||
required_attributes=(clusters.ElectricalPowerMeasurement.Attributes.Voltage,),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -959,7 +956,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
clusters.ElectricalPowerMeasurement.Attributes.RMSVoltage,
|
||||
),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -977,7 +973,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
clusters.ElectricalPowerMeasurement.Attributes.ApparentCurrent,
|
||||
),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -995,7 +990,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
clusters.ElectricalPowerMeasurement.Attributes.ActiveCurrent,
|
||||
),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -1013,7 +1007,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
clusters.ElectricalPowerMeasurement.Attributes.ReactiveCurrent,
|
||||
),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -1031,7 +1024,6 @@ DISCOVERY_SCHEMAS = [
|
||||
required_attributes=(
|
||||
clusters.ElectricalPowerMeasurement.Attributes.RMSCurrent,
|
||||
),
|
||||
allow_none_value=True,
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
@@ -1047,7 +1039,6 @@ DISCOVERY_SCHEMAS = [
|
||||
device_to_ha=lambda x: x.energy,
|
||||
),
|
||||
entity_class=MatterSensor,
|
||||
allow_none_value=True,
|
||||
required_attributes=(
|
||||
clusters.ElectricalEnergyMeasurement.Attributes.CumulativeEnergyImported,
|
||||
),
|
||||
@@ -1067,7 +1058,6 @@ DISCOVERY_SCHEMAS = [
|
||||
device_to_ha=lambda x: x.energy,
|
||||
),
|
||||
entity_class=MatterSensor,
|
||||
allow_none_value=True,
|
||||
required_attributes=(
|
||||
clusters.ElectricalEnergyMeasurement.Attributes.CumulativeEnergyExported,
|
||||
),
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"config": {
|
||||
"abort": {
|
||||
"addon_get_discovery_info_failed": "Failed to get Matter Server app discovery info.",
|
||||
"addon_info_failed": "Failed to get Matter Server app info.",
|
||||
"addon_install_failed": "Failed to install the Matter Server app.",
|
||||
"addon_start_failed": "Failed to start the Matter Server app.",
|
||||
"addon_get_discovery_info_failed": "Failed to get Matter Server add-on discovery info.",
|
||||
"addon_info_failed": "Failed to get Matter Server add-on info.",
|
||||
"addon_install_failed": "Failed to install the Matter Server add-on.",
|
||||
"addon_start_failed": "Failed to start the Matter Server add-on.",
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"not_matter_addon": "Discovered app is not the official Matter Server app.",
|
||||
"not_matter_addon": "Discovered add-on is not the official Matter Server add-on.",
|
||||
"reconfiguration_successful": "Successfully reconfigured the Matter integration."
|
||||
},
|
||||
"error": {
|
||||
@@ -18,15 +18,15 @@
|
||||
},
|
||||
"flow_title": "{name}",
|
||||
"progress": {
|
||||
"install_addon": "Please wait while the Matter Server app installation finishes. This can take several minutes.",
|
||||
"start_addon": "Please wait while the Matter Server app starts. This app is what powers Matter in Home Assistant. This may take some seconds."
|
||||
"install_addon": "Please wait while the Matter Server add-on installation finishes. This can take several minutes.",
|
||||
"start_addon": "Please wait while the Matter Server add-on starts. This add-on is what powers Matter in Home Assistant. This may take some seconds."
|
||||
},
|
||||
"step": {
|
||||
"hassio_confirm": {
|
||||
"title": "Set up the Matter integration with the Matter Server app"
|
||||
"title": "Set up the Matter integration with the Matter Server add-on"
|
||||
},
|
||||
"install_addon": {
|
||||
"title": "The app installation has started"
|
||||
"title": "The add-on installation has started"
|
||||
},
|
||||
"manual": {
|
||||
"data": {
|
||||
@@ -35,13 +35,13 @@
|
||||
},
|
||||
"on_supervisor": {
|
||||
"data": {
|
||||
"use_addon": "Use the official Matter Server Supervisor app"
|
||||
"use_addon": "Use the official Matter Server Supervisor add-on"
|
||||
},
|
||||
"description": "Do you want to use the official Matter Server Supervisor app?\n\nIf you are already running the Matter Server in another app, in a custom container, natively etc., then do not select this option.",
|
||||
"description": "Do you want to use the official Matter Server Supervisor add-on?\n\nIf you are already running the Matter Server in another add-on, in a custom container, natively etc., then do not select this option.",
|
||||
"title": "Select connection method"
|
||||
},
|
||||
"start_addon": {
|
||||
"title": "Starting app."
|
||||
"title": "Starting add-on."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -46,42 +46,30 @@ async def async_setup_entry(
|
||||
class MatterSwitchEntityDescription(SwitchEntityDescription, MatterEntityDescription):
|
||||
"""Describe Matter Switch entities."""
|
||||
|
||||
inverted: bool = False
|
||||
|
||||
|
||||
class MatterSwitch(MatterEntity, SwitchEntity):
|
||||
"""Representation of a Matter switch."""
|
||||
|
||||
entity_description: MatterSwitchEntityDescription
|
||||
_platform_translation_key = "switch"
|
||||
|
||||
def _get_command_for_value(self, value: bool) -> ClusterCommand:
|
||||
"""Get the appropriate command for the desired value.
|
||||
|
||||
Applies inversion if needed (e.g., for inverted logic like mute).
|
||||
"""
|
||||
send_value = not value if self.entity_description.inverted else value
|
||||
return (
|
||||
clusters.OnOff.Commands.On()
|
||||
if send_value
|
||||
else clusters.OnOff.Commands.Off()
|
||||
)
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn switch on."""
|
||||
await self.send_device_command(self._get_command_for_value(True))
|
||||
await self.send_device_command(
|
||||
clusters.OnOff.Commands.On(),
|
||||
)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn switch off."""
|
||||
await self.send_device_command(self._get_command_for_value(False))
|
||||
await self.send_device_command(
|
||||
clusters.OnOff.Commands.Off(),
|
||||
)
|
||||
|
||||
@callback
|
||||
def _update_from_device(self) -> None:
|
||||
"""Update from device."""
|
||||
value = self.get_matter_attribute_value(self._entity_info.primary_attribute)
|
||||
if self.entity_description.inverted:
|
||||
value = not value
|
||||
self._attr_is_on = value
|
||||
self._attr_is_on = self.get_matter_attribute_value(
|
||||
self._entity_info.primary_attribute
|
||||
)
|
||||
|
||||
|
||||
class MatterGenericCommandSwitch(MatterSwitch):
|
||||
@@ -133,7 +121,9 @@ class MatterGenericCommandSwitch(MatterSwitch):
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class MatterGenericCommandSwitchEntityDescription(MatterSwitchEntityDescription):
|
||||
class MatterGenericCommandSwitchEntityDescription(
|
||||
SwitchEntityDescription, MatterEntityDescription
|
||||
):
|
||||
"""Describe Matter Generic command Switch entities."""
|
||||
|
||||
# command: a custom callback to create the command to send to the device
|
||||
@@ -143,7 +133,9 @@ class MatterGenericCommandSwitchEntityDescription(MatterSwitchEntityDescription)
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class MatterNumericSwitchEntityDescription(MatterSwitchEntityDescription):
|
||||
class MatterNumericSwitchEntityDescription(
|
||||
SwitchEntityDescription, MatterEntityDescription
|
||||
):
|
||||
"""Describe Matter Numeric Switch entities."""
|
||||
|
||||
|
||||
@@ -154,10 +146,11 @@ class MatterNumericSwitch(MatterSwitch):
|
||||
|
||||
async def _async_set_native_value(self, value: bool) -> None:
|
||||
"""Update the current value."""
|
||||
send_value: Any = value
|
||||
if value_convert := self.entity_description.ha_to_device:
|
||||
send_value = value_convert(value)
|
||||
await self.write_attribute(value=send_value)
|
||||
await self.write_attribute(
|
||||
value=send_value,
|
||||
)
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn switch on."""
|
||||
@@ -255,12 +248,19 @@ DISCOVERY_SCHEMAS = [
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SWITCH,
|
||||
entity_description=MatterSwitchEntityDescription(
|
||||
entity_description=MatterNumericSwitchEntityDescription(
|
||||
key="MatterMuteToggle",
|
||||
translation_key="speaker_mute",
|
||||
inverted=True,
|
||||
device_to_ha={
|
||||
True: False, # True means volume is on, so HA should show mute as off
|
||||
False: True, # False means volume is off (muted), so HA should show mute as on
|
||||
}.get,
|
||||
ha_to_device={
|
||||
False: True, # HA showing mute as off means volume is on, so send True
|
||||
True: False, # HA showing mute as on means volume is off (muted), so send False
|
||||
}.get,
|
||||
),
|
||||
entity_class=MatterSwitch,
|
||||
entity_class=MatterNumericSwitch,
|
||||
required_attributes=(clusters.OnOff.Attributes.OnOff,),
|
||||
device_type=(device_types.Speaker,),
|
||||
),
|
||||
|
||||
@@ -10,6 +10,7 @@ from chip.clusters import Objects as clusters
|
||||
from matter_server.client.models import device_types
|
||||
|
||||
from homeassistant.components.vacuum import (
|
||||
Segment,
|
||||
StateVacuumEntity,
|
||||
StateVacuumEntityDescription,
|
||||
VacuumActivity,
|
||||
@@ -70,6 +71,7 @@ class MatterVacuum(MatterEntity, StateVacuumEntity):
|
||||
"""Representation of a Matter Vacuum cleaner entity."""
|
||||
|
||||
_last_accepted_commands: list[int] | None = None
|
||||
_last_service_area_feature_map: int | None = None
|
||||
_supported_run_modes: (
|
||||
dict[int, clusters.RvcRunMode.Structs.ModeOptionStruct] | None
|
||||
) = None
|
||||
@@ -136,6 +138,16 @@ class MatterVacuum(MatterEntity, StateVacuumEntity):
|
||||
"No supported run mode found to start the vacuum cleaner."
|
||||
)
|
||||
|
||||
# Reset selected areas to an unconstrained selection to ensure start
|
||||
# performs a full clean and does not reuse a previous area-targeted
|
||||
# selection.
|
||||
if VacuumEntityFeature.CLEAN_AREA in self.supported_features:
|
||||
# Matter ServiceArea: an empty NewAreas list means unconstrained
|
||||
# operation (full clean).
|
||||
await self.send_device_command(
|
||||
clusters.ServiceArea.Commands.SelectAreas(newAreas=[])
|
||||
)
|
||||
|
||||
await self.send_device_command(
|
||||
clusters.RvcRunMode.Commands.ChangeToMode(newMode=mode.mode)
|
||||
)
|
||||
@@ -144,6 +156,66 @@ class MatterVacuum(MatterEntity, StateVacuumEntity):
|
||||
"""Pause the cleaning task."""
|
||||
await self.send_device_command(clusters.RvcOperationalState.Commands.Pause())
|
||||
|
||||
@property
|
||||
def _current_segments(self) -> list[Segment]:
|
||||
"""Return the current cleanable segments reported by the device."""
|
||||
supported_areas: list[clusters.ServiceArea.Structs.AreaStruct] = (
|
||||
self.get_matter_attribute_value(
|
||||
clusters.ServiceArea.Attributes.SupportedAreas
|
||||
)
|
||||
)
|
||||
|
||||
segments: list[Segment] = []
|
||||
for area in supported_areas:
|
||||
area_name = None
|
||||
if area.areaInfo and area.areaInfo.locationInfo:
|
||||
area_name = area.areaInfo.locationInfo.locationName
|
||||
|
||||
if area_name:
|
||||
segments.append(
|
||||
Segment(
|
||||
id=str(area.areaID),
|
||||
name=area_name,
|
||||
)
|
||||
)
|
||||
|
||||
return segments
|
||||
|
||||
async def async_get_segments(self) -> list[Segment]:
|
||||
"""Get the segments that can be cleaned.
|
||||
|
||||
Returns a list of segments containing their ids and names.
|
||||
"""
|
||||
return self._current_segments
|
||||
|
||||
async def async_clean_segments(self, segment_ids: list[str], **kwargs: Any) -> None:
|
||||
"""Clean the specified segments.
|
||||
|
||||
Args:
|
||||
segment_ids: List of segment IDs to clean.
|
||||
**kwargs: Additional arguments (unused).
|
||||
|
||||
"""
|
||||
# Convert string IDs to integers
|
||||
area_ids = [int(segment_id) for segment_id in segment_ids]
|
||||
|
||||
# Ensure a CLEANING run mode is available before changing device state
|
||||
mode = self._get_run_mode_by_tag(ModeTag.CLEANING)
|
||||
if mode is None:
|
||||
raise HomeAssistantError(
|
||||
"No supported run mode found to start the vacuum cleaner."
|
||||
)
|
||||
|
||||
# Send the SelectAreas command to the vacuum
|
||||
await self.send_device_command(
|
||||
clusters.ServiceArea.Commands.SelectAreas(newAreas=area_ids)
|
||||
)
|
||||
|
||||
# Start cleaning using ChangeToMode with CLEANING tag
|
||||
await self.send_device_command(
|
||||
clusters.RvcRunMode.Commands.ChangeToMode(newMode=mode.mode)
|
||||
)
|
||||
|
||||
@callback
|
||||
def _update_from_device(self) -> None:
|
||||
"""Update from device."""
|
||||
@@ -176,16 +248,34 @@ class MatterVacuum(MatterEntity, StateVacuumEntity):
|
||||
state = VacuumActivity.CLEANING
|
||||
self._attr_activity = state
|
||||
|
||||
if (
|
||||
VacuumEntityFeature.CLEAN_AREA in self.supported_features
|
||||
and self.registry_entry is not None
|
||||
and (last_seen_segments := self.last_seen_segments) is not None
|
||||
and self._current_segments != last_seen_segments
|
||||
):
|
||||
self.async_create_segments_issue()
|
||||
|
||||
@callback
|
||||
def _calculate_features(self) -> None:
|
||||
"""Calculate features for HA Vacuum platform."""
|
||||
accepted_operational_commands: list[int] = self.get_matter_attribute_value(
|
||||
clusters.RvcOperationalState.Attributes.AcceptedCommandList
|
||||
)
|
||||
# in principle the feature set should not change, except for the accepted commands
|
||||
if self._last_accepted_commands == accepted_operational_commands:
|
||||
service_area_feature_map: int | None = self.get_matter_attribute_value(
|
||||
clusters.ServiceArea.Attributes.FeatureMap
|
||||
)
|
||||
|
||||
# In principle the feature set should not change, except for accepted
|
||||
# commands and service area feature map.
|
||||
if (
|
||||
self._last_accepted_commands == accepted_operational_commands
|
||||
and self._last_service_area_feature_map == service_area_feature_map
|
||||
):
|
||||
return
|
||||
|
||||
self._last_accepted_commands = accepted_operational_commands
|
||||
self._last_service_area_feature_map = service_area_feature_map
|
||||
supported_features: VacuumEntityFeature = VacuumEntityFeature(0)
|
||||
supported_features |= VacuumEntityFeature.START
|
||||
supported_features |= VacuumEntityFeature.STATE
|
||||
@@ -212,6 +302,12 @@ class MatterVacuum(MatterEntity, StateVacuumEntity):
|
||||
in accepted_operational_commands
|
||||
):
|
||||
supported_features |= VacuumEntityFeature.RETURN_HOME
|
||||
# Check if Map feature is enabled for clean area support
|
||||
if (
|
||||
service_area_feature_map is not None
|
||||
and service_area_feature_map & clusters.ServiceArea.Bitmaps.Feature.kMaps
|
||||
):
|
||||
supported_features |= VacuumEntityFeature.CLEAN_AREA
|
||||
|
||||
self._attr_supported_features = supported_features
|
||||
|
||||
@@ -228,6 +324,10 @@ DISCOVERY_SCHEMAS = [
|
||||
clusters.RvcRunMode.Attributes.CurrentMode,
|
||||
clusters.RvcOperationalState.Attributes.OperationalState,
|
||||
),
|
||||
optional_attributes=(
|
||||
clusters.ServiceArea.Attributes.FeatureMap,
|
||||
clusters.ServiceArea.Attributes.SupportedAreas,
|
||||
),
|
||||
device_type=(device_types.RoboticVacuumCleaner,),
|
||||
allow_none_value=True,
|
||||
),
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
"""Integration for MyNeomitis."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import aiohttp
|
||||
import pyaxencoapi
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_EMAIL,
|
||||
CONF_PASSWORD,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import Event, HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = [Platform.SELECT]
|
||||
|
||||
|
||||
@dataclass
|
||||
class MyNeomitisRuntimeData:
|
||||
"""Runtime data for MyNeomitis integration."""
|
||||
|
||||
api: pyaxencoapi.PyAxencoAPI
|
||||
devices: list[dict[str, Any]]
|
||||
|
||||
|
||||
type MyNeomitisConfigEntry = ConfigEntry[MyNeomitisRuntimeData]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: MyNeomitisConfigEntry) -> bool:
|
||||
"""Set up MyNeomitis from a config entry."""
|
||||
session = async_get_clientsession(hass)
|
||||
|
||||
email: str = entry.data[CONF_EMAIL]
|
||||
password: str = entry.data[CONF_PASSWORD]
|
||||
|
||||
api = pyaxencoapi.PyAxencoAPI(session)
|
||||
connected = False
|
||||
try:
|
||||
await api.login(email, password)
|
||||
await api.connect_websocket()
|
||||
connected = True
|
||||
_LOGGER.debug("Successfully connected to Login/WebSocket")
|
||||
|
||||
# Retrieve the user's devices
|
||||
devices: list[dict[str, Any]] = await api.get_devices()
|
||||
|
||||
except aiohttp.ClientResponseError as err:
|
||||
if connected:
|
||||
try:
|
||||
await api.disconnect_websocket()
|
||||
except (
|
||||
TimeoutError,
|
||||
ConnectionError,
|
||||
aiohttp.ClientError,
|
||||
) as disconnect_err:
|
||||
_LOGGER.error(
|
||||
"Error while disconnecting WebSocket for %s: %s",
|
||||
entry.entry_id,
|
||||
disconnect_err,
|
||||
)
|
||||
if err.status == 401:
|
||||
raise ConfigEntryAuthFailed(
|
||||
"Authentication failed, please update your credentials"
|
||||
) from err
|
||||
raise ConfigEntryNotReady(f"Error connecting to API: {err}") from err
|
||||
except (TimeoutError, ConnectionError, aiohttp.ClientError) as err:
|
||||
if connected:
|
||||
try:
|
||||
await api.disconnect_websocket()
|
||||
except (
|
||||
TimeoutError,
|
||||
ConnectionError,
|
||||
aiohttp.ClientError,
|
||||
) as disconnect_err:
|
||||
_LOGGER.error(
|
||||
"Error while disconnecting WebSocket for %s: %s",
|
||||
entry.entry_id,
|
||||
disconnect_err,
|
||||
)
|
||||
raise ConfigEntryNotReady(f"Error connecting to API/WebSocket: {err}") from err
|
||||
|
||||
entry.runtime_data = MyNeomitisRuntimeData(api=api, devices=devices)
|
||||
|
||||
async def _async_disconnect_websocket(_event: Event) -> None:
|
||||
"""Disconnect WebSocket on Home Assistant shutdown."""
|
||||
try:
|
||||
await api.disconnect_websocket()
|
||||
except (TimeoutError, ConnectionError, aiohttp.ClientError) as err:
|
||||
_LOGGER.error(
|
||||
"Error while disconnecting WebSocket for %s: %s",
|
||||
entry.entry_id,
|
||||
err,
|
||||
)
|
||||
|
||||
entry.async_on_unload(
|
||||
hass.bus.async_listen_once(
|
||||
EVENT_HOMEASSISTANT_STOP, _async_disconnect_websocket
|
||||
)
|
||||
)
|
||||
|
||||
# Load platforms
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: MyNeomitisConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unload_ok:
|
||||
try:
|
||||
await entry.runtime_data.api.disconnect_websocket()
|
||||
except (TimeoutError, ConnectionError) as err:
|
||||
_LOGGER.error(
|
||||
"Error while disconnecting WebSocket for %s: %s",
|
||||
entry.entry_id,
|
||||
err,
|
||||
)
|
||||
|
||||
return unload_ok
|
||||
@@ -1,78 +0,0 @@
|
||||
"""Config flow for MyNeomitis integration."""
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import aiohttp
|
||||
from pyaxencoapi import PyAxencoAPI
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import CONF_USER_ID, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MyNeoConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle the configuration flow for the MyNeomitis integration."""
|
||||
|
||||
VERSION = 1
|
||||
MINOR_VERSION = 1
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step of the configuration flow."""
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
if user_input is not None:
|
||||
email: str = user_input[CONF_EMAIL]
|
||||
password: str = user_input[CONF_PASSWORD]
|
||||
|
||||
session = async_get_clientsession(self.hass)
|
||||
api = PyAxencoAPI(session)
|
||||
|
||||
try:
|
||||
await api.login(email, password)
|
||||
except aiohttp.ClientResponseError as e:
|
||||
if e.status == 401:
|
||||
errors["base"] = "invalid_auth"
|
||||
elif e.status >= 500:
|
||||
errors["base"] = "cannot_connect"
|
||||
else:
|
||||
errors["base"] = "unknown"
|
||||
except aiohttp.ClientConnectionError:
|
||||
errors["base"] = "cannot_connect"
|
||||
except aiohttp.ClientError:
|
||||
errors["base"] = "unknown"
|
||||
except Exception:
|
||||
_LOGGER.exception("Unexpected error during login")
|
||||
errors["base"] = "unknown"
|
||||
|
||||
if not errors:
|
||||
# Prevent duplicate configuration with the same user ID
|
||||
await self.async_set_unique_id(api.user_id)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
return self.async_create_entry(
|
||||
title=f"MyNeomitis ({email})",
|
||||
data={
|
||||
CONF_EMAIL: email,
|
||||
CONF_PASSWORD: password,
|
||||
CONF_USER_ID: api.user_id,
|
||||
},
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_EMAIL): str,
|
||||
vol.Required(CONF_PASSWORD): str,
|
||||
}
|
||||
),
|
||||
errors=errors,
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
"""Constants for the MyNeomitis integration."""
|
||||
|
||||
DOMAIN = "myneomitis"
|
||||
CONF_USER_ID = "user_id"
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"entity": {
|
||||
"select": {
|
||||
"pilote": {
|
||||
"state": {
|
||||
"antifrost": "mdi:snowflake",
|
||||
"auto": "mdi:refresh-auto",
|
||||
"boost": "mdi:rocket-launch",
|
||||
"comfort": "mdi:fire",
|
||||
"eco": "mdi:leaf",
|
||||
"eco_1": "mdi:leaf",
|
||||
"eco_2": "mdi:leaf",
|
||||
"standby": "mdi:toggle-switch-off-outline"
|
||||
}
|
||||
},
|
||||
"relais": {
|
||||
"state": {
|
||||
"auto": "mdi:refresh-auto",
|
||||
"off": "mdi:toggle-switch-off-outline",
|
||||
"on": "mdi:toggle-switch"
|
||||
}
|
||||
},
|
||||
"ufh": {
|
||||
"state": {
|
||||
"cooling": "mdi:snowflake",
|
||||
"heating": "mdi:fire"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"domain": "myneomitis",
|
||||
"name": "MyNeomitis",
|
||||
"codeowners": ["@l-pr"],
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/myneomitis",
|
||||
"integration_type": "hub",
|
||||
"iot_class": "cloud_push",
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["pyaxencoapi==1.0.6"]
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
rules:
|
||||
# Bronze tier rules
|
||||
action-setup:
|
||||
status: exempt
|
||||
comment: Integration does not register service actions.
|
||||
appropriate-polling:
|
||||
status: exempt
|
||||
comment: Integration uses WebSocket push updates, not polling.
|
||||
brands: done
|
||||
common-modules: done
|
||||
config-flow-test-coverage: done
|
||||
config-flow: done
|
||||
dependency-transparency: done
|
||||
docs-actions:
|
||||
status: exempt
|
||||
comment: Integration does not provide service actions.
|
||||
docs-high-level-description: done
|
||||
docs-installation-instructions: done
|
||||
docs-removal-instructions: done
|
||||
entity-event-setup: done
|
||||
entity-unique-id: done
|
||||
has-entity-name: done
|
||||
runtime-data: done
|
||||
test-before-configure: done
|
||||
test-before-setup: done
|
||||
unique-config-entry: done
|
||||
|
||||
# Silver tier rules
|
||||
action-exceptions:
|
||||
status: exempt
|
||||
comment: Integration does not provide service actions.
|
||||
config-entry-unloading: done
|
||||
docs-configuration-parameters:
|
||||
status: exempt
|
||||
comment: Integration has no configuration parameters beyond initial setup.
|
||||
docs-installation-parameters: done
|
||||
entity-unavailable: done
|
||||
integration-owner: done
|
||||
log-when-unavailable: done
|
||||
parallel-updates:
|
||||
status: exempt
|
||||
comment: Integration uses WebSocket callbacks to push updates directly to entities, not coordinator-based polling.
|
||||
reauthentication-flow: todo
|
||||
test-coverage: done
|
||||
|
||||
# Gold tier rules
|
||||
devices: todo
|
||||
diagnostics: todo
|
||||
discovery-update-info:
|
||||
status: exempt
|
||||
comment: Integration is cloud-based and does not use local discovery.
|
||||
discovery:
|
||||
status: exempt
|
||||
comment: Integration requires manual authentication via cloud service.
|
||||
docs-data-update: todo
|
||||
docs-examples: todo
|
||||
docs-known-limitations: todo
|
||||
docs-supported-devices: todo
|
||||
docs-supported-functions: todo
|
||||
docs-troubleshooting: todo
|
||||
docs-use-cases: todo
|
||||
dynamic-devices: todo
|
||||
entity-category: todo
|
||||
entity-device-class: todo
|
||||
entity-disabled-by-default: todo
|
||||
entity-translations: done
|
||||
exception-translations: todo
|
||||
icon-translations: todo
|
||||
reconfiguration-flow: todo
|
||||
repair-issues: todo
|
||||
stale-devices: todo
|
||||
|
||||
# Platinum tier rules
|
||||
async-dependency: done
|
||||
inject-websession: done
|
||||
strict-typing: todo
|
||||
@@ -1,208 +0,0 @@
|
||||
"""Select entities for MyNeomitis integration.
|
||||
|
||||
This module defines and sets up the select entities for the MyNeomitis integration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pyaxencoapi import PyAxencoAPI
|
||||
|
||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import MyNeomitisConfigEntry
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SUPPORTED_MODELS: frozenset[str] = frozenset({"EWS"})
|
||||
SUPPORTED_SUB_MODELS: frozenset[str] = frozenset({"UFH"})
|
||||
|
||||
PRESET_MODE_MAP = {
|
||||
"comfort": 1,
|
||||
"eco": 2,
|
||||
"antifrost": 3,
|
||||
"standby": 4,
|
||||
"boost": 6,
|
||||
"setpoint": 8,
|
||||
"comfort_plus": 20,
|
||||
"eco_1": 40,
|
||||
"eco_2": 41,
|
||||
"auto": 60,
|
||||
}
|
||||
|
||||
PRESET_MODE_MAP_RELAIS = {
|
||||
"on": 1,
|
||||
"off": 2,
|
||||
"auto": 60,
|
||||
}
|
||||
|
||||
PRESET_MODE_MAP_UFH = {
|
||||
"heating": 0,
|
||||
"cooling": 1,
|
||||
}
|
||||
|
||||
REVERSE_PRESET_MODE_MAP = {v: k for k, v in PRESET_MODE_MAP.items()}
|
||||
|
||||
REVERSE_PRESET_MODE_MAP_RELAIS = {v: k for k, v in PRESET_MODE_MAP_RELAIS.items()}
|
||||
|
||||
REVERSE_PRESET_MODE_MAP_UFH = {v: k for k, v in PRESET_MODE_MAP_UFH.items()}
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class MyNeoSelectEntityDescription(SelectEntityDescription):
|
||||
"""Describe MyNeomitis select entity."""
|
||||
|
||||
preset_mode_map: dict[str, int]
|
||||
reverse_preset_mode_map: dict[int, str]
|
||||
state_key: str
|
||||
|
||||
|
||||
SELECT_TYPES: dict[str, MyNeoSelectEntityDescription] = {
|
||||
"relais": MyNeoSelectEntityDescription(
|
||||
key="relais",
|
||||
translation_key="relais",
|
||||
options=list(PRESET_MODE_MAP_RELAIS),
|
||||
preset_mode_map=PRESET_MODE_MAP_RELAIS,
|
||||
reverse_preset_mode_map=REVERSE_PRESET_MODE_MAP_RELAIS,
|
||||
state_key="targetMode",
|
||||
),
|
||||
"pilote": MyNeoSelectEntityDescription(
|
||||
key="pilote",
|
||||
translation_key="pilote",
|
||||
options=list(PRESET_MODE_MAP),
|
||||
preset_mode_map=PRESET_MODE_MAP,
|
||||
reverse_preset_mode_map=REVERSE_PRESET_MODE_MAP,
|
||||
state_key="targetMode",
|
||||
),
|
||||
"ufh": MyNeoSelectEntityDescription(
|
||||
key="ufh",
|
||||
translation_key="ufh",
|
||||
options=list(PRESET_MODE_MAP_UFH),
|
||||
preset_mode_map=PRESET_MODE_MAP_UFH,
|
||||
reverse_preset_mode_map=REVERSE_PRESET_MODE_MAP_UFH,
|
||||
state_key="changeOverUser",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MyNeomitisConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Select entities from a config entry."""
|
||||
api = config_entry.runtime_data.api
|
||||
devices = config_entry.runtime_data.devices
|
||||
|
||||
def _create_entity(device: dict) -> MyNeoSelect:
|
||||
"""Create a select entity for a device."""
|
||||
if device["model"] == "EWS":
|
||||
# According to the MyNeomitis API, EWS "relais" devices expose a "relayMode"
|
||||
# field in their state, while "pilote" devices do not. We therefore use the
|
||||
# presence of "relayMode" as an explicit heuristic to distinguish relais
|
||||
# from pilote devices. If the upstream API changes this behavior, this
|
||||
# detection logic must be revisited.
|
||||
if "relayMode" in device.get("state", {}):
|
||||
description = SELECT_TYPES["relais"]
|
||||
else:
|
||||
description = SELECT_TYPES["pilote"]
|
||||
else: # UFH
|
||||
description = SELECT_TYPES["ufh"]
|
||||
|
||||
return MyNeoSelect(api, device, description)
|
||||
|
||||
select_entities = [
|
||||
_create_entity(device)
|
||||
for device in devices
|
||||
if device["model"] in SUPPORTED_MODELS | SUPPORTED_SUB_MODELS
|
||||
]
|
||||
|
||||
async_add_entities(select_entities)
|
||||
|
||||
|
||||
class MyNeoSelect(SelectEntity):
|
||||
"""Select entity for MyNeomitis devices."""
|
||||
|
||||
entity_description: MyNeoSelectEntityDescription
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None # Entity represents the device itself
|
||||
_attr_should_poll = False
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
api: PyAxencoAPI,
|
||||
device: dict[str, Any],
|
||||
description: MyNeoSelectEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the MyNeoSelect entity."""
|
||||
self.entity_description = description
|
||||
self._api = api
|
||||
self._device = device
|
||||
self._attr_unique_id = device["_id"]
|
||||
self._attr_available = device["connected"]
|
||||
self._attr_device_info = dr.DeviceInfo(
|
||||
identifiers={(DOMAIN, device["_id"])},
|
||||
name=device["name"],
|
||||
manufacturer="Axenco",
|
||||
model=device["model"],
|
||||
)
|
||||
# Set current option based on device state
|
||||
current_mode = device.get("state", {}).get(description.state_key)
|
||||
self._attr_current_option = description.reverse_preset_mode_map.get(
|
||||
current_mode
|
||||
)
|
||||
self._unavailable_logged: bool = False
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register listener when entity is added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
if unsubscribe := self._api.register_listener(
|
||||
self._device["_id"], self.handle_ws_update
|
||||
):
|
||||
self.async_on_remove(unsubscribe)
|
||||
|
||||
@callback
|
||||
def handle_ws_update(self, new_state: dict[str, Any]) -> None:
|
||||
"""Handle WebSocket updates for the device."""
|
||||
if not new_state:
|
||||
return
|
||||
|
||||
if "connected" in new_state:
|
||||
self._attr_available = new_state["connected"]
|
||||
if not self._attr_available:
|
||||
if not self._unavailable_logged:
|
||||
_LOGGER.info("The entity %s is unavailable", self.entity_id)
|
||||
self._unavailable_logged = True
|
||||
elif self._unavailable_logged:
|
||||
_LOGGER.info("The entity %s is back online", self.entity_id)
|
||||
self._unavailable_logged = False
|
||||
|
||||
# Check for state updates using the description's state_key
|
||||
state_key = self.entity_description.state_key
|
||||
if state_key in new_state:
|
||||
mode = new_state.get(state_key)
|
||||
if mode is not None:
|
||||
self._attr_current_option = (
|
||||
self.entity_description.reverse_preset_mode_map.get(mode)
|
||||
)
|
||||
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_select_option(self, option: str) -> None:
|
||||
"""Send the new mode via the API."""
|
||||
mode_code = self.entity_description.preset_mode_map.get(option)
|
||||
|
||||
if mode_code is None:
|
||||
_LOGGER.warning("Unknown mode selected: %s", option)
|
||||
return
|
||||
|
||||
await self._api.set_device_mode(self._device["_id"], mode_code)
|
||||
self._attr_current_option = option
|
||||
self.async_write_ha_state()
|
||||
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"config": {
|
||||
"abort": {
|
||||
"already_configured": "This integration is already configured."
|
||||
},
|
||||
"error": {
|
||||
"cannot_connect": "Could not connect to the MyNeomitis service. Please try again later.",
|
||||
"invalid_auth": "Authentication failed. Please check your email address and password.",
|
||||
"unknown": "An unexpected error occurred. Please try again."
|
||||
},
|
||||
"step": {
|
||||
"user": {
|
||||
"data": {
|
||||
"email": "[%key:common::config_flow::data::email%]",
|
||||
"password": "[%key:common::config_flow::data::password%]"
|
||||
},
|
||||
"data_description": {
|
||||
"email": "Your email address used for your MyNeomitis account",
|
||||
"password": "Your MyNeomitis account password"
|
||||
},
|
||||
"description": "Enter your MyNeomitis account credentials.",
|
||||
"title": "Connect to MyNeomitis"
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"select": {
|
||||
"pilote": {
|
||||
"state": {
|
||||
"antifrost": "Frost protection",
|
||||
"auto": "[%key:common::state::auto%]",
|
||||
"boost": "Boost",
|
||||
"comfort": "Comfort",
|
||||
"comfort_plus": "Comfort +",
|
||||
"eco": "Eco",
|
||||
"eco_1": "Eco -1",
|
||||
"eco_2": "Eco -2",
|
||||
"setpoint": "Setpoint",
|
||||
"standby": "[%key:common::state::standby%]"
|
||||
}
|
||||
},
|
||||
"relais": {
|
||||
"state": {
|
||||
"auto": "[%key:common::state::auto%]",
|
||||
"off": "[%key:common::state::off%]",
|
||||
"on": "[%key:common::state::on%]"
|
||||
}
|
||||
},
|
||||
"ufh": {
|
||||
"state": {
|
||||
"cooling": "Cooling",
|
||||
"heating": "Heating"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user