What am I doing wrong ?
I have an energy meter, I count energy day and energy total. I want to count and display the sum of energy, where the price of 1 kW is 0.65 $ .
.sitemap
Text item=Dziszejsza label="Energia na dziś [%.3f kWh]" icon="my_volt" // *ENERGY.Today*
Text item=Wczorajsza label="Energia Wczoraj [%.3f kWh]" icon="my_volt" // *ENERGY.Yesterday*
Text item=Calosc label="Energia całość [%.3f kWh]" icon="my_volt" // **ENERGY.Total**
Text item=Zarobek // 1kW is 0,65 $
.items
Number Zarobek "Zarobek Tauron [%.2f $]"
.rules
import java.lang.Object
import org.eclipse.smarthome.core.items.GenericItem
import org.eclipse.smarthome.core.library.items.StringItem
import java.lang.Math.*
import org.openhab.core.library.types.DecimalType
val Koszt = 0.65
rule "tauron"
when
Item Calosc received update
then
var Number Zarobek = ( Koszt * Calosc.state as Number )
logInfo("AUTOMATION", "Zarobek = " + Zarobek)
logInfo("AUTOMATION", "Sama calosc = " + Calosc )
logInfo("AUTOMATION", "Sama calosc = " + Calosc.state as Number)
Zarobek.sendCommand(Calosc.state as Number * 0.65 )
end
log
2021-08-18 22:33:03.382 [INFO ] [se.smarthome.model.script.AUTOMATION] - Zarobek = 3.9416
2021-08-18 22:33:03.388 [INFO ] [se.smarthome.model.script.AUTOMATION] - Sama calosc = Calosc (Type=NumberItem, State=6.064, Label=Wyprodukowana całość, Category=null)
2021-08-18 22:33:03.394 [INFO ] [se.smarthome.model.script.AUTOMATION] - Sama calosc = 6.064
2021-08-18 22:33:03.397 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘tauron’: ‘sendCommand’ is not a member of ‘java.lang.Number’; line 21, column 9, length 51