Add Shelly "installed version" extra state attribute to Gen2 firmware update sensor (#57722)
parent
eed9f67402
commit
e232bdc082
|
@ -153,8 +153,9 @@ RPC_SENSORS: Final = {
|
|||
name="Firmware Update",
|
||||
device_class=DEVICE_CLASS_UPDATE,
|
||||
default_enabled=False,
|
||||
extra_state_attributes=lambda status: {
|
||||
extra_state_attributes=lambda status, shelly: {
|
||||
"latest_stable_version": status.get("stable", {"version": ""})["version"],
|
||||
"installed_version": shelly["ver"],
|
||||
"beta_version": status.get("beta", {"version": ""})["version"],
|
||||
},
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
|
|
|
@ -255,7 +255,7 @@ class RpcAttributeDescription:
|
|||
default_enabled: bool = True
|
||||
available: Callable[[dict], 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
|
||||
|
||||
|
||||
|
@ -608,8 +608,11 @@ class ShellyRpcAttributeEntity(ShellyRpcEntity, entity.Entity):
|
|||
if self.description.extra_state_attributes is None:
|
||||
return None
|
||||
|
||||
assert self.wrapper.device.shelly
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue