From 491c06f53bae28fcfe1bb2f791b2e4f3b7527a70 Mon Sep 17 00:00:00 2001 From: Nick Touran Date: Thu, 9 Jun 2016 20:53:41 -0700 Subject: [PATCH] Recover from rare error condition from LIRC (#2267) * More resilient accessing of LIRC codes to handle rare error case. * Line length fix in LIRC --- homeassistant/components/lirc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/lirc.py b/homeassistant/components/lirc.py index ec172d1b7f2413..ddb8b9542a5303 100644 --- a/homeassistant/components/lirc.py +++ b/homeassistant/components/lirc.py @@ -66,7 +66,12 @@ def run(self): """Main loop of LIRC interface thread.""" import lirc while not self.stopped.isSet(): - code = lirc.nextcode() # list; empty if no buttons pressed + try: + code = lirc.nextcode() # list; empty if no buttons pressed + except lirc.NextCodeError: + _LOGGER.warning('Encountered error reading ' + 'next code from LIRC') + code = None # interpret result from python-lirc if code: code = code[0]