ZUNO_METER()

This macro is a generic macro to be used to setup meter channel for Z-Uno board using ZUNO_SETUP_CHANNELS. Instead we suggest to use one of the specific macro ZUNO_METER_* from the list below. Z-Uno understands two ways to define a channel: using getter function and using a variable.
  • With getter definition the getter function is called each time a value is requested. This allows to do some calculus before returning a value.
  • With variable definition Z-Uno will automatically return the variable status. This allows to minimize your code.
ZUNO_METER(type, resettable, scale, size, precision, getter, resetter) type type of channel like ZUNO_METER_TYPE_ELECTRIC, ZUNO_METER_TYPE_GAS or ZUNO_METER_TYPE_WATER. Used to correctly display the meter in the Z-Wave controller. Full list is defined in ZUNO_Definitions.h and starts with ZUNO_METER_TYPE_ resettable METER_RESET_ENABLE (value can be set to zero via Z-Wave) or METER_RESET_DISABLE (value can not be set to zero). scale specific scale used for meter type. See ZUNO_Definitions.h for the full list. size size: 1, 2 or 4 bytes. precision precision (number of decimals after dot). getter pointer to a user defined function, which is supposed to return current value for this channel. resetter pointer to a user defined function, which is called on reset command to zero value. Functions getter should return current value using types BYTE (for size = 1), WORD (for size = 2) or DWORD (for size = 4) depending on size field defined in size parameter. In almost all most used macros the size is 4 and value type is DWORD. BYTE getter(void) Values returned by getter are signed. Values are interpreted according to the following transformation:
  • signed value = value / 10precision, for value < MAX_NUM/2
  • signed value = (value - MAX_NUM) / 10precision, for value ≥ MAX_NUM/2
Where MAX_NUM = 28*size and precision defined number of decimal digits after dot.
For example if size 1 and precision 0, value 25 represents 25,
for size 1 and precision 0, value 164 represents -92 = 164 - 256,
for size 1 and precision 1, value 25 represents 2.5 = 25 / 10,
for size 1 and precision 1, value 164 represents -9.2 = (164 - 256) / 10,
for size 2 and precision 1, value 366 represents 36.6,
for size 2 and precision 1, value 65535 represents -0.1 = (65535 - 65536) / 10,
for size 2 and precision 2, value 65535 represents -0.01 = (65535 - 65536) / 100.
Channel generated using this macro will have Z-Wave Device Class GENERIC_TYPE_METER / SPECIFIC_TYPE_ROUTING_METERL with Meter Command Class.
ZUNO_SETUP_CHANNELS(
    ZUNO_METER(
        ZUNO_METER_TYPE_WATER,
        METER_RESET_ENABLE,
        ZUNO_METER_WATER_SCALE_METERS3,
        METER_SIZE_FOUR_BYTES,
        METER_PRECISION_THREE_DECIMALS,
        getterFunction,
        resetterFunction
    )
);
           
void setup() {
    ...
}

void loop() {
    ...
}

DWORD getterFunction() {
    return currentValue;
}

void resetterFunction(byte v) {
    currentValue = 0;
}

ZUNO_METER(type, resettable, scale, size, precision, variable, NULL) type type of channel like ZUNO_METER_TYPE_ELECTRIC, ZUNO_METER_TYPE_GAS or ZUNO_METER_TYPE_WATER. Used to correctly display the meter in the Z-Wave controller. Full list is defined in ZUNO_Definitions.h and starts with ZUNO_METER_TYPE_ resettable METER_RESET_ENABLE (value can be set to zero via Z-Wave) or METER_RESET_DISABLE (value can not be set to zero). scale specific scale used for meter type. See ZUNO_Definitions.h for the full list. size size: 1, 2 or 4 bytes. precision precision (number of decimals after dot). variable variable that stores pointer the current value for this channel. variable type should correspond to size: BYTE (for size = 1), WORD (for size = 2) or DWORD (for size = 4). In almost all most used macros the size is 4 and value type is DWORD.
ZUNO_SETUP_CHANNELS(
    ZUNO_METER(
        ZUNO_METER_TYPE_WATER,
        METER_RESET_ENABLE,
        ZUNO_METER_WATER_SCALE_METERS3,
        METER_SIZE_FOUR_BYTES,
        METER_PRECISION_THREE_DECIMALS,
        meterValue,
        NULL
    )
);

DWORD meterValue = 0;

void setup() {
    ...
}

void loop() {
    ...
    meterValue++;
    ...
}

Popular sensor types have pre-defined macro. Few are listed below. Full list is defined in ZUNO_Definitions.h file and starts with ZUNO_METER_
ZUNO_METER_ELECTRIC_KWH(GETTER, RESETTER);
ZUNO_METER_GAS(GETTER, RESETTER);
ZUNO_METER_WATER(GETTER, RESETTER);