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 RPC is 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=False to use http instead off https. Set verify=False to skip the verification of the SSL cert.

Provide credentials via username and password if the Homegear server is secured by basic auth. It’s not possible to use authentication with an insecure connection (http)!

call(method_name, *args, **kwargs)[source]

Call the given method using the HTTPServer.

Parameters:
  • method_name – Method to be called
  • args – Arguments passed through
  • kwargs – Keyword arguments passed through
Returns:

Return value of the XML RPC method

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=False to use http instead off https. Set verify=False to skip the verification of the SSL cert.

Provide credentials via username and password if the Homegear server is secured by basic auth. It’s not possible to use authentication with an insecure connection (http)!

call(method_name, *args, **kwargs)[source]

Call the given method using the ServerProxy.

Parameters:
  • method_name – Method to be called
  • args – Arguments passed through
  • kwargs – Keyword arguments passed through
Returns:

Return value of the XML RPC method

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