mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Always create APCUPS device (#104716)
This commit is contained in:
parent
2496c275c8
commit
fed8e5e873
@ -9,6 +9,7 @@ from typing import Final
|
|||||||
|
|
||||||
from apcaccess import status
|
from apcaccess import status
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.debounce import Debouncer
|
from homeassistant.helpers.debounce import Debouncer
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
@ -32,6 +33,8 @@ class APCUPSdCoordinator(DataUpdateCoordinator[OrderedDict[str, str]]):
|
|||||||
updates from the server.
|
updates from the server.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, host: str, port: int) -> None:
|
def __init__(self, hass: HomeAssistant, host: str, port: int) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
@ -70,13 +73,10 @@ class APCUPSdCoordinator(DataUpdateCoordinator[OrderedDict[str, str]]):
|
|||||||
return self.data.get("SERIALNO")
|
return self.data.get("SERIALNO")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo | None:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the DeviceInfo of this APC UPS, if serial number is available."""
|
"""Return the DeviceInfo of this APC UPS, if serial number is available."""
|
||||||
if not self.ups_serial_no:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.ups_serial_no)},
|
identifiers={(DOMAIN, self.ups_serial_no or self.config_entry.entry_id)},
|
||||||
model=self.ups_model,
|
model=self.ups_model,
|
||||||
manufacturer="APC",
|
manufacturer="APC",
|
||||||
name=self.ups_name if self.ups_name else "APC UPS",
|
name=self.ups_name if self.ups_name else "APC UPS",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user