예제 #1
0
    SECRETS = None


__version__ = "1.3.18"

# Initialize the logger
LOGGER = logging.getLogger(__name__)

if variables_private is None:
    LOGGER.error("Couldn't access the private variables.")
if SECRETS is None:
    LOGGER.error("Couldn't access the API-Key and/or client-ID.")

PLUGIN = Plugin("Twitch", SECRETS is not None, LOGGER, __file__)

STREAM_LIST = context.get_children("media.twitch", default={})

FAILS = 0
# Fail-counter. Used to track consecutive fails of the plugin. Since the list
# of streams is accessed every minute it's not too bad if ine of the checks
# completely fails, as long as the following ones succeed again.
# As soon as the failcounter reaches 3 the user will be notified, before that
# he/she doesn't have to be bothered.


@subscribe_to(["system.onstart", "time.schedule.min"])
def check_followed_streams(key, data):
    """Check for new online streams on twitch.tv."""
    global FAILS

    def _fail(msg):
예제 #2
0
                              user="******",
                              password=PASSWORD)

    except IOError:
        LOGGER.error("Couldn't connect to a fritzbox at the default "
                         "address '192.168.178.1'!")
        FRITZBOX = None

    if FRITZBOX is not None:
        hosts = _get_hosts_info()
        if hosts is not []:
            authenticated = True

PLUGIN = Device("FritzBox", authenticated, LOGGER, __file__)

DEVICES_DICT = context.get_children("network.devices", default={})


def _status_update(device):
    status = "online" if int(device["status"]) else "offline"
    LOGGER.debug("Updating device %s", device["mac"])
    eventbuilder.eEvent(
        sender_id=PLUGIN.name,
        keyword="network.fritzbox.availability.{}.{}".format(
            status, device["name"]),
        data=device).trigger()
    context.set_property("network.devices.{}".format(device["mac"]), device)


@subscribe_to(["system.onstart", "time.schedule.10s"])
def update_devices(key, data):