API Reference¶
See Method Reference for all API methods.
GearClient¶
Client for the APIs provided by Homegear.
-
class
gearthonic.client.GearClient(host, port, protocol=0, **kwargs)[source]¶ Client for the APIs provided by Homegear.
Usage:
>>> gc = GearClient('localhost', 1234) >>> gc.device.list_devices()
The default communication protocol is
XML RPC. Additionally,JSON RPCis supported:>>> from gearthonic import JSONRPC >>> GearClient('localhost', 1234, protocol=JSONRPC)
Any protocol can accept additional parameters. Provide them while initialising the client:
>>> GearClient('localhost', 1234, protocol=JSONRPC, secure=False, username='ham')
For a full list of supported parameters, have a look at each protocol class or see the documentation for the protocols. :class:
-
call(method_name, *args, **kwargs)[source]¶ Call the given method using the instantiated protocol.
Parameters: - method_name – method to be called
- args – arguments passed through
- kwargs – keyword arguments passed through
Returns: return value of the call
-
device¶ Smart access to all device related API methods.
-
system¶ Smart access to all system related API methods.
-
Communication protocols¶
These classes are used to communicate with the different APIs provided by the Homegear server.
-
class
gearthonic.protocols.JsonRpcProtocol(host, port, secure=True, verify=True, username=None, password=None)[source]¶ Communicate with Homegear via JSON RPC.
>>> jp = JsonRpcProtocol('host.example.com', 2003) >>> jp.call('listDevices') [...]
Set
secure=Falseto usehttpinstead offhttps. Setverify=Falseto skip the verification of the SSL cert.Provide credentials via
usernameandpasswordif the Homegear server is secured by basic auth. It’s not possible to use authentication with an insecure connection (http)!
-
class
gearthonic.protocols.XmlRpcProtocol(host, port, secure=True, verify=True, username=None, password=None)[source]¶ Communicate with Homegear via XML RPC.
>>> xp = XmlRpcProtocol('host.example.com', 2003) >>> xp.call('listDevices') [...]
Set
secure=Falseto usehttpinstead offhttps. Setverify=Falseto skip the verification of the SSL cert.Provide credentials via
usernameandpasswordif the Homegear server is secured by basic auth. It’s not possible to use authentication with an insecure connection (http)!
-
gearthonic.protocols.initialise_protocol(protocol, host, port, **kwargs)[source]¶ Factory method to initialise a specific protocol.
Parameters: - protocol (int) – ID of the protocol to initialise
- host (str) – host of the server
- port (int) – port of the server
- kwargs – will be used to initialise the protocol
Return type: _ProtocolInterface