How does Unit Configuration module work?

Overview

ImperiHome comes with a Unit Configuration module available in the configuration contextual menu of sensors (temperature, wind, hydrometry, electricity ...).
This module allows you to set two optional properties that can be configured independently one from the other:

  • A formula that will be applied on the value received from the system.
  • The unit that will be displayed right after the value. 

 




While the unit is only plain text that will be displayed as is, the formula is an expression that will be evaluated by the system and thus has to respect a syntax.

Formula

This feature relies on exp4j which allows following operators and supports parenthesis:

  • Addition: +
  • Subtraction: -
  • Multiplication: *
  • Division: /
  • Exponentiation: ^
  • Modulo: %
  • absolute value: abs
  • arc cosine: acos
  • arc sine: asin
  • arc tangent: atan
  • cubic root: cbrt
  • nearest upper integer: ceil
  • cosine: cos
  • hyperbolic cosine: cosh
  • euler's number raised to the power (e^x): exp
  • nearest lower integer: floor
  • logarithmus naturalis (base e): log
  • sine: sin
  • hyperbolic sine: sinh
  • square root: sqrt
  • tangent: tan
  • hyperbolic tangent: tanh


To use the raw value retrieved from the system inside the formula, the keyword val must be used.

Example:
- Celsius to Fahrenheit formula: ((val * 9) / 5) + 32

Once a formula defined, it will be used each time the value from this sensor needs to be displayed (list view, dashboard view, graph ...)

If the formula is erroneous, it won't be recorded and a toast message will be displayed to inform you.

If the retrieved value from the system is not a double (a string for instance for custom sensor), and if a formula has been defined, ImperiHome will first try to convert the value to a double. If it fails, then the raw value will be used.

You can always erase a formula and retrieved default unit by pressing the "Reset" button in the dialog box.

Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Peter Stothers

    Hi. I have a sensor that is configured on my Vera 2 to detect when the garage door is up or down but it has to be added in MIOS as a lux sensor (long story) so when the door is down, Vera reports it as 0 lux. Can I use the Unit Configuration module to report <50% lux as 'Down' and >50% lux as 'UP'?

  • 0
    Avatar
    Michael

    Hello. Is it possible to use system variables like hours, minutes ... in the formula ?

    Thank you.

Please sign in to leave a comment.
Powered by Zendesk