mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use DeviceInfo in syncthru (#58581)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
03100693b0
commit
d7edb5b11c
@ -1,4 +1,5 @@
|
|||||||
"""Support for Samsung Printers with SyncThru web interface."""
|
"""Support for Samsung Printers with SyncThru web interface."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from pysyncthru import SyncThru, SyncthruState
|
from pysyncthru import SyncThru, SyncthruState
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ from homeassistant.components.binary_sensor import (
|
|||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
@ -63,9 +65,13 @@ class SyncThruBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
|||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo | None:
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return {"identifiers": device_identifiers(self.syncthru)}
|
if (identifiers := device_identifiers(self.syncthru)) is None:
|
||||||
|
return None
|
||||||
|
return DeviceInfo(
|
||||||
|
identifiers=identifiers,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SyncThruOnlineSensor(SyncThruBinarySensor):
|
class SyncThruOnlineSensor(SyncThruBinarySensor):
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Support for Samsung Printers with SyncThru web interface."""
|
"""Support for Samsung Printers with SyncThru web interface."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
|||||||
from homeassistant.config_entries import SOURCE_IMPORT
|
from homeassistant.config_entries import SOURCE_IMPORT
|
||||||
from homeassistant.const import CONF_NAME, CONF_RESOURCE, CONF_URL, PERCENTAGE
|
from homeassistant.const import CONF_NAME, CONF_RESOURCE, CONF_URL, PERCENTAGE
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
@ -129,9 +131,13 @@ class SyncThruSensor(CoordinatorEntity, SensorEntity):
|
|||||||
return self._unit_of_measurement
|
return self._unit_of_measurement
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo | None:
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return {"identifiers": device_identifiers(self.syncthru)}
|
if (identifiers := device_identifiers(self.syncthru)) is None:
|
||||||
|
return None
|
||||||
|
return DeviceInfo(
|
||||||
|
identifiers=identifiers,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SyncThruMainSensor(SyncThruSensor):
|
class SyncThruMainSensor(SyncThruSensor):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user