mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Fixed flake8 errors
This commit is contained in:
parent
f38787c258
commit
50ff26ea20
@ -66,14 +66,17 @@ import homeassistant.external.vera.vera as veraApi
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
""" Find and return Vera lights. """
|
""" Find and return Vera lights. """
|
||||||
try:
|
try:
|
||||||
base_url = config.get('vera_controller_url')
|
base_url = config.get('vera_controller_url')
|
||||||
if not base_url:
|
if not base_url:
|
||||||
_LOGGER.error("The required parameter 'vera_controller_url'"
|
_LOGGER.error(
|
||||||
" was not found in config")
|
"The required parameter 'vera_controller_url'"
|
||||||
|
" was not found in config"
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
device_data = config.get('device_data', None)
|
device_data = config.get('device_data', None)
|
||||||
@ -121,7 +124,6 @@ class VeraLight(ToggleDevice):
|
|||||||
self.vera_device = vera_device
|
self.vera_device = vera_device
|
||||||
self.extra_data = extra_data
|
self.extra_data = extra_data
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Get the mame of the light. """
|
""" Get the mame of the light. """
|
||||||
@ -142,8 +144,10 @@ class VeraLight(ToggleDevice):
|
|||||||
|
|
||||||
if self.vera_device.is_trippable:
|
if self.vera_device.is_trippable:
|
||||||
last_tripped = self.vera_device.refresh_value('LastTrip')
|
last_tripped = self.vera_device.refresh_value('LastTrip')
|
||||||
trip_time_str = time.strftime("%Y-%m-%d %H:%M",
|
trip_time_str = time.strftime(
|
||||||
time.localtime(int(last_tripped)))
|
"%Y-%m-%d %H:%M",
|
||||||
|
time.localtime(int(last_tripped))
|
||||||
|
)
|
||||||
|
|
||||||
attr['Last Tripped'] = trip_time_str
|
attr['Last Tripped'] = trip_time_str
|
||||||
|
|
||||||
@ -175,4 +179,3 @@ class VeraLight(ToggleDevice):
|
|||||||
# because the vera has some lag in updating the device status
|
# because the vera has some lag in updating the device status
|
||||||
if (self.last_command_send + 5) < time.time():
|
if (self.last_command_send + 5) < time.time():
|
||||||
self.is_on_status = self.vera_device.is_switched_on()
|
self.is_on_status = self.vera_device.is_switched_on()
|
||||||
|
|
@ -62,14 +62,17 @@ import homeassistant.external.vera.vera as veraApi
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def get_devices(hass, config):
|
def get_devices(hass, config):
|
||||||
""" Find and return Vera Sensors. """
|
""" Find and return Vera Sensors. """
|
||||||
try:
|
try:
|
||||||
base_url = config.get('vera_controller_url')
|
base_url = config.get('vera_controller_url')
|
||||||
if not base_url:
|
if not base_url:
|
||||||
_LOGGER.error("The required parameter 'vera_controller_url'"
|
_LOGGER.error(
|
||||||
" was not found in config")
|
"The required parameter 'vera_controller_url'"
|
||||||
|
" was not found in config"
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
device_data = config.get('device_data', None)
|
device_data = config.get('device_data', None)
|
||||||
@ -93,10 +96,12 @@ def get_devices(hass, config):
|
|||||||
|
|
||||||
return vera_sensors
|
return vera_sensors
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Performs setup for Vera controller devices """
|
""" Performs setup for Vera controller devices """
|
||||||
add_devices(get_devices(hass, config))
|
add_devices(get_devices(hass, config))
|
||||||
|
|
||||||
|
|
||||||
def get_extra_device_data(device_data, device_id):
|
def get_extra_device_data(device_data, device_id):
|
||||||
""" Gets the additional configuration data by Vera device Id """
|
""" Gets the additional configuration data by Vera device Id """
|
||||||
if not device_data:
|
if not device_data:
|
||||||
@ -134,7 +139,6 @@ class VeraSensor(Device):
|
|||||||
@property
|
@property
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
attr = super().state_attributes
|
attr = super().state_attributes
|
||||||
|
|
||||||
if self.vera_device.has_battery:
|
if self.vera_device.has_battery:
|
||||||
attr['Battery'] = self.vera_device.battery_level + '%'
|
attr['Battery'] = self.vera_device.battery_level + '%'
|
||||||
|
|
||||||
@ -144,26 +148,23 @@ class VeraSensor(Device):
|
|||||||
|
|
||||||
if self.vera_device.is_trippable:
|
if self.vera_device.is_trippable:
|
||||||
last_tripped = self.vera_device.refresh_value('LastTrip')
|
last_tripped = self.vera_device.refresh_value('LastTrip')
|
||||||
trip_time_str = time.strftime("%Y-%m-%d %H:%M",
|
trip_time_str = time.strftime(
|
||||||
time.localtime(int(last_tripped)))
|
"%Y-%m-%d %H:%M",
|
||||||
|
time.localtime(int(last_tripped))
|
||||||
|
)
|
||||||
attr['Last Tripped'] = trip_time_str
|
attr['Last Tripped'] = trip_time_str
|
||||||
|
|
||||||
tripped = self.vera_device.refresh_value('Tripped')
|
tripped = self.vera_device.refresh_value('Tripped')
|
||||||
attr['Tripped'] = 'True' if tripped == '1' else 'False'
|
attr['Tripped'] = 'True' if tripped == '1' else 'False'
|
||||||
|
|
||||||
attr['Vera Device Id'] = self.vera_device.vera_device_id
|
attr['Vera Device Id'] = self.vera_device.vera_device_id
|
||||||
|
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.vera_device.category == "Temperature Sensor":
|
if self.vera_device.category == "Temperature Sensor":
|
||||||
self.vera_device.refresh_value('CurrentTemperature')
|
self.vera_device.refresh_value('CurrentTemperature')
|
||||||
current_temp = self.vera_device.get_value('CurrentTemperature')
|
current_temp = self.vera_device.get_value('CurrentTemperature')
|
||||||
vera_temp_units = self.vera_device.veraController.temperature_units
|
vera_temp_units = self.vera_device.veraController.temperature_units
|
||||||
self.current_value = current_temp + '°' + vera_temp_units
|
self.current_value = current_temp + '°' + vera_temp_units
|
||||||
|
|
||||||
elif self.vera_device.category == "Light Sensor":
|
elif self.vera_device.category == "Light Sensor":
|
||||||
self.vera_device.refresh_value('CurrentLevel')
|
self.vera_device.refresh_value('CurrentLevel')
|
||||||
self.current_value = self.vera_device.get_value('CurrentLevel')
|
self.current_value = self.vera_device.get_value('CurrentLevel')
|
||||||
@ -172,4 +173,3 @@ class VeraSensor(Device):
|
|||||||
self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped'
|
self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped'
|
||||||
else:
|
else:
|
||||||
self.current_value = 'Unknown'
|
self.current_value = 'Unknown'
|
||||||
|
|
@ -62,14 +62,17 @@ import homeassistant.external.vera.vera as veraApi
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def get_devices(hass, config):
|
def get_devices(hass, config):
|
||||||
""" Find and return Vera switches. """
|
""" Find and return Vera switches. """
|
||||||
try:
|
try:
|
||||||
base_url = config.get('vera_controller_url')
|
base_url = config.get('vera_controller_url')
|
||||||
if not base_url:
|
if not base_url:
|
||||||
_LOGGER.error("The required parameter 'vera_controller_url'"
|
_LOGGER.error(
|
||||||
" was not found in config")
|
"The required parameter 'vera_controller_url'"
|
||||||
|
" was not found in config"
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
device_data = config.get('device_data', None)
|
device_data = config.get('device_data', None)
|
||||||
@ -94,6 +97,7 @@ def get_devices(hass, config):
|
|||||||
|
|
||||||
return vera_switches
|
return vera_switches
|
||||||
|
|
||||||
|
|
||||||
def get_extra_device_data(device_data, device_id):
|
def get_extra_device_data(device_data, device_id):
|
||||||
""" Gets the additional configuration data by Vera device Id """
|
""" Gets the additional configuration data by Vera device Id """
|
||||||
if not device_data:
|
if not device_data:
|
||||||
@ -109,6 +113,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
""" Find and return Vera lights. """
|
""" Find and return Vera lights. """
|
||||||
add_devices(get_devices(hass, config))
|
add_devices(get_devices(hass, config))
|
||||||
|
|
||||||
|
|
||||||
class VeraSwitch(ToggleDevice):
|
class VeraSwitch(ToggleDevice):
|
||||||
""" Represents a Vera Switch """
|
""" Represents a Vera Switch """
|
||||||
is_on_status = False
|
is_on_status = False
|
||||||
@ -140,8 +145,10 @@ class VeraSwitch(ToggleDevice):
|
|||||||
|
|
||||||
if self.vera_device.is_trippable:
|
if self.vera_device.is_trippable:
|
||||||
last_tripped = self.vera_device.refresh_value('LastTrip')
|
last_tripped = self.vera_device.refresh_value('LastTrip')
|
||||||
trip_time_str = time.strftime("%Y-%m-%d %H:%M",
|
trip_time_str = time.strftime(
|
||||||
time.localtime(int(last_tripped)))
|
"%Y-%m-%d %H:%M",
|
||||||
|
time.localtime(int(last_tripped))
|
||||||
|
)
|
||||||
|
|
||||||
attr['Last Tripped'] = trip_time_str
|
attr['Last Tripped'] = trip_time_str
|
||||||
|
|
||||||
@ -173,4 +180,3 @@ class VeraSwitch(ToggleDevice):
|
|||||||
# because the vera has some lag in updating the device status
|
# because the vera has some lag in updating the device status
|
||||||
if (self.last_command_send + 5) < time.time():
|
if (self.last_command_send + 5) < time.time():
|
||||||
self.is_on_status = self.vera_device.is_switched_on()
|
self.is_on_status = self.vera_device.is_switched_on()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user