Dishwasher price calculation automation

Here is another rule example in the same category for a tumble dryer - using the Energi Data Service binding and VAT transformation:

rule "Tumble dryer final price"
when
    Item TumbleDryer_RawState changed to 7 // End
then
    val elapsedTime = (TumbleDryer_ElapsedTime.state as QuantityType<Number>).intValue
    val Instant endTime = now.toInstant()
    val Instant startTime = endTime.minusSeconds(elapsedTime * 60)

    logInfo("Tumble Dryer", "Calculating price for " + startTime.toString + " - " + endTime.toString)

    val actions = getActions("energidataservice", "energidataservice:service:energidataservice");
    var price = Float::parseFloat(transform("VAT", "DK", actions.calculatePrice(startTime, endTime, 667 | W).toString))
    sendPushMessage.apply("Tumble dryer", "Price for run program: " + String.format("%.2f", price) + " kr.")
end
2 Likes