mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add syncthru active alerts sensor, set default manufacturer (#79418)
* Use Samsung as default manufacturer * Sensor docstring fixes * Add active alerts sensor
This commit is contained in:
parent
506695fdc5
commit
6010672e2f
@ -69,6 +69,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
config_entry_id=entry.entry_id,
|
config_entry_id=entry.entry_id,
|
||||||
configuration_url=printer.url,
|
configuration_url=printer.url,
|
||||||
connections=device_connections(printer),
|
connections=device_connections(printer),
|
||||||
|
default_manufacturer="Samsung",
|
||||||
identifiers=device_identifiers(printer),
|
identifiers=device_identifiers(printer),
|
||||||
model=printer.model(),
|
model=printer.model(),
|
||||||
name=printer.hostname(),
|
name=printer.hostname(),
|
||||||
|
@ -55,7 +55,10 @@ async def async_setup_entry(
|
|||||||
supp_output_tray = printer.output_tray_status()
|
supp_output_tray = printer.output_tray_status()
|
||||||
|
|
||||||
name = config_entry.data[CONF_NAME]
|
name = config_entry.data[CONF_NAME]
|
||||||
entities: list[SyncThruSensor] = [SyncThruMainSensor(coordinator, name)]
|
entities: list[SyncThruSensor] = [
|
||||||
|
SyncThruMainSensor(coordinator, name),
|
||||||
|
SyncThruActiveAlertSensor(coordinator, name),
|
||||||
|
]
|
||||||
|
|
||||||
for key in supp_toner:
|
for key in supp_toner:
|
||||||
entities.append(SyncThruTonerSensor(coordinator, name, key))
|
entities.append(SyncThruTonerSensor(coordinator, name, key))
|
||||||
@ -166,7 +169,7 @@ class SyncThruTonerSensor(SyncThruSensor):
|
|||||||
|
|
||||||
|
|
||||||
class SyncThruDrumSensor(SyncThruSensor):
|
class SyncThruDrumSensor(SyncThruSensor):
|
||||||
"""Implementation of a Samsung Printer toner sensor platform."""
|
"""Implementation of a Samsung Printer drum sensor platform."""
|
||||||
|
|
||||||
def __init__(self, syncthru, name, color):
|
def __init__(self, syncthru, name, color):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
@ -214,7 +217,7 @@ class SyncThruInputTraySensor(SyncThruSensor):
|
|||||||
|
|
||||||
|
|
||||||
class SyncThruOutputTraySensor(SyncThruSensor):
|
class SyncThruOutputTraySensor(SyncThruSensor):
|
||||||
"""Implementation of a Samsung Printer input tray sensor platform."""
|
"""Implementation of a Samsung Printer output tray sensor platform."""
|
||||||
|
|
||||||
def __init__(self, syncthru, name, number):
|
def __init__(self, syncthru, name, number):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
@ -237,3 +240,18 @@ class SyncThruOutputTraySensor(SyncThruSensor):
|
|||||||
if tray_state == "":
|
if tray_state == "":
|
||||||
tray_state = "Ready"
|
tray_state = "Ready"
|
||||||
return tray_state
|
return tray_state
|
||||||
|
|
||||||
|
|
||||||
|
class SyncThruActiveAlertSensor(SyncThruSensor):
|
||||||
|
"""Implementation of a Samsung Printer active alerts sensor platform."""
|
||||||
|
|
||||||
|
def __init__(self, syncthru, name):
|
||||||
|
"""Initialize the sensor."""
|
||||||
|
super().__init__(syncthru, name)
|
||||||
|
self._name = f"{name} Active Alerts"
|
||||||
|
self._id_suffix = "_active_alerts"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def native_value(self):
|
||||||
|
"""Show number of active alerts."""
|
||||||
|
return self.syncthru.raw().get("GXI_ACTIVE_ALERT_TOTAL")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user