File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -241,11 +241,17 @@ def extra_state_attributes(self) -> dict[str, Any]:
241241 attrs : dict [str , Any ] = {}
242242
243243 if (device := self ._coordinator .data [self ._id ]) and (
244- state := device .raw_data ().get ("status" )
245- ):
244+ state := device .raw_data ().get ("status" , {})
245+ ) and (bool (state .get ("online" , False ))):
246+ device_rssi = state .get ("signal" , {}).get ("device_rssi" )
247+ self ._attr_extra_state_attributes ["device_rssi" ] = f"{ device_rssi :.2f} " if device_rssi else "Unknown"
248+ hub_rssi = state .get ("signal" , {}).get ("hub_rssi" )
249+ if hub_rssi is not None :
250+ self ._attr_extra_state_attributes ["hub_rssi" ] = f"{ hub_rssi :.2f} "
251+
246252 attrs = {
247- "device_rssi" : f' { state [ "signal" ][ " device_rssi" ]:.2f } ' ,
248- "hub_rssi" : f' { state [ "signal" ][ " hub_rssi" ]:.2f } ' ,
253+ "device_rssi" : device_rssi ,
254+ "hub_rssi" : hub_rssi ,
249255 }
250256
251257 return attrs
You can’t perform that action at this time.
0 commit comments