openhab-addons/bundles/org.openhab.transform.vat
Jacob Laursen 4d47f33012
Initial contribution (#14529)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
2023-03-17 22:06:06 +01:00
..
src/main Initial contribution (#14529) 2023-03-17 22:06:06 +01:00
NOTICE Initial contribution (#14529) 2023-03-17 22:06:06 +01:00
pom.xml Initial contribution (#14529) 2023-03-17 22:06:06 +01:00
README.md Initial contribution (#14529) 2023-03-17 22:06:06 +01:00

VAT Transformation Service

The VAT Transformation Service adds VAT (Value-Added Tax) to a given input amount. The input string must be either an ISO 3166 alpha-2 country code or a percentage, i.e. numerical format.

Examples

Display

Number CurrentSpotPrice "Current Spot Price incl. VAT [VAT(12.5):%s]" <price>

In a Rule

Add Danish VAT to price:

var Number price = 499
logInfo("Price", "Price incl. VAT: " + transform("VAT", "DK", price.toString))

Usage as a Profile

The functionality of this TransformationService can also be used in a Profile on an ItemChannelLink. This is the most powerful usage since VAT will be added without providing any explicit country code, percentage or configuration. To use this, an .items file can be configured as follows:

Number CurrentSpotPrice "Current Spot Price" <price> { channel="<channelUID>" [profile="transform:VAT"] }

To override VAT percentage for configured system country:

Number CurrentSpotPrice "Current Spot Price" <price> { channel="<channelUID>" [profile="transform:VAT", percentage="12.5"] }

If VAT is not known for the configured country or the provided percentage is invalid, the default is 0%, so the input value will be put into the transformation without any changes.

Please note: This profile is a one-way transformation, i.e. only values from a device towards the item are changed, the other direction is left untouched.