Esempio n. 1
0
    async def get(self, request, event):
        """Respond to requests from the device."""
        from aiohttp import web

        hass = request.app["hass"]

        token = request.query.get("token")

        device = get_doorstation_by_token(hass, token)

        if device is None:
            return web.Response(status=401, text="Invalid token provided.")

        if device:
            event_data = device.get_event_data()
        else:
            event_data = {}

        if event == "clear":
            hass.bus.async_fire(RESET_DEVICE_FAVORITES, {"token": token})

            message = f"HTTP Favorites cleared for {device.slug}"
            return web.Response(status=200, text=message)

        hass.bus.async_fire(f"{DOMAIN}_{event}", event_data)

        log_entry(hass, f"Doorbird {event}", "event was fired.", DOMAIN)

        return web.Response(status=200, text="OK")
Esempio n. 2
0
    def action():
        """ Action to be executed. """
        _LOGGER.info('Executing %s', name)
        logbook.log_entry(hass, name, 'has been triggered', DOMAIN)

        domain, service = split_entity_id(config[CONF_SERVICE])
        service_data = config.get(CONF_SERVICE_DATA, {})

        if not isinstance(service_data, dict):
            _LOGGER.error("%s should be a dictionary", CONF_SERVICE_DATA)
            service_data = {}

        if CONF_SERVICE_ENTITY_ID in config:
            try:
                service_data[ATTR_ENTITY_ID] = \
                    config[CONF_SERVICE_ENTITY_ID].split(",")
            except AttributeError:
                service_data[ATTR_ENTITY_ID] = \
                    config[CONF_SERVICE_ENTITY_ID]

        hass.services.call(domain, service, service_data)
Esempio n. 3
0
    def action():
        """ Action to be executed. """
        _LOGGER.info('Executing %s', name)
        logbook.log_entry(hass, name, 'has been triggered', DOMAIN)

        domain, service = split_entity_id(config[CONF_SERVICE])
        service_data = config.get(CONF_SERVICE_DATA, {})

        if not isinstance(service_data, dict):
            _LOGGER.error("%s should be a dictionary", CONF_SERVICE_DATA)
            service_data = {}

        if CONF_SERVICE_ENTITY_ID in config:
            try:
                service_data[ATTR_ENTITY_ID] = \
                    config[CONF_SERVICE_ENTITY_ID].split(",")
            except AttributeError:
                service_data[ATTR_ENTITY_ID] = \
                    config[CONF_SERVICE_ENTITY_ID]

        hass.services.call(domain, service, service_data)
Esempio n. 4
0
    def lockactivity(self, node, atype, aval):
        """ We have decoded a report (via alarms) from old Schlage locks """
        if atype == USER_CODE_ENTERED:
            codename = self.getcodename(node, aval)
            self.hass.bus.fire(EVENT_DOOR_CODE_ENTERED, {
                'node': node.name,
                'name': codename
            })
            logbook.log_entry(self.hass, node.name,
                              'User entered code {}'.format(codename))

        elif atype == TOO_MANY_FAILED_ATTEMPTS:
            self.hass.bus.fire(EVENT_DOOR_TOO_MANY_ATTEMPTS,
                               {'node': node.name})
            msg = 'Multiple invalid door codes entered at {}'.format(node.name)
            persistent_notification.create(self.hass, msg, 'Potential Prowler')
            _LOGGER.warning(msg)

        else:
            _LOGGER.warning(
                "Unknown lock alarm type! Investigate ({}, {}, {})".format(
                    node.node_id, atype, aval))
Esempio n. 5
0
 def action(variables=None):
     """Action to be executed."""
     _LOGGER.info('Executing %s', name)
     logbook.log_entry(hass, name, 'has been triggered', DOMAIN)
     script_obj.run(variables)
Esempio n. 6
0
 def action(variables=None):
     """Action to be executed."""
     _LOGGER.info('Executing %s', name)
     logbook.log_entry(hass, name, 'has been triggered', DOMAIN)
     script_obj.run(variables)
Esempio n. 7
0
    def action():
        """Action to be executed."""
        _LOGGER.info('Executing %s', name)
        logbook.log_entry(hass, name, 'has been triggered', DOMAIN)

        call_from_config(hass, config)
Esempio n. 8
0
    def action():
        """Action to be executed."""
        _LOGGER.info('Executing %s', name)
        logbook.log_entry(hass, name, 'has been triggered', DOMAIN)

        call_from_config(hass, config)