Skip to main content

Weheat Backend client

Project description

Weheat backend client

This is a client for the Weheat backend. It is automatically generated from the OpenAPI specification.

Requirements.

Python 3.7+

Installation & Usage

You can install directly using:

pip install weheat

Then import the package:

import weheat

Getting Started

After installation, you can now use the client to interact with the Weheat backend.

import datetime
from keycloak import KeycloakOpenID  # install with pip install python-keycloak
from weheat import ApiClient, Configuration, HeatPumpApi, HeatPumpLogApi, EnergyLogApi

# input your information here
auth_url = 'https://auth.weheat.nl/auth/'
api_url = 'https://api.weheat.nl'
realm_name = 'Weheat'
my_client_id = 'WeheatCommunityAPI'  # client ID and secret provided by Weheat
my_client_secret = ''
username = ''  # username and password used for the online portal
password = ''
my_heat_pump_id = ''  # your heat pump UUID

# Get the access token from keycloak
keycloak_open_id = KeycloakOpenID(server_url=auth_url,
                                  client_id=my_client_id,
                                  realm_name=realm_name,
                                  client_secret_key=my_client_secret)

token_response = keycloak_open_id.token(username, password)
keycloak_open_id.logout(token_response['refresh_token'])

# Create the cinfiguration object
config = Configuration(host=api_url, access_token=token_response['access_token'])

# with the client the APIs can be accessed
with ApiClient(configuration=config) as client:
    # Getting all heat pumps that the user has access to
    response = HeatPumpApi(client).api_v1_heat_pumps_get_with_http_info()

    if response.status_code == 200:
        print(f'My heat pump: {response.data}')

    # Getting the latest log of the heat pump
    response = HeatPumpLogApi(client).api_v1_heat_pumps_heat_pump_id_logs_latest_get_with_http_info(
        heat_pump_id=my_heat_pump_id)

    if response.status_code == 200:
        print(f'My heat pump logs: {response.data}')

    # Getting the energy logs of the heat pump in a specific period
    # interval can be  "Minute", "FiveMinute", "FifteenMinute", "Hour", "Day", "Week", "Month", "Year"
    response = EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=my_heat_pump_id,
                                                                                       start_time=datetime.datetime(
                                                                                           2024, 6,
                                                                                           22, 0, 0,
                                                                                           0),
                                                                                       end_time=datetime.datetime(2024,
                                                                                                                  6, 22,
                                                                                                                  15, 0,
                                                                                                                  0),
                                                                                       interval='Hour')

    if response.status_code == 200:
        print(f'My energy logs: {response.data}')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weheat-2024.8.30.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

weheat-2024.8.30-py3-none-any.whl (52.6 kB view details)

Uploaded Python 3

File details

Details for the file weheat-2024.8.30.tar.gz.

File metadata

  • Download URL: weheat-2024.8.30.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for weheat-2024.8.30.tar.gz
Algorithm Hash digest
SHA256 ef9045d2028330f01ef232f306ed8c333a6d300a70300193a999ea74df23e914
MD5 38d06d2f2931965e1bd35aac3b714e55
BLAKE2b-256 92d9a99a0a5197d727b010ee38ef148f0ced02cffeb8fd470dde251d36f62cb1

See more details on using hashes here.

File details

Details for the file weheat-2024.8.30-py3-none-any.whl.

File metadata

  • Download URL: weheat-2024.8.30-py3-none-any.whl
  • Upload date:
  • Size: 52.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for weheat-2024.8.30-py3-none-any.whl
Algorithm Hash digest
SHA256 c96eb08dd809c9f9960f4a3b361dd98b1db6e2d5f21a31cd95904fd8b9df159e
MD5 b8d388f17322b73b7e02828be8dfc22a
BLAKE2b-256 0e6ebdb1904c2ca2df5914b29f41e99bbbdbc047212ab22541240e14e57247b4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page