Gateway Module Webservice API

From OpenMotics
Jump to: navigation, search

This page describes the Gateway API (exposed as a secure webservice on the OpenMotics Gateway). The response is a json-formatted dict, by default the dict contains the 'success' key which has a boolean value that indicates whether the API call was successfully executed. The documentation below show the return value in the following format: 'key': description. Eg. returns 'on': boolean means the full response is something like { 'success' : true, 'on' : false }.

Contents

Authentication

Most API calls require an authentication token, use the login call to get a token (tokens are valid for 1 hour).


WebInterface.login(username, password)

Login to the web service, returns a token if successful, returns HTTP status code 401 otherwise.
Parameters:
  • username (String) – Name of the user.
  • password (String) – Password of the user.
Returns: ‘token’ : String

User management is enabled when the gateway is in authorized mode (authorized mode can be enabled by pressing the white button on the gateway for more than 5 seconds). If the gateway is not in authorized mode, HTTP status code 401 is returned.


WebInterface.create_user(username, password)

Create a new user using a username and a password. Only possible in authorized mode.
Parameters:
  • username (String) – Name of the user.
  • password (String) – Password of the user.

WebInterface.get_usernames()

Get the names of the users on the gateway. Only possible in authorized mode.
Returns: ‘usernames’: list of usernames (String).

WebInterface.remove_user(username)

Remove a user. Only possible in authorized mode.
Parameters: username (String) – Name of the user to remove.

Master modules

These API functions return which modules are known by the OpenMotics master. Discover mode can be used to detect new modules on the bus (this is only for modules attached to the master, power modules use seperate API calls).


WebInterface.get_modules(token)

Get a list of all modules attached and registered with the master.
Returns: ‘output’: list of module types (O,R,D) and ‘input’: list of input module types (I,T,L).

WebInterface.module_discover_start(token)

Start the module discover mode on the master.
Returns: ‘status’: ‘OK’.

WebInterface.module_discover_stop(token)

Stop the module discover mode on the master.
Returns: ‘status’: ‘OK’.

WebInterface.flash_leds(token, type, id)

Flash the leds on the module for an output/input/sensor.
Parameters:
  • type (Integer) – The module type: output/dimmer (0), input (1), sensor/temperatur (2).
  • id (Integer) – The id of the output/input/sensor.
Returns: ‘status’: ‘OK’.

Output status

Below are the API functions for getting and setting the output status.


WebInterface.get_output_status(token)

Get the status of the outputs.
Returns: ‘status’: list of dictionaries with the following keys: id, status, dimmer and ctimer.

WebInterface.set_output(token, id, is_on, dimmer=None, timer=None)

Set the status, dimmer and timer of an output.
Parameters:
  • id (Integer [0, 240]) – The id of the output to set
  • is_on (Boolean) – Whether the output should be on
  • dimmer (Integer [0, 100] or None) – The dimmer value to set, None if unchanged
  • timer (Integer in (150, 450, 900, 1500, 2220, 3120)) – The timer value to set, None if unchanged

WebInterface.set_all_lights_off(token)

Turn all lights off.

WebInterface.set_all_lights_floor_off(token, floor)

Turn all lights on a given floor off.
Parameters: floor (Byte) – The id of the floor

WebInterface.set_all_lights_floor_on(token, floor)

Turn all lights on a given floor on.
Parameters: floor (Byte) – The id of the floor

Thermostat status

Below are the API functions for getting and setting the thermostat status.


WebInterface.get_thermostat_status(token)

Get the status of the thermostats.
Returns: global status information about the thermostats: ‘thermostats_on’,
::‘automatic’ and ‘setpoint’ and ‘status’: a list with status information for allthermostats, each element in the list is a dict with the following keys:‘id’, ‘act’, ‘csetp’, ‘output0’, ‘output1’, ‘outside’, ‘mode’.

WebInterface.set_current_setpoint(token, thermostat, temperature)

Set the current setpoint of a thermostat.
Parameters:
  • thermostat (Integer [0, 24]) – The id of the thermostat to set
  • temperature (float) – The temperature to set in degrees Celcius
Returns: ‘status’: ‘OK’.

WebInterface.set_thermostat_mode(token, thermostat_on, automatic, setpoint)

Set the mode of the thermostats. Thermostats can be on or off, automatic or manualand is set to one of the 6 setpoints.
Parameters:
  • thermostat_on (Boolean) – Whether the thermostats are on
  • automatic (Boolean) – Automatic mode (True) or Manual mode (False)
  • setpoint (Integer [0, 5]) – The current setpoint
Returns: ‘status’: ‘OK’.

WebInterface.get_sensor_temperature_status(token)

Get the current temperature of all sensors.
Returns: ‘status’: list of 32 temperatures, 1 for each sensor.

Other status


WebInterface.get_last_inputs(token)

Get the 5 last pressed inputs during the last 5 minutes.
Returns: ‘inputs’: list of tuples (input, output).

WebInterface.get_pulse_counter_status(token)

Get the pulse counter values.
Returns: ‘counters’: array with the 8 pulse counter values.

WebInterface.get_sensor_humidity_status(token)

Get the current humidity of all sensors.
Returns: ‘status’: List of 32 bytes, 1 for each sensor.

WebInterface.get_sensor_brightness_status(token)

Get the current brightness of all sensors.
Returns: ‘status’: List of 32 bytes, 1 for each sensor.

Configuration

Below are the API functions for getting and setting the OpenMotics Master configuration.


WebInterface.get_output_configuration(token, id, fields=None)

Get a specific output_configuration defined by its id.
Parameters:
  • id (Id) – The id of the output_configuration
  • fields (Json encoded list of strings) – The field of the output_configuration to get. (None gets all fields)
Returns: ‘config’: output_configuration dict: contains ‘id’ (Id), ‘floor’ (Byte), ‘module_type’ (String[1]), ‘name’ (String[16]), ‘timer’ (Word), ‘type’ (Byte)

WebInterface.get_output_configurations(token, fields=None)

Get all output_configurations.
Parameters: fields (Json encoded list of strings) – The field of the output_configuration to get. (None gets all fields)
Returns: ‘config’: list of output_configuration dict: contains ‘id’ (Id), ‘floor’ (Byte), ‘module_type’ (String[1]), ‘name’ (String[16]), ‘timer’ (Word), ‘type’ (Byte)

WebInterface.set_output_configuration(token, config)

Set one output_configuration.
Parameters: config (output_configuration dict: contains ‘id’ (Id), ‘floor’ (Byte), ‘name’ (String[16]), ‘timer’ (Word), ‘type’ (Byte)) – The output_configuration to set

WebInterface.set_output_configurations(token, config)

Set multiple output_configurations.
Parameters: config (list of output_configuration dict: contains ‘id’ (Id), ‘floor’ (Byte), ‘name’ (String[16]), ‘timer’ (Word), ‘type’ (Byte)) – The list of output_configurations to set

WebInterface.get_input_configuration(token, id, fields=None)

Get a specific input_configuration defined by its id.
Parameters:
  • id (Id) – The id of the input_configuration
  • fields (Json encoded list of strings) – The field of the input_configuration to get. (None gets all fields)
Returns: ‘config’: input_configuration dict: contains ‘id’ (Id), ‘action’ (Byte), ‘basic_actions’ (Actions[15]), ‘module_type’ (String[1]), ‘name’ (String[8])

WebInterface.get_input_configurations(token, fields=None)

Get all input_configurations.
Parameters: fields (Json encoded list of strings) – The field of the input_configuration to get. (None gets all fields)
Returns: ‘config’: list of input_configuration dict: contains ‘id’ (Id), ‘action’ (Byte), ‘basic_actions’ (Actions[15]), ‘module_type’ (String[1]), ‘name’ (String[8])

WebInterface.set_input_configuration(token, config)

Set one input_configuration.
Parameters: config (input_configuration dict: contains ‘id’ (Id), ‘action’ (Byte), ‘basic_actions’ (Actions[15]), ‘name’ (String[8])) – The input_configuration to set

WebInterface.set_input_configurations(token, config)

Set multiple input_configurations.
Parameters: config (list of input_configuration dict: contains ‘id’ (Id), ‘action’ (Byte), ‘basic_actions’ (Actions[15]), ‘name’ (String[8])) – The list of input_configurations to set

WebInterface.get_thermostat_configuration(token, id, fields=None)

Get a specific thermostat_configuration defined by its id.
Parameters:
  • id (Id) – The id of the thermostat_configuration
  • fields (Json encoded list of strings) – The field of the thermostat_configuration to get. (None gets all fields)
Returns: ‘config’: thermostat_configuration dict: contains ‘id’ (Id), ‘auto_fri’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_mon’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sat’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sun’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_thu’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_tue’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_wed’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘name’ (String[16]), ‘output0’ (Byte), ‘output1’ (Byte), ‘pid_d’ (Byte), ‘pid_i’ (Byte), ‘pid_int’ (Byte), ‘pid_p’ (Byte), ‘sensor’ (Byte), ‘setp0’ (Temp), ‘setp1’ (Temp), ‘setp2’ (Temp), ‘setp3’ (Temp), ‘setp4’ (Temp), ‘setp5’ (Temp)

WebInterface.get_thermostat_configurations(token, fields=None)

Get all thermostat_configurations.
Parameters: fields (Json encoded list of strings) – The field of the thermostat_configuration to get. (None gets all fields)
Returns: ‘config’: list of thermostat_configuration dict: contains ‘id’ (Id), ‘auto_fri’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_mon’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sat’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sun’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_thu’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_tue’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_wed’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘name’ (String[16]), ‘output0’ (Byte), ‘output1’ (Byte), ‘pid_d’ (Byte), ‘pid_i’ (Byte), ‘pid_int’ (Byte), ‘pid_p’ (Byte), ‘sensor’ (Byte), ‘setp0’ (Temp), ‘setp1’ (Temp), ‘setp2’ (Temp), ‘setp3’ (Temp), ‘setp4’ (Temp), ‘setp5’ (Temp)

WebInterface.set_thermostat_configuration(token, config)

Set one thermostat_configuration.
Parameters: config (thermostat_configuration dict: contains ‘id’ (Id), ‘auto_fri’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_mon’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sat’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sun’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_thu’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_tue’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_wed’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘name’ (String[16]), ‘output0’ (Byte), ‘output1’ (Byte), ‘pid_d’ (Byte), ‘pid_i’ (Byte), ‘pid_int’ (Byte), ‘pid_p’ (Byte), ‘sensor’ (Byte), ‘setp0’ (Temp), ‘setp1’ (Temp), ‘setp2’ (Temp), ‘setp3’ (Temp), ‘setp4’ (Temp), ‘setp5’ (Temp)) – The thermostat_configuration to set

WebInterface.set_thermostat_configurations(token, config)

Set multiple thermostat_configurations.
Parameters: config (list of thermostat_configuration dict: contains ‘id’ (Id), ‘auto_fri’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_mon’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sat’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_sun’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_thu’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_tue’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘auto_wed’ ([temp_n(Temp),start_d1(Time),stop_d1(Time),temp_d1(Temp),start_d2(Time),stop_d2(Time),temp_d2(Temp)]), ‘name’ (String[16]), ‘output0’ (Byte), ‘output1’ (Byte), ‘pid_d’ (Byte), ‘pid_i’ (Byte), ‘pid_int’ (Byte), ‘pid_p’ (Byte), ‘sensor’ (Byte), ‘setp0’ (Temp), ‘setp1’ (Temp), ‘setp2’ (Temp), ‘setp3’ (Temp), ‘setp4’ (Temp), ‘setp5’ (Temp)) – The list of thermostat_configurations to set

WebInterface.get_sensor_configuration(token, id, fields=None)

Get a specific sensor_configuration defined by its id.
Parameters:
  • id (Id) – The id of the sensor_configuration
  • fields (Json encoded list of strings) – The field of the sensor_configuration to get. (None gets all fields)
Returns: ‘config’: sensor_configuration dict: contains ‘id’ (Id), ‘name’ (String[16]), ‘offset’ (SignedTemp(-7.5 to 7.5 degrees))

WebInterface.get_sensor_configurations(token, fields=None)

Get all sensor_configurations.
Parameters: fields (Json encoded list of strings) – The field of the sensor_configuration to get. (None gets all fields)
Returns: ‘config’: list of sensor_configuration dict: contains ‘id’ (Id), ‘name’ (String[16]), ‘offset’ (SignedTemp(-7.5 to 7.5 degrees))

WebInterface.set_sensor_configuration(token, config)

Set one sensor_configuration.
Parameters: config (sensor_configuration dict: contains ‘id’ (Id), ‘name’ (String[16]), ‘offset’ (SignedTemp(-7.5 to 7.5 degrees))) – The sensor_configuration to set

WebInterface.set_sensor_configurations(token, config)

Set multiple sensor_configurations.
Parameters: config (list of sensor_configuration dict: contains ‘id’ (Id), ‘name’ (String[16]), ‘offset’ (SignedTemp(-7.5 to 7.5 degrees))) – The list of sensor_configurations to set

WebInterface.get_pump_group_configuration(token, id, fields=None)

Get a specific pump_group_configuration defined by its id.
Parameters:
  • id (Id) – The id of the pump_group_configuration
  • fields (Json encoded list of strings) – The field of the pump_group_configuration to get. (None gets all fields)
Returns: ‘config’: pump_group_configuration dict: contains ‘id’ (Id), ‘outputs’ (CSV[32])

WebInterface.get_pump_group_configurations(token, fields=None)

Get all pump_group_configurations.
Parameters: fields (Json encoded list of strings) – The field of the pump_group_configuration to get. (None gets all fields)
Returns: ‘config’: list of pump_group_configuration dict: contains ‘id’ (Id), ‘outputs’ (CSV[32])

WebInterface.set_pump_group_configuration(token, config)

Set one pump_group_configuration.
Parameters: config (pump_group_configuration dict: contains ‘id’ (Id), ‘outputs’ (CSV[32])) – The pump_group_configuration to set

WebInterface.set_pump_group_configurations(token, config)

Set multiple pump_group_configurations.
Parameters: config (list of pump_group_configuration dict: contains ‘id’ (Id), ‘outputs’ (CSV[32])) – The list of pump_group_configurations to set

WebInterface.get_group_action_configuration(token, id, fields=None)

Get a specific group_action_configuration defined by its id.
Parameters:
  • id (Id) – The id of the group_action_configuration
  • fields (Json encoded list of strings) – The field of the group_action_configuration to get. (None gets all fields)
Returns: ‘config’: group_action_configuration dict: contains ‘id’ (Id), ‘actions’ (Actions[16]), ‘name’ (String[16])

WebInterface.get_group_action_configurations(token, fields=None)

Get all group_action_configurations.
Parameters: fields (Json encoded list of strings) – The field of the group_action_configuration to get. (None gets all fields)
Returns: ‘config’: list of group_action_configuration dict: contains ‘id’ (Id), ‘actions’ (Actions[16]), ‘name’ (String[16])

WebInterface.set_group_action_configuration(token, config)

Set one group_action_configuration.
Parameters: config (group_action_configuration dict: contains ‘id’ (Id), ‘actions’ (Actions[16]), ‘name’ (String[16])) – The group_action_configuration to set

WebInterface.set_group_action_configurations(token, config)

Set multiple group_action_configurations.
Parameters: config (list of group_action_configuration dict: contains ‘id’ (Id), ‘actions’ (Actions[16]), ‘name’ (String[16])) – The list of group_action_configurations to set

WebInterface.get_scheduled_action_configuration(token, id, fields=None)

Get a specific scheduled_action_configuration defined by its id.
Parameters:
  • id (Id) – The id of the scheduled_action_configuration
  • fields (Json encoded list of strings) – The field of the scheduled_action_configuration to get. (None gets all fields)
Returns: ‘config’: scheduled_action_configuration dict: contains ‘id’ (Id), ‘action’ (Actions[1]), ‘day’ (Byte), ‘hour’ (Byte), ‘minute’ (Byte)

WebInterface.get_scheduled_action_configurations(token, fields=None)

Get all scheduled_action_configurations.
Parameters: fields (Json encoded list of strings) – The field of the scheduled_action_configuration to get. (None gets all fields)
Returns: ‘config’: list of scheduled_action_configuration dict: contains ‘id’ (Id), ‘action’ (Actions[1]), ‘day’ (Byte), ‘hour’ (Byte), ‘minute’ (Byte)

WebInterface.set_scheduled_action_configuration(token, config)

Set one scheduled_action_configuration.
Parameters: config (scheduled_action_configuration dict: contains ‘id’ (Id), ‘action’ (Actions[1]), ‘day’ (Byte), ‘hour’ (Byte), ‘minute’ (Byte)) – The scheduled_action_configuration to set

WebInterface.set_scheduled_action_configurations(token, config)

Set multiple scheduled_action_configurations.
Parameters: config (list of scheduled_action_configuration dict: contains ‘id’ (Id), ‘action’ (Actions[1]), ‘day’ (Byte), ‘hour’ (Byte), ‘minute’ (Byte)) – The list of scheduled_action_configurations to set

WebInterface.get_pulse_counter_configuration(token, id, fields=None)

Get a specific pulse_counter_configuration defined by its id.
Parameters:
  • id (Id) – The id of the pulse_counter_configuration
  • fields (Json encoded list of strings) – The field of the pulse_counter_configuration to get. (None gets all fields)
Returns: ‘config’: pulse_counter_configuration dict: contains ‘id’ (Id), ‘input’ (Byte), ‘name’ (String[16])

WebInterface.get_pulse_counter_configurations(token, fields=None)

Get all pulse_counter_configurations.
Parameters: fields (Json encoded list of strings) – The field of the pulse_counter_configuration to get. (None gets all fields)
Returns: ‘config’: list of pulse_counter_configuration dict: contains ‘id’ (Id), ‘input’ (Byte), ‘name’ (String[16])

WebInterface.set_pulse_counter_configuration(token, config)

Set one pulse_counter_configuration.
Parameters: config (pulse_counter_configuration dict: contains ‘id’ (Id), ‘input’ (Byte), ‘name’ (String[16])) – The pulse_counter_configuration to set

WebInterface.set_pulse_counter_configurations(token, config)

Set multiple pulse_counter_configurations.
Parameters: config (list of pulse_counter_configuration dict: contains ‘id’ (Id), ‘input’ (Byte), ‘name’ (String[16])) – The list of pulse_counter_configurations to set

WebInterface.get_startup_action_configuration(token, fields=None)

Get the startup_action_configuration.
Parameters: fields (Json encoded list of strings) – The field of the startup_action_configuration to get. (None gets all fields)
Returns: ‘config’: startup_action_configuration dict: contains ‘actions’ (Actions[100])

WebInterface.set_startup_action_configuration(token, config)

Set the startup_action_configuration.
Parameters: config (startup_action_configuration dict: contains ‘actions’ (Actions[100])) – The startup_action_configuration to set

WebInterface.get_dimmer_configuration(token, fields=None)

Get the dimmer_configuration.
Parameters: fields (Json encoded list of strings) – The field of the dimmer_configuration to get. (None gets all fields)
Returns: ‘config’: dimmer_configuration dict: contains ‘dim_memory’ (Byte), ‘dim_step’ (Byte), ‘dim_wait_cycle’ (Byte), ‘min_dim_level’ (Byte)

WebInterface.set_dimmer_configuration(token, config)

Set the dimmer_configuration.
Parameters: config (dimmer_configuration dict: contains ‘dim_memory’ (Byte), ‘dim_step’ (Byte), ‘dim_wait_cycle’ (Byte), ‘min_dim_level’ (Byte)) – The dimmer_configuration to set

WebInterface.get_global_thermostat_configuration(token, fields=None)

Get the global_thermostat_configuration.
Parameters: fields (Json encoded list of strings) – The field of the global_thermostat_configuration to get. (None gets all fields)
Returns: ‘config’: global_thermostat_configuration dict: contains ‘outside_sensor’ (Byte), ‘pump_delay’ (Byte), ‘threshold_temp’ (Temp)

WebInterface.set_global_thermostat_configuration(token, config)

Set the global_thermostat_configuration.
Parameters: config (global_thermostat_configuration dict: contains ‘outside_sensor’ (Byte), ‘pump_delay’ (Byte), ‘threshold_temp’ (Temp)) – The global_thermostat_configuration to set

Power modules


WebInterface.get_power_modules(token)

Get information on the power modules. The times format is a comma seperated list ofHH:MM formatted times times (index 0 = start Monday, index 1 = stop Monday,index 2 = start Tuesday, ...).
Returns: ‘modules’: list of dictionaries with the following keys: ‘id’, ‘name’, ‘address’, ‘input0’, ‘input1’, ‘input2’, ‘input3’, ‘input4’, ‘input5’, ‘input6’, ‘input7’, ‘sensor0’, ‘sensor1’, ‘sensor2’, ‘sensor3’, ‘sensor4’, ‘sensor5’, ‘sensor6’, ‘sensor7’, ‘times0’, ‘times1’, ‘times2’, ‘times3’, ‘times4’, ‘times5’, ‘times6’, ‘times7’.

WebInterface.set_power_modules(token, modules)

Set information for the power modules.
Parameters: modules – json encoded list of dicts with keys: ‘id’, ‘name’, ‘input0’, ‘input1’, ‘input2’, ‘input3’, ‘input4’, ‘input5’, ‘input6’, ‘input7’, ‘sensor0’, ‘sensor1’, ‘sensor2’, ‘sensor3’, ‘sensor4’, ‘sensor5’, ‘sensor6’, ‘sensor7’, ‘times0’, ‘times1’, ‘times2’, ‘times3’, ‘times4’, ‘times5’, ‘times6’, ‘times7’.

WebInterface.get_realtime_power(token)

Get the realtime power measurements.
Returns: module id as the keys: [voltage, frequency, current, power].

WebInterface.get_total_energy(token)

Get the total energy (Wh) consumed by the power modules.
Returns: modules id as key: [day, night].

WebInterface.start_power_address_mode(token)

Start the address mode on the power modules.

WebInterface.stop_power_address_mode(token)

Stop the address mode on the power modules.

WebInterface.in_power_address_mode(token)

Check if the power modules are in address mode.
Returns: ‘address_mode’: Boolean

WebInterface.set_power_voltage(token, module_id, voltage)

Set the voltage for a given module.
Parameters:
  • module_id (Byte) – The id of the power module.
  • voltage (Float) – The voltage to set for the power module.

Timezones


WebInterface.set_timezone(token, timezone)

Set the timezone for the gateway.
Parameters: timezone (String) – in format ‘Continent/City’.

WebInterface.get_timezone(token)

Get the timezone for the gateway.
Returns: ‘timezone’: the timezone in ‘Continent/City’ format (String).

Special actions


WebInterface.do_group_action(token, group_action_id)

Execute a group action.
Parameters: group_action_id (Integer [0, 159]) – The id of the group action

WebInterface.do_url_action(token, url, method='GET', headers=None, data=None, auth=None, timeout=10)

Execute an url action.
Parameters:
  • url (String) – The url to fetch.
  • method (String) – (optional) The http method (defaults to GET).
  • headers (String) – (optional) The http headers to send (format: json encoded dict)
  • data (String) – (optional) Bytes to send in the body of the request.
  • auth (String) – (optional) Json encoded tuple (username, password).
  • timeout (Integer) – (optional) Timeout in seconds for the http request (default = 10 sec).
Returns: ‘headers’: response headers, ‘data’: response body.

WebInterface.schedule_action(token, timestamp, action)

Schedule an action at a given point in the future. An action can be any function of theOpenMotics webservice. The action is JSON encoded dict with keys: ‘type’, ‘action’, ‘params’and ‘description’. At the moment ‘type’ can only be ‘basic’. ‘action’ contains the name ofthe function on the webservice. ‘params’ is a dict maps the names of the parameters given tothe function to their desired values. ‘description’ can be used to identify the scheduledaction.
Parameters:
  • timestamp (Integer.) – UNIX timestamp.
  • action (String.) – JSON encoded dict (see above).

WebInterface.list_scheduled_actions(token)

Get a list of all scheduled actions.
Returns: ‘actions’: a list of dicts with keys: ‘timestamp’, ‘from_now’, ‘id’, ‘description’ and ‘action’. ‘timestamp’ is the UNIX timestamp when the action will be executed. ‘from_now’ is the number of seconds until the action will be scheduled. ‘id’ is a unique integer for the scheduled action. ‘description’ contains a user set description for the action. ‘action’ contains the function and params that will be used to execute the scheduled action.

WebInterface.remove_scheduled_action(token, id)

Remove a scheduled action when the id of the action is given.
Parameters: id (Integer) – the id of the scheduled action to remove.

Maintenance functions


WebInterface.get_master_backup(token)

Get a backup of the eeprom of the master.
Returns: This function does not return a dict, unlike all other API functions: it returns a string of bytes (size = 64kb).

WebInterface.master_restore(token, data)

Restore a backup of the eeprom of the master.
Parameters: data (multipart/form-data encoded bytes (size = 64 kb).) – The eeprom backup to restore.
Returns: ‘output’: array with the addresses that were written.

WebInterface.get_errors(token)

Get the number of seconds since the last successul communication with the master andpower modules (master_last_success, power_last_success) and the error list per module(input and output modules). The modules are identified by O1, O2, I1, I2, ...
Returns: ‘errors’: list of tuples (module, nr_errors), ‘master_last_success’: UNIX timestamp of the last succesful master communication and ‘power_last_success’: UNIX timestamp of the last successful power communication.

WebInterface.master_clear_error_list(token)

Clear the number of errors.

WebInterface.get_version(token)

Get the version of the openmotics software.
Returns: ‘version’: String (a.b.c).

WebInterface.get_status(token)

Get the status of the master.
Returns: ‘time’: hour and minutes (HH:MM), ‘date’: day, month, year (DD:MM:YYYY), ‘mode’: Integer, ‘version’: a.b.c and ‘hw_version’: hardware version (Integer).

WebInterface.update(token, version, md5, update_data)

Perform an update.
Parameters:
  • version (String) – the new version number.
  • md5 (String) – the md5 sum of update_data.
  • update_data (multipart/form-data encoded byte string.) – a tgz file containing the update script (update.sh) and data.

WebInterface.get_update_output(token)

Get the output of the last update.
Returns: ‘output’: String with the output from the update script.

WebInterface.open_maintenance(token)

Open maintenance mode, return the port of the maintenance socket.
Returns: ‘port’: Port on which the maintenance ssl socket is listening (Integer between 6000 and 7000).

WebInterface.set_master_status_leds(token, status)

Set the status of the leds on the master.
Parameters: status – whether the leds should be on (true) or off (false).

WebInterface.factory_reset(token)

Reset the gateway to factory defaults.
Returns: ‘output’: dict with Factory reset comple

Plugin functions

Functions for getting the installed plugins, installing a plugin, removing a plugin and getting the logs for the installed plugins.


WebInterface.get_plugins(token)

Get the installed plugins.
Returns: ‘plugins’: dict with name, version and interfaces where name and version are strings and interfaces is a list of tuples (interface, version) which are both strings.

WebInterface.install_plugin(token, md5, package_data)

Install a new plugin. The package_data should include a __init__.py file andwill be installed in /opt/openmotics/python/plugins/name.
Parameters:
  • name (String) – Name of the plugin to install.
  • version (String) – Version of the plugin to install.
  • md5 (String) – md5 sum of the package_data.
  • update_data (multipart/form-data encoded byte string.) – a tgz file containing the content of the plugin package.

WebInterface.remove_plugin(token, name)

Remove a plugin. This removes the package data and configuration data of the plugin.
Parameters:
  • name – Name of the plugin to remove.
  • type – String

WebInterface.get_plugin_logs(token)

Get the logs for all plugins.
Returns: ‘logs’: dict with the names of the plugins as keys and the logs (String) as value.