mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Store Shelly REST entity descriptions as tuples (#193664)
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
887a7afbe7
commit
16c2e91bbc
@@ -219,8 +219,8 @@ BLOCK_SENSORS: dict[tuple[str, str], BlockBinarySensorDescription] = {
|
||||
),
|
||||
}
|
||||
|
||||
REST_SENSORS: Final = {
|
||||
"cloud": RestBinarySensorDescription(
|
||||
REST_SENSORS: Final = (
|
||||
RestBinarySensorDescription(
|
||||
key="cloud",
|
||||
translation_key="cloud",
|
||||
value=lambda status, _: status["cloud"]["connected"],
|
||||
@@ -228,7 +228,7 @@ REST_SENSORS: Final = {
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
RPC_SENSORS: Final = (
|
||||
RpcBinarySensorDescription(
|
||||
|
||||
@@ -305,7 +305,7 @@ def async_setup_entry_rest(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ShellyConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
sensors: Mapping[str, RestEntityDescription],
|
||||
sensors: Iterable[RestEntityDescription],
|
||||
sensor_class: Callable,
|
||||
) -> None:
|
||||
"""Set up entities for REST sensors."""
|
||||
@@ -313,8 +313,8 @@ def async_setup_entry_rest(
|
||||
assert coordinator
|
||||
|
||||
async_add_entities(
|
||||
sensor_class(coordinator, sensor_id, sensors[sensor_id])
|
||||
for sensor_id in sensors
|
||||
sensor_class(coordinator, description.key, description)
|
||||
for description in sensors
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -520,8 +520,8 @@ BLOCK_SENSORS: dict[tuple[str, str], BlockSensorDescription] = {
|
||||
),
|
||||
}
|
||||
|
||||
REST_SENSORS: Final = {
|
||||
"rssi": RestSensorDescription(
|
||||
REST_SENSORS: Final = (
|
||||
RestSensorDescription(
|
||||
key="rssi",
|
||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
value=lambda status, _: status["wifi_sta"]["rssi"],
|
||||
@@ -530,14 +530,14 @@ REST_SENSORS: Final = {
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
"uptime": RestSensorDescription(
|
||||
RestSensorDescription(
|
||||
key="uptime",
|
||||
value=lambda status, _: utcnow() - timedelta(seconds=status["uptime"]),
|
||||
device_class=SensorDeviceClass.UPTIME,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
RPC_SENSORS: Final = (
|
||||
|
||||
@@ -69,8 +69,8 @@ class RestUpdateDescription(RestEntityDescription, UpdateEntityDescription):
|
||||
beta: bool
|
||||
|
||||
|
||||
REST_UPDATES: Final = {
|
||||
"fwupdate": RestUpdateDescription(
|
||||
REST_UPDATES: Final = (
|
||||
RestUpdateDescription(
|
||||
key="fwupdate",
|
||||
latest_version=lambda status: status["update"]["new_version"],
|
||||
beta=False,
|
||||
@@ -78,8 +78,8 @@ REST_UPDATES: Final = {
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
"fwupdate_beta": RestUpdateDescription(
|
||||
key="fwupdate",
|
||||
RestUpdateDescription(
|
||||
key="fwupdate_beta",
|
||||
translation_key="beta_firmware",
|
||||
latest_version=lambda status: status["update"].get("beta_version"),
|
||||
beta=True,
|
||||
@@ -87,7 +87,7 @@ REST_UPDATES: Final = {
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class RpcLoraAddOnUpdateEntity(ShellyRpcAttributeEntity, UpdateEntity):
|
||||
|
||||
Reference in New Issue
Block a user