Giter Site home page Giter Site logo

Comments (2)

jacontre-c avatar jacontre-c commented on August 11, 2024

A possible fix , would be for the API function to return proper object containing the error status, tested in my setup, it works, and it may be applicable to other areas, but I don't know interaction with HA API:

def check_alarm_status(
    self, installation: Installation, referenceId: str
) -> CheckAlarmStatus:
    """Check status of the operation check alarm."""
    content = {
        "operationName": "CheckAlarmStatus",
        "variables": {
            "numinst": str(installation.number),
            "panel": installation.panel,
            "referenceId": referenceId,
            "idService": "11",
            "counter": 2,
        },
        "query": "query CheckAlarmStatus($numinst: String!, $idService: String!, $panel: String!, $referenceId: String!) {\n  xSCheckAlarmStatus(numinst: $numinst, idService: $idService, panel: $panel, referenceId: $referenceId) {\n    res\n    msg\n    status\n    numinst\n    protomResponse\n    protomResponseDate\n  }\n}\n",
    }
    response = self._execute_request(content)
    result_json = json.loads(response.text)
    if "errors" in result_json:
        error_message = result_json["errors"][0]["message"]
        #return error_message  <<<< THIS
        # _LOGGER.debug(result_json)
        return CheckAlarmStatus(
            "ERROR",
            error_message,
            "",
            "",
            "",
            "",
        )
    else:
        raw_data = result_json["data"]["xSCheckAlarmStatus"]
        return CheckAlarmStatus(
            raw_data["res"],
            raw_data["msg"],
            raw_data["status"],
            raw_data["numinst"],
            raw_data["protomResponse"],
            raw_data["protomResponseDate"],
        )

from securitas-direct-new-api.

guerrerotook avatar guerrerotook commented on August 11, 2024

Can you check this with the new release v1.1.0.0 I just publish, #33 ?

from securitas-direct-new-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.