Skip to content

Items Analogue_Sensor_Items

ggodart edited this page Jan 1, 2021 · 3 revisions

AnalogSensor_Item

See original

SYNOPSIS

Declaration:

Items.mht

Defined in items.mht as

#
ANALOG_SENSOR, indoor-t, indoor_temp, house_owx, Sensors, temp, hot_alarm=85, cold_alarm=62

'indoor-t' is an identifier for the sensor that some other software will require to associate sensor data to this item.

'temp' is the sensor type. Currently, only 'temp' and 'humid' are supported. Additional types will be added in the future.

house_owx is the one-wire "conduit" that populates AnalogSensor_Items. Sensors is a group.

The tag=value data following "temp" are tokens. More info on use of tokens is described below.

  • Alternatively, if declaring via code:
  $indoor_temp = new AnalogSensor_Item('indoor-t', 'temp');

DESCRIPTION

This package provides a device-agnostic method of maintaining analog sensor measurement collection, contains derivative utilities and mechanisms for deriving state and/or associating action to sensor change.

INHERITS

Generic_Item

METHODS

Method Description
measurement(measurement,timestamp,skipdelta) updates the measurement data maintained by this item if measurement, etc are provided; otherwise the last measurement value is returned.
map_to_weather(weather_hash_memberi, graph_title) copies any measurement update to the Weather hash specified by weather_hash_member. If graph_title is supplied, it will replace the default graph title used by code/common/weather_rrd_update.pl to display titles. Note that if graph_title is used, then you must consistently use this with all sensors or specify the titles via the ini parm: weather_graph_sensor_names.
get_average_change_rate(number_samples) returns the average change rate over number_samples. In general, number_samples should be > 1 since a very low delta time between previous and current measurement can make the change rate artificially high. Specifying longer numbers will provide more smoothing. If fewer samples exist than number_samples, the existing number will be used.
apply_offset(offset) applies an offset to the measurement value. Enter a negative number to apply a negative offset. This is useful to compensate for linear temperature shifts.
token(tag,value) adds "value" as a "token" to be evaluated during state and/or event condition checks; or, returns "token" if only "tag" is supplied. A token is referenced in a condition using the syntax: $token_ where is tag. See tie_state_condition example below.
remove_token(tag) removes the token from use. IMPORTANT: do not remove a token before first removing all conditions that depend on it.
tie_state_condition(condition,state) registers a condition and state value to be evaluated each measurement update. If condition is true and the current item's state value is not "state", then the state value is changed to "state". Note that tieing more than one condition to the same state--while supported--is discouraged as the first condition that "wins" is used; no mechanism exists to determine the order of condition evaluation.
$indoor_temp->tie_state_condition('$measurement > 81 and $measurement < 84',hot);
# use tokens to that the condition isn't "hardwired" to a constant
$indoor_temp->token('danger_sp',85);
$indoor_temp->tie_state_condition('$measurement > $token_danger_sp',dangerhot);
In the above example, the state is changed to hot if it is not already hot AND the measurement is between 81 and 84. Similarly, the state is change to dangerhot if the state is not already dangerhot and exceeds 85 degrees. Note that the state will not change if the measurement is greater than 84 degrees--which is the "hot" condition--until it reaches the "dangerhot" condition. This example illustrates a 1 degree hysteresis (actually, greater than 1 degree if the measurement updates do not provide tenths or greater precision).
It is important to note in the above example that single quotes are used since the string "$measurement" must not be evaluated until the state condition is checked. There are a number of "built-in" condition variables which are referenced via tokens. The current set of tokens is:
$measurement - the current measurement value
$measurement_change - the difference between the previous value and the most recent value. Note that this may be 0.
$time_since_previous - the different in time between the previous value and the most recent value. The resolution is milliseconds.
$recent_change_rate - the average change rate over the last three samples
$state - the state of the item
measurement_change returns the most current change of measurement values
untie_state_condition(condition) unregisters condition. Unregisters all conditions if condition is not provided.
tie_event_condition(condition,event) registers a condition and an event. See tie_state_condition for an explanation of condition. event is the code or code reference to be evaluated if condition is true. Since tied event conditions are evaluated for every measurement update, be careful that the condition relies on change-oriented variables and/or that the internal logic of "event" ensure against more frequent execution than is desired.
untie_event_condition(condition) same as untie_state_condition except applied to tied event conditions.
id(id) sets id to id. Returns id if id not present.
type(type) set type to type (temp or humid). Returns type if not present.

INI PARAMETERS

NONE

AUTHOR

Gregg Liming gregg@limings.net

SEE ALSO

NONE

AnalogRangeSensor_Item

SYNOPSIS

Items.mht

Defined in items.mht as

#
ANALOG_SENSOR_R, attribute, object, xap instance, group, type, alert_lo, warning_low, warning_high, alert_high

'attribute' is an identifier for the sensor that some other software will require to associate sensor data to this item. 'type' is the sensor type. Currently, only 'temp' and 'humid' are supported from owx, and disk, network, cpu, temps, swap, and memory from sdx. Additional types will be added in the future. xap instance is the xap "conduit" that populates AnalogRangeSensor_Items. group is a group. The ranges work out as follows:

  state = alert_low    if measurement < alert_low
  state = warning_low  if alert_low < measurement < warning_low
  state = normal       if warning_low < measurement < warning_high
  state = warning_high if warning_high < measurement < alert_high
  state = alert_high   if measurement > alert_high

note if the sensor is not upper or lower bound, then the appropriate bounds should be omitted.

Alternatively, if declaring via code:

  $server_hda1 = new AnalogRangeSensor_Item('sda1.free', 'disk', 50000, 100000);
  $server_load = new AnalogRangeSensor_Item('loadavg1', 'cpu', , , 4, 6);

TODO:

More generic states if requested

DESCRIPTION

This package provides is a derivative AnalogSensor to provide 'range' type functionality.

INHERITS

AnalogSensor_Item

METHODS

UnDoc

INI PARAMETERS

NONE

AUTHOR

Gregg Liming / Howard Plato gregg@limings.net

SEE ALSO

NONE

AnalogAveraging_Item

SYNOPSIS

Items.mht

Defined in items.mht as

# first declare the sensors
  ANALOG_SENSOR, indoor1-t, indoor_temp1, house_owx, Sensors, temp
  ANALOG_SENSOR, indoor2-t, indoor_tem2p, house_owx, Sensors, temp

  # then, declare the averaging item:
  ANALOG_AVERAGE, indoor_temp1, indoor_temp, hot_alarm=85, cold_alarm=62
  ANALOG_AVERAGE, indoor_temp2, indoor_temp

Note that the use of tokens is applied on only the first declaration. Any token use on subsequent declarations is ignored.

DESCRIPTION

This package provides an ability to average measurement reports from multiple AnalogSensor_Items. Because it inherits from AnalogSensor_Items, all operations that AnalogSensor_Item permits are also supported.

INHERITS

AnalogSensor_Item

METHODS

Method Description
sensor_timeout(timeout) changes the default timeout from 3600 seconds to seconds. Any measurement report that exceeds the timeout is ignored for the purpose of averaging. This keeps "stale" measurements from adversely impacting averaging

INI PARAMETERS

NONE

AUTHOR

UNK

SEE ALSO

NONE

Clone this wiki locally