Example #1
0
def call_service(api, domain, service, service_data=None):
    """Call a service at the remote API."""
    try:
        req = api(METHOD_POST, URL_API_SERVICES_SERVICE.format(domain, service), service_data)

        if req.status_code != 200:
            _LOGGER.error("Error calling service: %d - %s", req.status_code, req.text)

    except HomeAssistantError:
        _LOGGER.exception("Error calling service")
Example #2
0
def call_service(api, domain, service, service_data=None):
    """ Calls a service at the remote API. """
    try:
        req = api(METHOD_POST,
                  URL_API_SERVICES_SERVICE.format(domain,
                                                  service), service_data)

        if req.status_code != 200:
            _LOGGER.error("Error calling service: %d - %s", req.status_code,
                          req.text)

    except ha.HomeAssistantError:
        _LOGGER.exception("Error calling service")
Example #3
0
def call_service(api: API, domain: str, service: str,
                 service_data: Dict = None,
                 timeout: int = 5) -> None:
    """Call a service at the remote API."""
    try:
        req = api(METH_POST,
                  URL_API_SERVICES_SERVICE.format(domain, service),
                  service_data, timeout=timeout)

        if req.status_code != 200:
            _LOGGER.error("Error calling service: %d - %s",
                          req.status_code, req.text)

    except HomeAssistantError:
        _LOGGER.exception("Error calling service")