Return attribute dict directly without temporary variable v3 (#41502)
This commit is contained in:
parent
f42eca3fcf
commit
916178925e
3 changed files with 8 additions and 9 deletions
|
@ -508,7 +508,7 @@ class FibaroDevice(Entity):
|
|||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes of the device."""
|
||||
attr = {}
|
||||
attr = {"fibaro_id": self.fibaro_device.id}
|
||||
|
||||
try:
|
||||
if "battery" in self.fibaro_device.interfaces:
|
||||
|
@ -528,5 +528,4 @@ class FibaroDevice(Entity):
|
|||
except (ValueError, KeyError):
|
||||
pass
|
||||
|
||||
attr["fibaro_id"] = self.fibaro_device.id
|
||||
return attr
|
||||
|
|
|
@ -73,7 +73,12 @@ class HMDevice(Entity):
|
|||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return device specific state attributes."""
|
||||
attr = {}
|
||||
|
||||
# Static attributes
|
||||
attr = {
|
||||
"id": self._hmdevice.ADDRESS,
|
||||
"interface": self._interface,
|
||||
}
|
||||
|
||||
# Generate a dictionary with attributes
|
||||
for node, data in HM_ATTRIBUTE_SUPPORT.items():
|
||||
|
@ -82,10 +87,6 @@ class HMDevice(Entity):
|
|||
value = data[1].get(self._data[node], self._data[node])
|
||||
attr[data[0]] = value
|
||||
|
||||
# Static attributes
|
||||
attr["id"] = self._hmdevice.ADDRESS
|
||||
attr["interface"] = self._interface
|
||||
|
||||
return attr
|
||||
|
||||
def update(self):
|
||||
|
|
|
@ -140,8 +140,7 @@ class LutronCasetaDevice(Entity):
|
|||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
attr = {"device_id": self.device_id, "zone_id": self._device["zone"]}
|
||||
return attr
|
||||
return {"device_id": self.device_id, "zone_id": self._device["zone"]}
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue