OpenMotics Python SDK

From OpenMotics
Revision as of 11:12, 5 April 2014 by Fryckbos (talk | contribs) (Created page with "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. <syntaxhighlight lang="python"> api = Op...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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).