toonapilib package

Submodules

toonapilib.configuration module

A place to store the configuration.

toonapilib.helpers module

All helper objects will live here.

class toonapilib.helpers.Agreement(id, checksum, heating_type, display_common_name, display_hardware_version, display_software_version, solar, toonly)

Bases: tuple

checksum

Alias for field number 1

display_common_name

Alias for field number 3

display_hardware_version

Alias for field number 4

display_software_version

Alias for field number 5

heating_type

Alias for field number 2

id

Alias for field number 0

solar

Alias for field number 6

toonly

Alias for field number 7

class toonapilib.helpers.Data(toon_instance)[source]

Data object exposing flow and graph attributes.

class Flow(toon_instance)[source]

Bases: toonapilib.helpers.TimeWindowRetriever

The object that exposes the flow information of categories in toon.

The information is rrd metrics

get_gas_time_window(from_datetime, to_datetime)[source]

Retrieves the gas flow for the provided time window.

Parameters:
  • from_datetime (str) – A string representing a date that dateparser can understand
  • to_datetime (str) – A string representing a date that dateparser can understand
Returns:

rrd response if returned

get_power_time_window(from_datetime, to_datetime)[source]

Retrieves the power flow for the provided time window.

Parameters:
  • from_datetime (str) – A string representing a date that dateparser can understand
  • to_datetime (str) – A string representing a date that dateparser can understand
Returns:

rrd response if returned

class Graph(toon_instance)[source]

Bases: toonapilib.helpers.TimeWindowRetriever

The object that exposes the graph information of categories in toon.

The information is rrd metrics and the object dynamically handles the accessing of attributes matching with the corresponding api endpoint if they are know, raises an exception if not.

get_district_heat_time_window(from_datetime, to_datetime, interval='hours')[source]

Retrieves the district heat graph for the provided time window.

Parameters:
  • from_datetime (str) – A string representing a date that dateparser can understand
  • to_datetime (str) – A string representing a date that dateparser can understand
  • interval (str) – A string representing the interval, one of [‘hours’, ‘days’, ‘weeks’, ‘months’, ‘years’]
Returns:

rrd response if returned

get_gas_time_window(from_datetime, to_datetime, interval='hours')[source]

Retrieves the gas graph for the provided time window.

Parameters:
  • from_datetime (str) – A string representing a date that dateparser can understand
  • to_datetime (str) – A string representing a date that dateparser can understand
  • interval (str) – A string representing the interval, one of [‘hours’, ‘days’, ‘weeks’, ‘months’, ‘years’]
Returns:

rrd response if returned

get_power_time_window(from_datetime, to_datetime, interval='hours')[source]

Retrieves the power graph for the provided time window.

Parameters:
  • from_datetime (str) – A string representing a date that dateparser can understand
  • to_datetime (str) – A string representing a date that dateparser can understand
  • interval (str) – A string representing the interval, one of [‘hours’, ‘days’, ‘weeks’, ‘months’, ‘years’]
Returns:

rrd response if returned

class toonapilib.helpers.Light(toon_instance, name)[source]

Bases: toonapilib.helpers.Switch

Object modeling the hue light bulbs that toon can interact with.

It inherits from switch which is the common interface with the hue lamps to turn on, off or toggle

rgb_color

The rgb color value of the light.

class toonapilib.helpers.Low(meter_reading_low, daily_usage_low)

Bases: tuple

daily_usage_low

Alias for field number 1

meter_reading_low

Alias for field number 0

class toonapilib.helpers.PowerUsage(average_daily, average, daily_cost, daily_usage, is_smart, meter_reading, value, meter_reading_low, daily_usage_low)

Bases: tuple

average

Alias for field number 1

average_daily

Alias for field number 0

daily_cost

Alias for field number 2

daily_usage

Alias for field number 3

daily_usage_low

Alias for field number 8

is_smart

Alias for field number 4

meter_reading

Alias for field number 5

meter_reading_low

Alias for field number 7

value

Alias for field number 6

class toonapilib.helpers.SmartPlug(toon_instance, name)[source]

Bases: toonapilib.helpers.Switch

Object modeling the fibaro smart plugs the toon can interact with.

It inherits from switch which is the common interface with the hue lamps to turn on, off or toggle

average_usage

The average power usage.

current_usage

The current power usage.

daily_usage

The daily power usage.

flow_graph_uuid

The uuid of the flow graph.

network_health_state

The state of the network health.

quantity_graph_uuid

The uuid of the quantity graph.

usage_capable

Boolean about the capability of the device to report power usage.

class toonapilib.helpers.SmokeDetector(device_uuid, name, last_connected_change, is_connected, battery_level, device_type)

Bases: tuple

battery_level

Alias for field number 4

device_type

Alias for field number 5

device_uuid

Alias for field number 0

is_connected

Alias for field number 3

last_connected_change

Alias for field number 2

name

Alias for field number 1

class toonapilib.helpers.Solar(maximum, produced, value, average_produced, meter_reading_low_produced, meter_reading_produced, daily_cost_produced)

Bases: tuple

average_produced

Alias for field number 3

daily_cost_produced

Alias for field number 6

maximum

Alias for field number 0

meter_reading_low_produced

Alias for field number 4

meter_reading_produced

Alias for field number 5

produced

Alias for field number 1

value

Alias for field number 2

class toonapilib.helpers.Switch(toon_instance, name)[source]

Core object to implement the turning on, off or toggle.

Both hue lamps and fibaro plugs have a switch component that is shared. This implements that usage.

can_toggle

Boolean about the capability of the device to toggle state.

current_state

The device’s current state.

device_type

The type of the device.

device_uuid

The uuid of the device.

in_switch_all_group

Boolean about whether the device is in a switch group.

in_switch_schedule

Boolean about whether the device is in a switch schedule.

is_connected

Boolean about the connection status of the device.

is_locked

Boolean about the lock state of the object.

name

The name of the device.

status

Returns the status of the device in a human friendly way.

toggle()[source]

Toggles the status of the device.

turn_off()[source]

Turns the device off.

turn_on()[source]

Turns the device on.

zwave_index

The zwave index of the device.

zwave_uuid

The zwave uuid.

class toonapilib.helpers.ThermostatInfo(active_state, boiler_connected, burner_info, current_displayed_temperature, current_modulation_level, current_set_point, error_found, have_ot_boiler, next_program, next_set_point, next_state, next_time, ot_communication_error, program_state, real_set_point)

Bases: tuple

active_state

Alias for field number 0

boiler_connected

Alias for field number 1

burner_info

Alias for field number 2

current_displayed_temperature

Alias for field number 3

current_modulation_level

Alias for field number 4

current_set_point

Alias for field number 5

error_found

Alias for field number 6

have_ot_boiler

Alias for field number 7

next_program

Alias for field number 8

next_set_point

Alias for field number 9

next_state

Alias for field number 10

next_time

Alias for field number 11

ot_communication_error

Alias for field number 12

program_state

Alias for field number 13

real_set_point

Alias for field number 14

class toonapilib.helpers.ThermostatState(name, id, temperature, dhw)

Bases: tuple

dhw

Alias for field number 3

id

Alias for field number 1

name

Alias for field number 0

temperature

Alias for field number 2

class toonapilib.helpers.TimeWindowRetriever(toon_instance)[source]

Object able to retrieve windows of time from endpoints.

class toonapilib.helpers.Usage(average_daily, average, daily_cost, daily_usage, is_smart, meter_reading, value)

Bases: tuple

average

Alias for field number 1

average_daily

Alias for field number 0

daily_cost

Alias for field number 2

daily_usage

Alias for field number 3

is_smart

Alias for field number 4

meter_reading

Alias for field number 5

value

Alias for field number 6

class toonapilib.helpers.User(client_id, client_secret, username, password)

Bases: tuple

client_id

Alias for field number 0

client_secret

Alias for field number 1

password

Alias for field number 3

username

Alias for field number 2

toonapilib.toonapilib module

Main code for toonapilib.

class toonapilib.toonapilib.Toon(authentication_token, tenant_id='eneco', display_common_name=None)[source]

Model of the toon smart meter from eneco.

burner_on

Boolean value of the state of the burner.

burner_state

The state the burner is in.

display_names

The ids of all the agreements.

Returns:A list of the agreement ids.
Return type:list
gas

A gas object modeled as a named tuple.

Type:return
get_light_by_name(name)[source]

Retrieves a light object by its name.

Parameters:name – The name of the light to return
Returns:A light object
get_smartplug_by_name(name)[source]

Retrieves a smartplug object by its name.

Parameters:name – The name of the smartplug to return
Returns:A smartplug object
get_smokedetector_by_name(name)[source]

Retrieves a smokedetector object by its name.

Parameters:name – The name of the smokedetector to return
Returns:A smokedetector object
get_thermostat_state_by_id(id_)[source]

Retrieves a thermostat state object by its id.

Parameters:id – The id of the thermostat state
Returns:The thermostat state object
get_thermostat_state_by_name(name)[source]

Retrieves a thermostat state object by its assigned name.

Parameters:name – The name of the thermostat state
Returns:The thermostat state object
lights

A list of light objects.

Type:return
power

A power object modeled as a named tuple.

Type:return
program_state

The active program state of the thermostat.

Returns:the program state
smartplugs

A list of smartplug objects.

Type:return
smokedetectors

A list of smokedetector objects modeled as named tuples.

Type:return
solar

A solar object modeled as a named tuple.

Type:return
status

The status of toon, cached for 300 seconds.

temperature

The current actual temperature as perceived by toon.

Returns:A float of the current temperature
thermostat

The current setting of the thermostat as temperature.

Returns:A float of the current setting of the temperature of the

thermostat

thermostat_info

A thermostatinfo object modeled as a named tuple.

Type:return
thermostat_state

The state of the thermostat programming.

Returns:A thermostat state object of the current setting
thermostat_states

The thermostat states of toon, cached for 1 hour.

toonapilib.toonapilibexceptions module

Custom exception code for toonapilib.

exception toonapilib.toonapilibexceptions.AgreementsRetrievalError[source]

Bases: exceptions.Exception

Could not retrieve agreements.

exception toonapilib.toonapilibexceptions.IncompleteStatus[source]

Bases: exceptions.Exception

The status received is missing vital information and is unusable.

exception toonapilib.toonapilibexceptions.InvalidAuthenticationToken[source]

Bases: exceptions.Exception

The authentication token provided was not accepted as valid.

exception toonapilib.toonapilibexceptions.InvalidDisplayName[source]

Bases: exceptions.Exception

The display name provided was not accepted as valid.

exception toonapilib.toonapilibexceptions.InvalidProgramState[source]

Bases: exceptions.Exception

The state provided to the program is not a valid one.

exception toonapilib.toonapilibexceptions.InvalidThermostatState[source]

Bases: exceptions.Exception

The state provided to the thermostat is not a valid one.

Module contents

toonapilib package.

Import all parts from toonapilib here