Device Templates

class festivalgrid.device_templates.device.DeviceTemplate(device)[source]

The base class for device templates.

Note

Usually you will only inherit from this class if you implement a new low level device template class like MQTTDevice.

__init__(device)[source]

Initialize a device template.

Args:

device (festivalgrid.models.Device): Device object instance.

digest_msg(msg)[source]

This method gets called whenever we fetch/receive a new message from a device. You must take care of parsing/interpreting the message and return a dict that can be stored into the time series database.

Args:

msg (str): The message that needs digesting

Returns:

bool:

True  -- Cut the power

Implement this if your device has a web admin interface.

Returns:

dict. Should return a dict with two keys:

title -- Title of the link
url   -- Full url to the device admin (e.g. http://192.168.1.4/admin)
notify_setup_change(model)[source]

This method gets called whenever a device’s configuration was changed (e.g. through the app or admin interface)

Args:

model (festivalgrid.models.Device): The device that was changed.

static provision(ip, stdout)[source]

This static method gets called when a user wants to auto-provision a device.

Args:

ip (str): The ip address of the device stdout (object): Use this to print messages to stdout (i.e. stdout.write('test'))

set_cut_power(state)[source]

Implement this if your device supports turning on/off it’s power state.

Returns:

bool:

True  -- Cut the power
False -- Restore power