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 info@huskoll.se.

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.

from huskoll import Huskoll
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
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.

Basic functions, executed one-by-one

This example shows the execution of some basic functions, one-by-one. Overwhelmed? Scroll a bit further down :)

from huskoll import Huskoll #Import the library
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
device = Huskoll.Device(token=TOKEN, hardware_id=HARDWARE_ID) #Create an object to work with the device

input("Press enter to turn off your heat pump.")
device.power_off() #Quick function to power off the device
input("Press enter to turn on your heat pump.")
device.power_on() #Quick function to power on the device
input("Press enter to change the heating mode to cooling.")
device.set_cooling() #Quick function to set the device heating mode to cooling
input("Press enter to change the heating mode to heating.")
device.set_heating() #Quick function to set the device heating mode to heating
input("Press enter to change the device temperature to 20.")
device.set_temp(20) #Quick function to set the device temperature to a set point
input("Press enter to decrease the device temperature by 2 steps.")
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.
input("Press enter to increase the device temperature by 1 step.")
device.increase_temperature() #The by parameter does not have to be set here, since its default is 1.

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.

from huskoll import Huskoll #Import the library
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
device = Huskoll.Device(token=TOKEN, hardware_id=HARDWARE_ID)

#A number of utility variables are provided by the library, and some of them are used below!
device.update_status(
    new_power_status=device.POWER_ON,
    new_temperature=23,
    new_fan_speed=device.FAN_HIGH 
) #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.

Get device status

from huskoll import Huskoll #Import the library
TOKEN = "YOUR_TOKEN_HERE" #Replace this with your token
HARDWARE_ID = "YOUR_HARDWARE_ID_HERE" #Replace this with the hardware ID of the device you wish to control
device = Huskoll.Device(token=TOKEN, hardware_id=HARDWARE_ID) #Create an object to work with the device

device_status = device.get_status() #Get the device status

#Print out device status
print("Device status: ")
print(f"Power: {device_status.power}") #Print out the power status
print(f"Current mode: {device_status.mode}") #Print out the mode
print(f"Current set temperature: {device_status.current_set_point}") #Print out the current set temperature
print(f"Current environment temperature: {device_status.current_env_temperature}") #Print out the current environment temperature

Last updated