Check that no configuration is provided (#3675)

This commit is contained in:
Fabian Affolter 2016-10-05 07:10:31 +02:00 committed by Paulus Schoutsen
parent b9b41d3855
commit dc53c21548

View File

@ -1,28 +1,35 @@
""" """
LIRC interface to receive signals from a infrared remote control. LIRC interface to receive signals from a infrared remote control.
This sensor will momentarily set state to various values as defined For more details about this component, please refer to the documentation at
in the .lintrc file which can be interpreted in home-assistant to https://home-assistant.io/components/lirc/
trigger various actions.
Sending signals to other IR receivers can be accomplished with the
shell_command component and the irsend command for now.
""" """
# pylint: disable=import-error # pylint: disable=import-error
import threading import threading
import time import time
import logging import logging
from homeassistant.const import (EVENT_HOMEASSISTANT_STOP, import voluptuous as vol
EVENT_HOMEASSISTANT_START)
from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_START)
DOMAIN = "lirc"
REQUIREMENTS = ['python-lirc==1.2.1'] REQUIREMENTS = ['python-lirc==1.2.1']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ICON = 'mdi:remote'
EVENT_IR_COMMAND_RECEIVED = 'ir_command_received'
BUTTON_NAME = 'button_name' BUTTON_NAME = 'button_name'
DOMAIN = 'lirc'
EVENT_IR_COMMAND_RECEIVED = 'ir_command_received'
ICON = 'mdi:remote'
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)
def setup(hass, config): def setup(hass, config):
"""Setup LIRC capability.""" """Setup LIRC capability."""
@ -65,20 +72,19 @@ class LircInterface(threading.Thread):
def run(self): def run(self):
"""Main loop of LIRC interface thread.""" """Main loop of LIRC interface thread."""
import lirc import lirc
_LOGGER.debug('LIRC interface thread started') _LOGGER.debug("LIRC interface thread started")
while not self.stopped.isSet(): while not self.stopped.isSet():
try: try:
code = lirc.nextcode() # list; empty if no buttons pressed code = lirc.nextcode() # list; empty if no buttons pressed
except lirc.NextCodeError: except lirc.NextCodeError:
_LOGGER.warning('Encountered error reading ' _LOGGER.warning("Error reading next code from LIRC")
'next code from LIRC')
code = None code = None
# interpret result from python-lirc # interpret result from python-lirc
if code: if code:
code = code[0] code = code[0]
_LOGGER.info('Got new LIRC code %s', code) _LOGGER.info("Got new LIRC code %s", code)
self.hass.bus.fire(EVENT_IR_COMMAND_RECEIVED, self.hass.bus.fire(
{BUTTON_NAME: code}) EVENT_IR_COMMAND_RECEIVED, {BUTTON_NAME: code})
else: else:
time.sleep(0.2) time.sleep(0.2)
lirc.deinit() lirc.deinit()