mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Set entity categories for some entities in Syncthru (#142828)
Set entity categories for some entities
This commit is contained in:
parent
2750535928
commit
6d5c000e1f
@ -9,7 +9,7 @@ from typing import Any, cast
|
|||||||
from pysyncthru import SyncThru, SyncthruState
|
from pysyncthru import SyncThru, SyncthruState
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ def get_toner_entity_description(color: str) -> SyncThruSensorDescription:
|
|||||||
return SyncThruSensorDescription(
|
return SyncThruSensorDescription(
|
||||||
key=f"toner_{color}",
|
key=f"toner_{color}",
|
||||||
translation_key=f"toner_{color}",
|
translation_key=f"toner_{color}",
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
value_fn=lambda printer: printer.toner_status().get(color, {}).get("remaining"),
|
value_fn=lambda printer: printer.toner_status().get(color, {}).get("remaining"),
|
||||||
extra_state_attributes_fn=lambda printer: printer.toner_status().get(color, {}),
|
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(
|
return SyncThruSensorDescription(
|
||||||
key=f"drum_{color}",
|
key=f"drum_{color}",
|
||||||
translation_key=f"drum_{color}",
|
translation_key=f"drum_{color}",
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
value_fn=lambda printer: printer.drum_status().get(color, {}).get("remaining"),
|
value_fn=lambda printer: printer.drum_status().get(color, {}).get("remaining"),
|
||||||
extra_state_attributes_fn=lambda printer: printer.drum_status().get(color, {}),
|
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(
|
return SyncThruSensorDescription(
|
||||||
key=f"tray_{tray}",
|
key=f"tray_{tray}",
|
||||||
translation_key=translation_key,
|
translation_key=translation_key,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
translation_placeholders=placeholders,
|
translation_placeholders=placeholders,
|
||||||
value_fn=(
|
value_fn=(
|
||||||
lambda printer: printer.input_tray_status().get(tray, {}).get("newError")
|
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(
|
return SyncThruSensorDescription(
|
||||||
key=f"output_tray_{tray}",
|
key=f"output_tray_{tray}",
|
||||||
translation_key="output_tray",
|
translation_key="output_tray",
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
translation_placeholders={"tray_number": str(tray)},
|
translation_placeholders={"tray_number": str(tray)},
|
||||||
value_fn=(
|
value_fn=(
|
||||||
lambda printer: printer.output_tray_status().get(tray, {}).get("status")
|
lambda printer: printer.output_tray_status().get(tray, {}).get("status")
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
'device_id': <ANY>,
|
'device_id': <ANY>,
|
||||||
'disabled_by': None,
|
'disabled_by': None,
|
||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
'entity_id': 'sensor.sec84251907c415_black_toner_level',
|
'entity_id': 'sensor.sec84251907c415_black_toner_level',
|
||||||
'has_entity_name': True,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
@ -162,7 +162,7 @@
|
|||||||
'device_id': <ANY>,
|
'device_id': <ANY>,
|
||||||
'disabled_by': None,
|
'disabled_by': None,
|
||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
'entity_id': 'sensor.sec84251907c415_cyan_toner_level',
|
'entity_id': 'sensor.sec84251907c415_cyan_toner_level',
|
||||||
'has_entity_name': True,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
@ -215,7 +215,7 @@
|
|||||||
'device_id': <ANY>,
|
'device_id': <ANY>,
|
||||||
'disabled_by': None,
|
'disabled_by': None,
|
||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
'entity_id': 'sensor.sec84251907c415_input_tray_1',
|
'entity_id': 'sensor.sec84251907c415_input_tray_1',
|
||||||
'has_entity_name': True,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
@ -271,7 +271,7 @@
|
|||||||
'device_id': <ANY>,
|
'device_id': <ANY>,
|
||||||
'disabled_by': None,
|
'disabled_by': None,
|
||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
'entity_id': 'sensor.sec84251907c415_magenta_toner_level',
|
'entity_id': 'sensor.sec84251907c415_magenta_toner_level',
|
||||||
'has_entity_name': True,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
@ -324,7 +324,7 @@
|
|||||||
'device_id': <ANY>,
|
'device_id': <ANY>,
|
||||||
'disabled_by': None,
|
'disabled_by': None,
|
||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
'entity_id': 'sensor.sec84251907c415_output_tray_1',
|
'entity_id': 'sensor.sec84251907c415_output_tray_1',
|
||||||
'has_entity_name': True,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
@ -375,7 +375,7 @@
|
|||||||
'device_id': <ANY>,
|
'device_id': <ANY>,
|
||||||
'disabled_by': None,
|
'disabled_by': None,
|
||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
'entity_id': 'sensor.sec84251907c415_yellow_toner_level',
|
'entity_id': 'sensor.sec84251907c415_yellow_toner_level',
|
||||||
'has_entity_name': True,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user