forked from home-assistant/core
Add Shelly "installed version" extra state attribute to Gen2 firmware update sensor (#57722)
This commit is contained in:
@@ -153,8 +153,9 @@ RPC_SENSORS: Final = {
|
|||||||
name="Firmware Update",
|
name="Firmware Update",
|
||||||
device_class=DEVICE_CLASS_UPDATE,
|
device_class=DEVICE_CLASS_UPDATE,
|
||||||
default_enabled=False,
|
default_enabled=False,
|
||||||
extra_state_attributes=lambda status: {
|
extra_state_attributes=lambda status, shelly: {
|
||||||
"latest_stable_version": status.get("stable", {"version": ""})["version"],
|
"latest_stable_version": status.get("stable", {"version": ""})["version"],
|
||||||
|
"installed_version": shelly["ver"],
|
||||||
"beta_version": status.get("beta", {"version": ""})["version"],
|
"beta_version": status.get("beta", {"version": ""})["version"],
|
||||||
},
|
},
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
|
@@ -255,7 +255,7 @@ class RpcAttributeDescription:
|
|||||||
default_enabled: bool = True
|
default_enabled: bool = True
|
||||||
available: Callable[[dict], bool] | None = None
|
available: Callable[[dict], bool] | None = None
|
||||||
removal_condition: Callable[[dict, str], bool] | None = None
|
removal_condition: Callable[[dict, str], bool] | None = None
|
||||||
extra_state_attributes: Callable[[dict], dict | None] | None = None
|
extra_state_attributes: Callable[[dict, dict], dict | None] | None = None
|
||||||
entity_category: str | None = None
|
entity_category: str | None = None
|
||||||
|
|
||||||
|
|
||||||
@@ -608,8 +608,11 @@ class ShellyRpcAttributeEntity(ShellyRpcEntity, entity.Entity):
|
|||||||
if self.description.extra_state_attributes is None:
|
if self.description.extra_state_attributes is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
assert self.wrapper.device.shelly
|
||||||
|
|
||||||
return self.description.extra_state_attributes(
|
return self.description.extra_state_attributes(
|
||||||
self.wrapper.device.status[self.key][self.sub_key]
|
self.wrapper.device.status[self.key][self.sub_key],
|
||||||
|
self.wrapper.device.shelly,
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Reference in New Issue
Block a user