mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Return attribute dict directly without temporary variable v3 (#41502)
This commit is contained in:
parent
f42eca3fcf
commit
916178925e
@ -508,7 +508,7 @@ class FibaroDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes of the device."""
|
"""Return the state attributes of the device."""
|
||||||
attr = {}
|
attr = {"fibaro_id": self.fibaro_device.id}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if "battery" in self.fibaro_device.interfaces:
|
if "battery" in self.fibaro_device.interfaces:
|
||||||
@ -528,5 +528,4 @@ class FibaroDevice(Entity):
|
|||||||
except (ValueError, KeyError):
|
except (ValueError, KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
attr["fibaro_id"] = self.fibaro_device.id
|
|
||||||
return attr
|
return attr
|
||||||
|
@ -73,7 +73,12 @@ class HMDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return device specific state attributes."""
|
"""Return device specific state attributes."""
|
||||||
attr = {}
|
|
||||||
|
# Static attributes
|
||||||
|
attr = {
|
||||||
|
"id": self._hmdevice.ADDRESS,
|
||||||
|
"interface": self._interface,
|
||||||
|
}
|
||||||
|
|
||||||
# Generate a dictionary with attributes
|
# Generate a dictionary with attributes
|
||||||
for node, data in HM_ATTRIBUTE_SUPPORT.items():
|
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])
|
value = data[1].get(self._data[node], self._data[node])
|
||||||
attr[data[0]] = value
|
attr[data[0]] = value
|
||||||
|
|
||||||
# Static attributes
|
|
||||||
attr["id"] = self._hmdevice.ADDRESS
|
|
||||||
attr["interface"] = self._interface
|
|
||||||
|
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
@ -140,8 +140,7 @@ class LutronCasetaDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attr = {"device_id": self.device_id, "zone_id": self._device["zone"]}
|
return {"device_id": self.device_id, "zone_id": self._device["zone"]}
|
||||||
return attr
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user