Index

ValueConvert

  1. Description
  2. Configuration
  3. Example

Convert an event value and generate a new event from it.

Description

This event handler is typically used to convert the val attribute of an event using a simple offset and multiplier.

Configuration

The handler specific element in this case is called newEvent, this has two attributes for the new event type and source. Two additional attributes must be provided these are offset and multiplier. Following the syntax of EventMapper et al. The contents of the newEvent element may contain other_data and copy_other_data. other_data is used in the event verbatim whilst copy_other_data is used to select attributes from the old event and the newVal. If you want the converted number you should have a copy_other_data element. When an event is selected for processing the newVal attribute is the value of the old event minus the preoffset and then multiplied by the multiplier and then the ] postoffset is added.

The following can be achieved:

Example

<eventInterface module='EventHandlers.ValueConvert' name='ValueConvert'>
    <eventtype type=''>
        <eventsource source='webbrick/100/AI/0'>
            <event>
                <newEvent type='local/value' source='local/Humidity/0' offset='20' multiplier='1.4'>
                    <copy_other_data val="newVal"/>
                </newEvent>
            </event>
        </eventsource>
        <eventsource source='webbrick/100/AI/0'>
            <event>
                <newEvent type='local/value' source='local/Humidity/2' preoffset='20' postoffset='20' 
                            multiplier='1.4'>
                    <copy_other_data val="newVal"/>
                </newEvent>
            </event>
        </eventsource>
    </eventtype>
</eventInterface>

This example, assuming it has a humidity sensor attached, picks an analogue input from a webbrick and converts it into a relative humidity.