mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Add support for warning attributes to Homematic IP Cloud (#26103)
* add supported optional features * use recommendations
This commit is contained in:
parent
38ce4039c3
commit
f80c9c93ca
@ -18,6 +18,28 @@ ATTR_RSSI_DEVICE = "rssi_device"
|
||||
ATTR_RSSI_PEER = "rssi_peer"
|
||||
ATTR_SABOTAGE = "sabotage"
|
||||
ATTR_GROUP_MEMBER_UNREACHABLE = "group_member_unreachable"
|
||||
ATTR_DEVICE_OVERHEATED = "device_overheated"
|
||||
ATTR_DEVICE_OVERLOADED = "device_overloaded"
|
||||
ATTR_DEVICE_UNTERVOLTAGE = "device_undervoltage"
|
||||
|
||||
DEVICE_ATTRIBUTE_ICONS = {
|
||||
"lowBat": "mdi:battery-outline",
|
||||
"sabotage": "mdi:alert",
|
||||
"deviceOverheated": "mdi:alert",
|
||||
"deviceOverloaded": "mdi:alert",
|
||||
"deviceUndervoltage": "mdi:alert",
|
||||
}
|
||||
|
||||
DEVICE_ATTRIBUTES = {
|
||||
"modelType": ATTR_MODEL_TYPE,
|
||||
"id": ATTR_ID,
|
||||
"sabotage": ATTR_SABOTAGE,
|
||||
"rssiDeviceValue": ATTR_RSSI_DEVICE,
|
||||
"rssiPeerValue": ATTR_RSSI_PEER,
|
||||
"deviceOverheated": ATTR_DEVICE_OVERHEATED,
|
||||
"deviceOverloaded": ATTR_DEVICE_OVERLOADED,
|
||||
"deviceUndervoltage": ATTR_DEVICE_UNTERVOLTAGE,
|
||||
}
|
||||
|
||||
|
||||
class HomematicipGenericDevice(Entity):
|
||||
@ -85,21 +107,19 @@ class HomematicipGenericDevice(Entity):
|
||||
@property
|
||||
def icon(self) -> Optional[str]:
|
||||
"""Return the icon."""
|
||||
if hasattr(self._device, "lowBat") and self._device.lowBat:
|
||||
return "mdi:battery-outline"
|
||||
if hasattr(self._device, "sabotage") and self._device.sabotage:
|
||||
return "mdi:alert"
|
||||
for attr, icon in DEVICE_ATTRIBUTE_ICONS.items():
|
||||
if getattr(self._device, attr, None):
|
||||
return icon
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes of the generic device."""
|
||||
attr = {ATTR_MODEL_TYPE: self._device.modelType, ATTR_ID: self._device.id}
|
||||
state_attr = {}
|
||||
for attr, attr_key in DEVICE_ATTRIBUTES.items():
|
||||
attr_value = getattr(self._device, attr, None)
|
||||
if attr_value:
|
||||
state_attr[attr_key] = attr_value
|
||||
|
||||
if hasattr(self._device, "sabotage") and self._device.sabotage:
|
||||
attr[ATTR_SABOTAGE] = self._device.sabotage
|
||||
if hasattr(self._device, "rssiDeviceValue") and self._device.rssiDeviceValue:
|
||||
attr[ATTR_RSSI_DEVICE] = self._device.rssiDeviceValue
|
||||
if hasattr(self._device, "rssiPeerValue") and self._device.rssiPeerValue:
|
||||
attr[ATTR_RSSI_PEER] = self._device.rssiPeerValue
|
||||
return attr
|
||||
return state_attr
|
||||
|
Loading…
x
Reference in New Issue
Block a user