OpenMotics Python SDK
Jump to navigation
Jump to search
The code for the Python SDK can be found at ....
Hello world
As a 'Hello world' example we will put output 1 in the ON state.
api = OpenMoticsCloudApi("user", "pass")
api.set_output(1, True)
We can do the same for a local gateway, without using the OpenMotics cloud:
api = OpenMoticsApi("OpenMotics.local", "user", "pass")
api.set_output(1, True)
All Gateway API functions can be called on an instance of OpenMoticsCloudApi and OpenMoticsApi.
Cloud api with multiple installations
If an OpenMotics cloud user has access to 1 installation, this installation will be selected by default. When the user access to multiple installations, the user will have to select the currently used installation. The following example selects the first installation.
api = OpenMoticsCloudApi("user", "pass")
installations = api.get_installations()
api.set_installation_id(installations[0]['id'])
get_installations() returns a list of dicts with the following keys: id (integer), name (String), version (String).