Skip to content

Conversation

@deric
Copy link

@deric deric commented Mar 31, 2022

Here' s a draft of API v2 support. Currently supports read-only queries. There will be definitely breaking changes (at least in authentication). When using GraphQL API we might add support for multiple controllers.

Example usage:

from hydrawiser.graphql import HydrawiserV2

hw = HydrawiserV2('<your email>', '<your hydrawise password>')
hw.controllers()

customer():

{
  "id": 123, # controller id
  "customerId": 99999,
  "name": "John Doe ",
  "email": "john@example.com",
  "validated": true,
  "controllers": [
    {
      "id": 11111,
      "name": "Garden",
      "deviceId": 123456
    }
  ]
}

controllers():

[
  {
    "id": 123, # controller id
    "name": "Garden",
    "online": true,
    "deviceId": 777,
    "wizardComplete": true,
    "hardware": {
      "serialNumber": "a3egafe1",
      "version": "hydrawise116",
      "status": "Linked",
      "installationDate": "Fri, 16 Jul 21 17:34:11 +0000"
    },
    "softwareVersion": "6.26",
    "boc": false,
    "lastAction": {
      "value": "Fri, 01 Apr 22 11:26:44 +0200",
      "timestamp": 1648805204
    }
  }
]

sensors():

[
  {
    "id": 123, # controller id
    "name": "Garden",
    "sensors": [
      {
        "id": 789456,
        "name": "Rainfall",
        "model": {
          "id": 4444,
          "name": "Rain Sensor (normally closed wire)",
          "modeType": "STOP",
          "active": true,
          "offLevel": 1,
          "offTimer": 0,
          "delay": 0,
          "divisor": 0,
          "flowRate": 0,
          "customerId": 0,
          "sensorType": "LEVEL_CLOSED",
          "category": {
            "name": "Hunter Clik"
          }
        }
      }
    ]
  }
]

zones():

[
  {
    "id": 123,
    "name": "Garden",
    "zones": [
      {
        "id": 100,
        "name": "Zone 1"
      },
      {
        "id": 101,
        "name": "Zone 2"
      }
    ]
  }
]

TODO:

  • Schedule running a zone
  • Suspend zone/relay
  • Retrieve sensor status
  • Update monitored attributes
  • Refresh OAuth2 token

This PR adds dependency on gql library, which seems to be a minimalistic GraphQL client, but Python 2 is no longer supported.

@ptcryan Is it ok to continue with implementation this way? The responses should be Python dict or JSON is preferred?

@deric deric mentioned this pull request Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant