Update docstrings (#7361)
* Update docstrings * Update docstrings * Update docstrings * Update docstrings * update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update tomato.py * Update isy994.py * Lint + fix tests * Lint
This commit is contained in:
1 parent
e22e70a01a
commit
3ee4d1060f
264 files changed
+1686
-1768
No files matched your search
@@ -4,7 +4,6 @@ Receive signals from a keyboard and use it as a remote control.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/keyboard_remote/
|
||||
"""
|
||||
|
||||
# pylint: disable=import-error
|
||||
import threading
|
||||
import logging
|
||||
@@ -15,24 +14,26 @@ import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import (
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
EVENT_HOMEASSISTANT_STOP
|
||||
)
|
||||
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP)
|
||||
|
||||
DOMAIN = "keyboard_remote"
|
||||
REQUIREMENTS = ['evdev==0.6.1']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEVICE_DESCRIPTOR = 'device_descriptor'
|
||||
DEVICE_ID_GROUP = 'Device descriptor or name'
|
||||
DEVICE_NAME = 'device_name'
|
||||
DOMAIN = 'keyboard_remote'
|
||||
|
||||
ICON = 'mdi:remote'
|
||||
|
||||
KEY_CODE = 'key_code'
|
||||
KEY_VALUE = {'key_up': 0, 'key_down': 1, 'key_hold': 2}
|
||||
KEYBOARD_REMOTE_COMMAND_RECEIVED = 'keyboard_remote_command_received'
|
||||
KEYBOARD_REMOTE_CONNECTED = 'keyboard_remote_connected'
|
||||
KEYBOARD_REMOTE_DISCONNECTED = 'keyboard_remote_disconnected'
|
||||
KEY_CODE = 'key_code'
|
||||
KEY_VALUE = {'key_up': 0, 'key_down': 1, 'key_hold': 2}
|
||||
TYPE = 'type'
|
||||
DEVICE_DESCRIPTOR = 'device_descriptor'
|
||||
DEVICE_NAME = 'device_name'
|
||||
DEVICE_ID_GROUP = 'Device descriptor or name'
|
||||
|
||||
TYPE = 'type'
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
@@ -45,12 +46,12 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup keyboard_remote."""
|
||||
"""Set up the keyboard_remote."""
|
||||
config = config.get(DOMAIN)
|
||||
|
||||
if not config.get(DEVICE_DESCRIPTOR) and\
|
||||
not config.get(DEVICE_NAME):
|
||||
_LOGGER.error('No device_descriptor or device_name found.')
|
||||
_LOGGER.error("No device_descriptor or device_name found")
|
||||
return
|
||||
|
||||
keyboard_remote = KeyboardRemote(
|
||||
@@ -91,10 +92,7 @@ class KeyboardRemote(threading.Thread):
|
||||
self.device_id = self.device_name
|
||||
self.dev = self._get_keyboard_device()
|
||||
if self.dev is not None:
|
||||
_LOGGER.debug(
|
||||
'Keyboard connected, %s',
|
||||
self.device_id
|
||||
)
|
||||
_LOGGER.debug("Keyboard connected, %s", self.device_id)
|
||||
else:
|
||||
id_folder = '/dev/input/by-id/'
|
||||
device_names = [InputDevice(file_name).name
|
||||
@@ -116,6 +114,7 @@ class KeyboardRemote(threading.Thread):
|
||||
self.key_value = KEY_VALUE.get(config.get(TYPE, 'key_up'))
|
||||
|
||||
def _get_keyboard_device(self):
|
||||
"""Get the keyboard device."""
|
||||
from evdev import InputDevice, list_devices
|
||||
if self.device_name:
|
||||
devices = [InputDevice(file_name) for file_name in list_devices()]
|
||||
@@ -132,14 +131,12 @@ class KeyboardRemote(threading.Thread):
|
||||
return None
|
||||
|
||||
def run(self):
|
||||
"""Main loop of the KeyboardRemote."""
|
||||
"""Run the loop of the KeyboardRemote."""
|
||||
from evdev import categorize, ecodes
|
||||
|
||||
if self.dev is not None:
|
||||
self.dev.grab()
|
||||
_LOGGER.debug(
|
||||
'Interface started for %s',
|
||||
self.dev)
|
||||
_LOGGER.debug("Interface started for %s", self.dev)
|
||||
|
||||
while not self.stopped.isSet():
|
||||
# Sleeps to ease load on processor
|
||||
@@ -152,8 +149,7 @@ class KeyboardRemote(threading.Thread):
|
||||
self.hass.bus.fire(
|
||||
KEYBOARD_REMOTE_CONNECTED
|
||||
)
|
||||
_LOGGER.debug('Keyboard re-connected, %s',
|
||||
self.device_id)
|
||||
_LOGGER.debug("Keyboard re-connected, %s", self.device_id)
|
||||
else:
|
||||
continue
|
||||
|
||||
@@ -164,8 +160,7 @@ class KeyboardRemote(threading.Thread):
|
||||
self.hass.bus.fire(
|
||||
KEYBOARD_REMOTE_DISCONNECTED
|
||||
)
|
||||
_LOGGER.debug('Keyboard disconnected, %s',
|
||||
self.device_id)
|
||||
_LOGGER.debug("Keyboard disconnected, %s", self.device_id)
|
||||
continue
|
||||
|
||||
if not event:
|
||||
|
||||
Reference in new issue
Block a user