Interfaces

Braubuddy components are built upon Abstract Base Classes (abc):

braubuddy.thermometer.base Braubuddy thermometer exceptions and interface.
braubuddy.envcontroller.base Braubuddy envcontroller exceptions and interface.
braubuddy.thermostat.base Braubuddy thermostat interface.
braubuddy.output.base Braubuddy output template and interface.

To add support for a new component simply extend the appropriate ABC. Consult the source of an existing component to get started and don’t forget to contribute your new component back to the Braubuddy project when you’re done!

Thermometer

class braubuddy.thermometer.base.IThermometer

Interface for creating a thermometer for use with braudbuddy.

get_temperature(units='celsius')

Get thermometer temperature in celsius or farenheit.

Parameters:units (str) – Temperature units, ‘celsius’ (default) or ‘farenheit.’
Returns:Thermometer temperature reading
Return type:float
Raises:braubuddy.thermometer.ReadError if temperature can not be read.

EnvController

class braubuddy.envcontroller.base.IEnvController

Interface for creating an environmental controller for use with braubuddy.

get_power_levels()

Get heater and cooler power levels.

Returns:Heater and cooler power levels
Return type:tuple of (int <heater_power_level>, int <cooler_power_level>)
set_cooler_level(percent)

Set environmental controller’s cooler power level as a percentage of full power.

Parameters:percent – Cooler power level.
Raises:PercentageError if percent is invalid
set_heater_level(percent)

Set environmental controller’s heater power level as a percentage of full power.

Parameters:percent – Heater power level.
Raises:PercentageError if percent is invalid

Thermostat

class braubuddy.thermostat.base.IThermostat(target)

Initialise thermostat.

Parameters:target (float) – Target temperature.
get_required_state(temp, heater_percent, cooler_percent, units='celsius')

Get the required heater + cooler power levels given the current temperature and heater + cooler power levels.

This is the thermostat’s brain. Implement a clever and novel algorithm here.

Parameters:
  • temp (float) – Current temperature.
  • heater_percent (int in range(0-100)) – Current heater power level.
  • cooler (int in range (0-100)) – Current cooler power level.
  • units (str) – Temperature units in which to work. Use ‘celsius’ or ‘fahrenheit’.
Returns:

Required heater and cooler power levels.

Return type:

tuple of (int, int)

target

Get the target temperature.

Output

class braubuddy.output.base.IOutput(units='celsius')

Interface for creating an output for use with braubuddy.

Parameters:units (str) – Temperature units to output.
publish_status(target, temp, heater_percent, cooler_percent)

Publish braubuddy status

Parameters:
  • target (float) – Target temperature.
  • temp (float) – Current temperature.
  • heater_percent (float) – Current heater power level as percentage.
  • cooler_percent – Current cooler power level as percentage.
set_units(new_units)

Set units to output.

Parameters:units (str) – Temperature units to output.

Braubuddy

A temperature management framework written in Python.

Navigation