Switch without Power measure math

Thats my math:
PowerInLivingrooom.postUpdate((HIFI.state as Number) + (TV.state as Number))

if i have a swich without power measure. i know that there is power xxx watt.
Now i would like to add xxx to my livingroom power if the switch ist on.
does somebody have an idee?

The calculatuon of powerconsumption needs to take into account if the other powerswitch is off (unchanged calculation ) or on ( calculation + xxxx). A simple if clause would do.
Aditipnally you would to add a trigger for this calculaton in the change events of the powerswitch (in addition to the aleeady used triggers).

Take smaller steps to make it easier to think about.

trigger when this, that or other changed

var temp_power = this + that
if (other is ON) { temp_power = temp_power + some_constant }
someItem.postUpdate( temp_power)

In your real rule, you are going to have to take account about if any of your Items are quantity types e.g. with units, “35 W”

1 Like

that sounds good, but it dont work. something is wrong.
Maby you see the mistake:

rule “WohnzimmerWatt1”
var temp_power = (TVWohnzimmerSensorSwitchSensorSensorSensorSensorSensorSensorSensorSensorSensorSensor_TVWohnzimmerENERGYPower.state as Number) + (DreamHifi_Watt_DreamHifi.state as Number) + (AlexaUSBLadeSensorSensorSwitchSensorSensorSensorSensorSensorSensorSensorSensorSensor_AlexaUSBLadeENERGYPower.state as Number)
if (hue:0010:eedc7b10da:28.state == ON) { temp_power = temp_power + 23 }
if (hue:0010:eedc7b10da:28.state == OFF) { temp_power = temp_power}
Watt_Wohnzimmer.postUpdate(temp_power)
end

[WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘WohnzimmerWattTest.rules’ has errors, therefore ignoring it: [3,1]: mismatched input ‘var’ expecting ‘when’

The errror is telling you what is wrong, your rule is missing the when section.
As srate by @rossko57 the second if statement does nothing!

Btw:Nice itemnamesnamesnames

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.