'Run the loop of the LIRC interface thread.'

def run(self):

    import lirc
    _LOGGER.debug('LIRC    interface    thread    started')
    while (not self.stopped.isSet()):
        try:
            code = lirc.nextcode()
        except lirc.NextCodeError:
            _LOGGER.warning('Error    reading    next    code    from    LIRC')
            code = None
        if code:
            code = code[0]
            _LOGGER.info('Got    new    LIRC    code    %s', code)
            self.hass.bus.fire(EVENT_IR_COMMAND_RECEIVED, {BUTTON_NAME: code})
        else:
            time.sleep(0.2)
    lirc.deinit()
    _LOGGER.debug('LIRC    interface    thread    stopped')
