hi all
I have set up the following rule for controlling a heat resistance: ought to be on when fotovoltaic production is bigger than whole home comsumption.
the rule is the following:
Blockquote
rule “stufetta bagno”
when
Item ProduzioneFotovoltaico_Power changed or
Item gconsumotot changed
then
var Number energyDiff = (ProduzioneFotovoltaico_Power.state as Number) - (gconsumotot.state as Number)
if (energyDiff <= 0) {
PresaCinema.SendCommand(ON)
}
else if (energyDiff >= -5) {
PresaCinema.SendCommand(OFF)
Code fences would make this a little easier to read.
rule “stufetta bagno”
when
Item ProduzioneFotovoltaico_Power changed or
Item gconsumotot changed
then
var Number energyDiff = (ProduzioneFotovoltaico_Power.state as Number) - (gconsumotot.state as Number)
if (energyDiff <= 0) {
PresaCinema.SendCommand(ON)
}
else if (energyDiff >= -5) {
PresaCinema.SendCommand(OFF)
}
postUpdate(energyDiff)
end
Make the following changes:
rule “stufetta bagno”
Use standard double quotes ", not “ and ”
if (energyDiff <= 0) {
else if (energyDiff >= -5) {
Should be energyDiff.intValue
postUpdate(energyDiff)
You need to specify the item you want to update. For example: YourItem.postUpdate(energyDiff).