Version: 3.2.11

Math Transformation

Transforms the input by applying simple math on it.

The available transformations are

The values need to be either decimals or strings. For bit-wise operations hexadecimal notation (e.g. 0x67) or binary notation (e.g. 0b00010000) are supported for both, value and state.

Full Example

Example Items:

Number multiply "Value multiplied by [MULTIPLY(1000):%s]" { channel="<channelUID>" }
Number add "Value added [ADD(5.1):%s]" { channel="<channelUID>" }
Number secondsToMinutes "Time [DIVIDE(60):%s]" { channel="<channelUID>" }
Number subtracted "Value subtracted [ADD(-1):%s]" { channel="<channelUID>" }
Number bitand "Value bitor [BITOR(0x27):%s]" { channel="<channelUID>" }

// Usage as a Profile
Number multiply "Value multiplied by [%.1f]" { channel="<channelUID>" [profile="transform:MULTIPLY", multiplicand=1000] }
Number add "Value added [%.1f]" { channel="<channelUID>" [profile="transform:ADD", addend=5.1] }
Number secondsToMinutes "Time [%d]" { channel="<channelUID>" [profile="transform:DIVIDE, divisor=60] }
Number subtracted "Value subtracted [%.1f]" { channel="<channelUID>" [profile="transform:ADD", addend=-1] }
Number bitand "Value bitand [%s]" { channel="<channelUID>" [profile="transform:BITAND", mask="0b00010000"] }

Example in Rules:

transform("MULTIPLY", "1000")
transform("ADD", "5.1")
transform("DIVIDE", "60")
transform("ADD", "-1")
transform("BITXOR", "127")