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:
Ville Skyttä 2022-10-08 21:54:16 +03:00 committed by GitHub
parent 506695fdc5
commit 6010672e2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View file

@ -69,6 +69,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
config_entry_id=entry.entry_id,
configuration_url=printer.url,
connections=device_connections(printer),
default_manufacturer="Samsung",
identifiers=device_identifiers(printer),
model=printer.model(),
name=printer.hostname(),

View file

@ -55,7 +55,10 @@ async def async_setup_entry(
supp_output_tray = printer.output_tray_status()
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:
entities.append(SyncThruTonerSensor(coordinator, name, key))
@ -166,7 +169,7 @@ class SyncThruTonerSensor(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):
"""Initialize the sensor."""
@ -214,7 +217,7 @@ class SyncThruInputTraySensor(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):
"""Initialize the sensor."""
@ -237,3 +240,18 @@ class SyncThruOutputTraySensor(SyncThruSensor):
if tray_state == "":
tray_state = "Ready"
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")