How to use the appdaemon.utils.log function in appdaemon

To help you get started, we’ve selected a few appdaemon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / appdaemon / appdaemon / hassapi.py View on Github external
def get_state(self, entity_id=None, attribute=None):
        utils.log(conf.logger, "DEBUG",
               "get_state: {}.{}".format(entity_id, attribute))
        device = None
        entity = None
        if entity_id is not None and "." in entity_id:
            if not self.entity_exists(entity_id):
                return None
        if entity_id is not None:
            if "." not in entity_id:
                if attribute is not None:
                    raise ValueError(
                        "{}: Invalid entity ID: {}".format(self.name, entity))
                device = entity_id
                entity = None
            else:
                device, entity = entity_id.split(".")
        with conf.ha_state_lock:
github home-assistant / appdaemon / appdaemon / hassapi.py View on Github external
def cancel_listen_event(self, handle):
        name = self.name
        utils.log(
            conf.logger, "DEBUG",
            "Canceling listen_event for {}".format(name)
        )
        with conf.callbacks_lock:
            if name in conf.callbacks and handle in conf.callbacks[name]:
                del conf.callbacks[name][handle]
            if name in conf.callbacks and conf.callbacks[name] == {}:
                del conf.callbacks[name]
github home-assistant / appdaemon / appdaemon / hassapi.py View on Github external
def cancel_listen_state(self, handle):
        name = self.name
        utils.log(
            conf.logger, "DEBUG",
            "Canceling listen_state for {}".format(name)
        )
        with conf.callbacks_lock:
            if name in conf.callbacks and handle in conf.callbacks[name]:
                del conf.callbacks[name][handle]
            if name in conf.callbacks and conf.callbacks[name] == {}:
                del conf.callbacks[name]
github home-assistant / appdaemon / appdaemon / hassapi.py View on Github external
def error(self, msg, level="WARNING"):
        msg = self._sub_stack(msg)
        utils.log(self._error, level, msg, self.name)
github home-assistant / appdaemon / appdaemon / hassapi.py View on Github external
def fire_event(self, event, **kwargs):
        utils.log(conf.logger, "DEBUG",
               "fire_event: {}, {}".format(event, kwargs))
        if conf.ha_key != "":
            headers = {'x-ha-access': conf.ha_key}
        else:
            headers = {}
        apiurl = "{}/api/events/{}".format(conf.ha_url, event)
        r = requests.post(
            apiurl, headers=headers, json=kwargs, verify=conf.certpath
        )
        r.raise_for_status()
        return r.json()
github home-assistant / appdaemon / appdaemon / admain.py View on Github external
def log(self, logger, level, msg, name=""):
        utils.log(logger, level, msg, name)
github home-assistant / appdaemon / appdaemon / hassapi.py View on Github external
def run_every(self, callback, start, interval, **kwargs):
        name = self.name
        now = utils.get_now()
        if start < now:
            raise ValueError("start cannot be in the past")
        utils.log(
            conf.logger, "DEBUG",
            "Registering run_every starting {} in {}s intervals for {}".format(
                 start, interval, name
            )
        )
        exec_time = start.timestamp()
        handle = utils.insert_schedule(name, exec_time, callback, True, None,
                                    interval=interval, **kwargs)
        return handle
github home-assistant / appdaemon / appdaemon / hassapi.py View on Github external
def run_at_sunrise(self, callback, **kwargs):
        name = self.name
        utils.log(conf.logger, "DEBUG",
               "Registering run_at_sunrise with kwargs = {} for {}".format(
                   kwargs, name))
        handle = self._schedule_sun(name, "next_rising", callback, **kwargs)
        return handle