from maxcube.cube import MaxCube
from maxcube.device import (
    MAX_DEVICE_MODE_AUTOMATIC,
    MAX_DEVICE_MODE_MANUAL,
    MAX_THERMOSTAT,
    MAX_THERMOSTAT_PLUS,
    MAX_WALL_THERMOSTAT,
    MAX_WINDOW_SHUTTER,
)

cube = MaxCube("192.168.0.20", 62910)

print("Serial: %s" % (cube.serial))
for room in cube.rooms:
    print("Room: " + room.name)
    for device in cube.devices_by_room(room):
        print("Device: " + device.name)

print("")

for device in cube.devices:
    if device.type == MAX_THERMOSTAT:
        type = "MAX_THERMOSTAT"
    elif device.type == MAX_THERMOSTAT_PLUS:
        type = "MAX_THERMOSTAT_PLUS"
    elif device.type == MAX_WINDOW_SHUTTER:
        type = "MAX_WINDOW_SHUTTER"
    elif device.type == MAX_WALL_THERMOSTAT:
        type = "MAX_WALL_THERMOSTAT"
    print("Type:   " + type)
    print("RF:     " + device.rf_address)
    print("Room ID:" + str(device.room_id))
    print("Room:   " + cube.room_by_id(device.room_id).name)
    print("Name:   " + device.name)
    print("Serial: " + device.serial)

    if device.type == MAX_THERMOSTAT:
        print("MaxSetP:" + str(device.max_temperature))
        print("MinSetP:" + str(device.min_temperature))
        if device.mode == MAX_DEVICE_MODE_AUTOMATIC:
            mode = "AUTO"
        elif device.mode == MAX_DEVICE_MODE_MANUAL:
            mode = "MANUAL"
        print("Mode:   " + mode)
        print("Actual: " + str(device.actual_temperature))
        print("Target: " + str(device.target_temperature))

    if device.type == MAX_WALL_THERMOSTAT:
        print("MaxSetP:" + str(device.max_temperature))
        print("MinSetP:" + str(device.min_temperature))
        if device.mode == MAX_DEVICE_MODE_AUTOMATIC:
            mode = "AUTO"
        elif device.mode == MAX_DEVICE_MODE_MANUAL:
            mode = "MANUAL"
        print("Mode:   " + mode)
        print("Actual: " + str(device.actual_temperature))
        print("Target: " + str(device.target_temperature))

    if device.type == MAX_WINDOW_SHUTTER:
        print("IsOpen: " + str(device.is_open))

    print("")

for device in cube.devices:
    print(device)
    if cube.is_wallthermostat(device) or cube.is_thermostat(device):
        print("Setting temp")
        cube.set_target_temperature(device, 8)
    else:
        print("No Thermostat")

print("")

for device in cube.devices:
    print(device)
    if cube.is_wallthermostat(device):
        print("Setting mode")
        cube.set_mode(device, MAX_DEVICE_MODE_MANUAL)
    else:
        print("No Wall Thermostat")

@@ -1,20 +1,31 @@
+import os%0A%0A
 from maxcube.cube im
@@ -237,16 +237,45 @@
 MaxCube(
+os.environ.get(%22MAXCUBE_IP%22, 
 %22192.168
@@ -280,16 +280,17 @@
 68.0.20%22
+)
 , 62910)
@@ -2152,35 +2152,37 @@
 (device)%0A    if 
-cub
+devic
 e.is_wallthermos
@@ -2189,22 +2189,18 @@
 tat(
+) or 
 devic
-e) or cub
 e.is
@@ -2203,38 +2203,32 @@
 e.is_thermostat(
-device
 ):%0A        print
@@ -2397,19 +2397,21 @@
 %0A    if 
-cub
+devic
 e.is_wal
@@ -2422,22 +2422,16 @@
 rmostat(
-device
 ):%0A     

Update sample code