mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Resolve pylint errors and warnings
This commit is contained in:
parent
e6b4dba330
commit
91961e629f
@ -48,9 +48,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
add_devices(switches)
|
add_devices(switches)
|
||||||
|
|
||||||
def cleanup_gpio(event):
|
def cleanup_gpio(event):
|
||||||
|
""" Stuff to do before stop home assistant """
|
||||||
|
# pylint: disable=no-member
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
|
|
||||||
def prepare_gpio(event):
|
def prepare_gpio(event):
|
||||||
|
""" Stuff to do when home assistant starts"""
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gpio)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gpio)
|
||||||
|
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_gpio)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_gpio)
|
||||||
@ -66,6 +69,7 @@ class RPiGPIOSwitch(ToggleEntity):
|
|||||||
self._name = name or DEVICE_DEFAULT_NAME
|
self._name = name or DEVICE_DEFAULT_NAME
|
||||||
self._state = False
|
self._state = False
|
||||||
self._gpio = gpio
|
self._gpio = gpio
|
||||||
|
# pylint: disable=no-member
|
||||||
GPIO.setup(gpio, GPIO.OUT)
|
GPIO.setup(gpio, GPIO.OUT)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -96,15 +100,18 @@ class RPiGPIOSwitch(ToggleEntity):
|
|||||||
self.update_ha_state()
|
self.update_ha_state()
|
||||||
|
|
||||||
def _switch(self, new_state):
|
def _switch(self, new_state):
|
||||||
""" Execute the actual commands """
|
""" Change the output value to Raspberry Pi GPIO port """
|
||||||
_LOGGER.info('Setting GPIO %s to %s', self._gpio, new_state)
|
_LOGGER.info('Setting GPIO %s to %s', self._gpio, new_state)
|
||||||
|
# pylint: disable=bare-except
|
||||||
try:
|
try:
|
||||||
|
# pylint: disable=no-member
|
||||||
GPIO.output(self._gpio, 1 if new_state else 0)
|
GPIO.output(self._gpio, 1 if new_state else 0)
|
||||||
except:
|
except:
|
||||||
_LOGGER.error('GPIO "%s" output failed', self._gpio)
|
_LOGGER.error('GPIO "%s" output failed', self._gpio)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# pylint: disable=no-self-use
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
""" Returns device specific state attributes. """
|
""" Returns device specific state attributes. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user