mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +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_RSSI_PEER = "rssi_peer"
|
||||||
ATTR_SABOTAGE = "sabotage"
|
ATTR_SABOTAGE = "sabotage"
|
||||||
ATTR_GROUP_MEMBER_UNREACHABLE = "group_member_unreachable"
|
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):
|
class HomematicipGenericDevice(Entity):
|
||||||
@ -85,21 +107,19 @@ class HomematicipGenericDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def icon(self) -> Optional[str]:
|
def icon(self) -> Optional[str]:
|
||||||
"""Return the icon."""
|
"""Return the icon."""
|
||||||
if hasattr(self._device, "lowBat") and self._device.lowBat:
|
for attr, icon in DEVICE_ATTRIBUTE_ICONS.items():
|
||||||
return "mdi:battery-outline"
|
if getattr(self._device, attr, None):
|
||||||
if hasattr(self._device, "sabotage") and self._device.sabotage:
|
return icon
|
||||||
return "mdi:alert"
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes of the generic device."""
|
"""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:
|
return state_attr
|
||||||
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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user