Move SmartThings imports to top (#24878)

* Move imports to top

* use lib constants

* Add missing three_axis mapping
This commit is contained in:
Andrew Sayre authored and GitHub committed 2019-06-30 22:29:21 -04:00
1 parent 7d651e2b7a
commit 7db4eeaf7f
12 files changed
+176 -191

No files matched your search

@@ -1,6 +1,8 @@
"""Support for switches through the SmartThings cloud API."""
from typing import Optional, Sequence
from pysmartthings import Attribute, Capability
from homeassistant.components.switch import SwitchDevice
from . import SmartThingsEntity
@@ -23,8 +25,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
"""Return all capabilities supported if minimum required are present."""
from pysmartthings import Capability
# Must be able to be turned on/off.
if Capability.switch in capabilities:
return [Capability.switch,
@@ -53,13 +53,11 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchDevice):
@property
def current_power_w(self):
"""Return the current power usage in W."""
from pysmartthings import Attribute
return self._device.status.attributes[Attribute.power].value
@property
def today_energy_kwh(self):
"""Return the today total energy usage in kWh."""
from pysmartthings import Attribute
return self._device.status.attributes[Attribute.energy].value
@property