Return attribute dict directly without temporary variable v2 (#41271)
This commit is contained in:
1 parent
33e69fe4bf
commit
513f03eb1f
27 files changed
+90
-124
No files matched your search
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user