Return attribute dict directly without temporary variable v2 (#41271)

This commit is contained in:
springstan authored and GitHub committed 2020-10-06 16:55:16 +02:00
1 parent 33e69fe4bf
commit 513f03eb1f
27 files changed
+90 -124

No files matched your search

+7 -6
View File
@@ -74,13 +74,14 @@ class VeSyncSwitchHA(VeSyncBaseSwitch, SwitchEntity):
@property
def device_state_attributes(self):
"""Return the state attributes of the device."""
attr = {}
if hasattr(self.smartplug, "weekly_energy_total"):
attr["voltage"] = self.smartplug.voltage
attr["weekly_energy_total"] = self.smartplug.weekly_energy_total
attr["monthly_energy_total"] = self.smartplug.monthly_energy_total
attr["yearly_energy_total"] = self.smartplug.yearly_energy_total
return attr
return {
"voltage": self.smartplug.voltage,
"weekly_energy_total": self.smartplug.weekly_energy_total,
"monthly_energy_total": self.smartplug.monthly_energy_total,
"yearly_energy_total": self.smartplug.yearly_energy_total,
}
return {}
@property
def current_power_w(self):