dripline.core.entity module

class dripline.core.entity.Entity(get_on_set=False, log_routing_key_prefix='sensor_value', log_interval=0, log_on_set=False, calibration=None, **kwargs)[source]

Bases: dripline.core.endpoint.Endpoint

Subclass of Endpoint which adds logic related to logging and confirming values.

In particular, there is support for: get_on_set -> setting the endpoint’s value returns a get() result rather than an empty success (particularly useful for devices which may round assignment values) log_on_set -> further extends get_on_set to send an alert message in addtion to returning the value in a reply log_interval -> leverages the scheduler class to log the on_get result at a regular cadence

Parameters
  • get_on_set – if true, calls to on_set are immediately followed by an on_get, which is returned

  • log_routing_key_prefix – first term in routing key used in alert messages which log values

  • log_interval – how often to log the Entity’s value. If 0 then scheduled logging is disabled; if a number, interpreted as number of seconds; if a dict, unpacked as arguments to the datetime.time_delta initializer; if a datetime.timedelta taken as the new value

  • log_on_set – if true, always call log_a_value() immediately after on_set Note: requires get_on_set be true, overrides must be equivalent

  • calibration (string || dict) – if string, updated with raw on_get() result via str.format() in @calibrate decorator, used to populate raw and calibrated values fields of a result payload. If a dictionary, the raw result is used to index the dict with the calibrated value being the dict’s value.

property get_on_set
log_a_value(the_value)[source]
property log_interval
property log_on_set
scheduled_log()[source]
start_logging()[source]
stop_logging()[source]