Set entity categories for some entities in Syncthru (#142828)

Set entity categories for some entities
This commit is contained in:
Joost Lekkerkerker 2025-04-14 09:51:41 +02:00 committed by GitHub
parent 2750535928
commit 6d5c000e1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View File

@ -9,7 +9,7 @@ from typing import Any, cast
from pysyncthru import SyncThru, SyncthruState
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
from homeassistant.const import PERCENTAGE
from homeassistant.const import PERCENTAGE, EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
@ -40,6 +40,7 @@ def get_toner_entity_description(color: str) -> SyncThruSensorDescription:
return SyncThruSensorDescription(
key=f"toner_{color}",
translation_key=f"toner_{color}",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda printer: printer.toner_status().get(color, {}).get("remaining"),
extra_state_attributes_fn=lambda printer: printer.toner_status().get(color, {}),
@ -51,6 +52,7 @@ def get_drum_entity_description(color: str) -> SyncThruSensorDescription:
return SyncThruSensorDescription(
key=f"drum_{color}",
translation_key=f"drum_{color}",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda printer: printer.drum_status().get(color, {}).get("remaining"),
extra_state_attributes_fn=lambda printer: printer.drum_status().get(color, {}),
@ -68,6 +70,7 @@ def get_input_tray_entity_description(tray: str) -> SyncThruSensorDescription:
return SyncThruSensorDescription(
key=f"tray_{tray}",
translation_key=translation_key,
entity_category=EntityCategory.DIAGNOSTIC,
translation_placeholders=placeholders,
value_fn=(
lambda printer: printer.input_tray_status().get(tray, {}).get("newError")
@ -84,6 +87,7 @@ def get_output_tray_entity_description(tray: int) -> SyncThruSensorDescription:
return SyncThruSensorDescription(
key=f"output_tray_{tray}",
translation_key="output_tray",
entity_category=EntityCategory.DIAGNOSTIC,
translation_placeholders={"tray_number": str(tray)},
value_fn=(
lambda printer: printer.output_tray_status().get(tray, {}).get("status")

View File

@ -109,7 +109,7 @@
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.sec84251907c415_black_toner_level',
'has_entity_name': True,
'hidden_by': None,
@ -162,7 +162,7 @@
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.sec84251907c415_cyan_toner_level',
'has_entity_name': True,
'hidden_by': None,
@ -215,7 +215,7 @@
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.sec84251907c415_input_tray_1',
'has_entity_name': True,
'hidden_by': None,
@ -271,7 +271,7 @@
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.sec84251907c415_magenta_toner_level',
'has_entity_name': True,
'hidden_by': None,
@ -324,7 +324,7 @@
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.sec84251907c415_output_tray_1',
'has_entity_name': True,
'hidden_by': None,
@ -375,7 +375,7 @@
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.sec84251907c415_yellow_toner_level',
'has_entity_name': True,
'hidden_by': None,