Fix PEP257 issues
This commit is contained in:
1 parent
652f059d6a
commit
49ebc6d0b0
29 files changed
+294
-309
No files matched your search
@@ -1,6 +1,4 @@
|
||||
"""
|
||||
homeassistant.components.switch.mfi
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Ubiquiti mFi switches.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
@@ -30,8 +28,7 @@ CONF_VERIFY_TLS = 'verify_tls'
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up mFi sensors. """
|
||||
|
||||
"""Setup mFi sensors."""
|
||||
if not validate_config({DOMAIN: config},
|
||||
{DOMAIN: ['host',
|
||||
CONF_USERNAME,
|
||||
@@ -64,47 +61,58 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class MfiSwitch(SwitchDevice):
|
||||
""" An mFi switch-able device. """
|
||||
"""Representation of an mFi switch-able device."""
|
||||
|
||||
def __init__(self, port):
|
||||
"""Initialize the mFi device."""
|
||||
self._port = port
|
||||
self._target_state = None
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Polling is needed."""
|
||||
return True
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID of the device."""
|
||||
return self._port.ident
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._port.label
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the device is on."""
|
||||
return self._port.output
|
||||
|
||||
def update(self):
|
||||
"""Get the latest state and update the state."""
|
||||
self._port.refresh()
|
||||
if self._target_state is not None:
|
||||
self._port.data['output'] = float(self._target_state)
|
||||
self._target_state = None
|
||||
|
||||
def turn_on(self):
|
||||
"""Turn the switch on."""
|
||||
self._port.control(True)
|
||||
self._target_state = True
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn the switch off."""
|
||||
self._port.control(False)
|
||||
self._target_state = False
|
||||
|
||||
@property
|
||||
def current_power_mwh(self):
|
||||
"""Return the current power usage in mWh."""
|
||||
return int(self._port.data.get('active_pwr', 0) * 1000)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes fof the device."""
|
||||
attr = {}
|
||||
attr['volts'] = round(self._port.data.get('v_rms', 0), 1)
|
||||
attr['amps'] = round(self._port.data.get('i_rms', 0), 1)
|
||||
|
||||
Reference in new issue
Block a user