Skip to content
Snippets Groups Projects
Unverified Commit d7edb5b1 authored by epenet's avatar epenet Committed by GitHub
Browse files

Use DeviceInfo in syncthru (#58581)

parent 03100693
No related branches found
No related tags found
No related merge requests found
"""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 ( ...@@ -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): ...@@ -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):
......
"""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 ...@@ -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): ...@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment