Quickstart

Quickstart

The library is easy and straightforward to use - it has one main class that represents a Huskoll Device.

Obtain an access token

To use the API (and this library), you need to have an access token. According to the Huskoll API docs, you can obtain that by sending an email to [email protected].

Obtain your hardware ID

To use the API (and this library), you also need to obtain the Hardware ID for the device(s) you want to interract with. The Hardware ID is visible in the Huskoll App, and also on a sticker on the bottom of the Huskoll device. (at least in the devices I checked with, hardware version 1.3)

Installation

The Huskoll Python Library will soon be available via PyPi under the package name huskoll.

And now, to the code!

Below are some code examples which shows what you can do with the library. There are more parameters and functions available which might help a lot - make sure to check out the docs for the Device class and the Status class!

Initialization of devices

This code shows the standard three-liner initialization code for devices.
1
from huskoll import Huskoll
2
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
3
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
4
device = Huskoll.Device(token=TOKEN, hardware_id=HARDWARE_ID) #Create an object to work with the device. You can create as many of these as you want for multiple devices.
Copied!

Basic functions, executed one-by-one

This example shows the execution of some basic functions, one-by-one. Overwhelmed? Scroll a bit further down :)
1
from huskoll import Huskoll #Import the library
2
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
3
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
4
device = Huskoll.Device(token=TOKEN, hardware_id=HARDWARE_ID) #Create an object to work with the device
5
​
6
input("Press enter to turn off your heat pump.")
7
device.power_off() #Quick function to power off the device
8
input("Press enter to turn on your heat pump.")
9
device.power_on() #Quick function to power on the device
10
input("Press enter to change the heating mode to cooling.")
11
device.set_cooling() #Quick function to set the device heating mode to cooling
12
input("Press enter to change the heating mode to heating.")
13
device.set_heating() #Quick function to set the device heating mode to heating
14
input("Press enter to change the device temperature to 20.")
15
device.set_temp(20) #Quick function to set the device temperature to a set point
16
input("Press enter to decrease the device temperature by 2 steps.")
17
device.decrease_temperature(by=2) #Quick function to decrease the device temperature. The by-parameter indicates by how many steps the temperature should be decreased.
18
input("Press enter to increase the device temperature by 1 step.")
19
device.increase_temperature() #The by parameter does not have to be set here, since its default is 1.
Copied!

Update multiple parameters at once

This example shows how to update multiple parameters to Huskoll at once, limiting the number of API requests and making the code prettier.
1
from huskoll import Huskoll #Import the library
2
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
3
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
4
device = Huskoll.Device(token=TOKEN, hardware_id=HARDWARE_ID)
5
​
6
#A number of utility variables are provided by the library, and some of them are used below!
7
device.update_status(
8
new_power_status=device.POWER_ON,
9
new_temperature=23,
10
new_fan_speed=device.FAN_HIGH
11
) #Set the device power to on, the temperature to 23 degrees, and the fan speed to high. The rest (the heating mode) will be unchanged.
Copied!

Get device status

1
from huskoll import Huskoll #Import the library
2
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
3
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
4
device = Huskoll.Device(token=TOKEN, hardware_id=HARDWARE_ID) #Create an object to work with the device
5
​
6
device_status = device.get_status() #Get the device status
7
​
8
#Print out device status
9
print("Device status: ")
10
print(f"Power: {device_status.power}") #Print out the power status
11
print(f"Current mode: {device_status.mode}") #Print out the mode
12
print(f"Current set temperature: {device_status.current_set_point}") #Print out the current set temperature
13
print(f"Current environment temperature: {device_status.current_env_temperature}") #Print out the current environment temperature
Copied!
​