Skip to content
Malene Trab edited this page Apr 16, 2024 · 2 revisions

Basic connection

from pyworxcloud import WorxCloud

cloud = WorxCloud("your@email", "password", "worx")

# Initialize connection
try:
    cloud.authenticate()
except AuthorizationError:
    # If invalid credentials are used, or something happend during
    # authorize, then exit
    exit(0)

# Connect to device with index 0 (devices are enumerated 0, 1, 2 ...)
# and do not verify SSL (False)
cloud.connect()

# Do your stuff

# Disconnect from the API
cloud.disconnect()

Print out latest state from the API

This can be done in 2 ways

Option 1:

from pyworxcloud import WorxCloud
from pprint import pprint

with WorxCloud("your@email","password","worx") as cloud:
    for _, device in cloud.devices.items():
        cloud.update(device.serial_number)
        pprint(vars(device))

Option 2:

from pyworxcloud import WorxCloud
from pprint import pprint

cloud = WorxCloud("your@email", "password", "worx")

# Initialize connection
try:
    cloud.authenticate()
except AuthorizationError:
    # If invalid credentials are used, or something happend during
    # authorize, then exit
    exit(0)

# Connect to device with index 0 (devices are enumerated 0, 1, 2 ...)
# and do not verify SSL (False)
cloud.connect()

# Read latest states received from the device
for _, device in cloud.devices.items():
    cloud.update(device.serial_number)

    # Print all vars and attributes of the cloud object
    pprint(vars(device))

# Disconnect from the API
cloud.disconnect()
Clone this wiki locally