PowerStationMonitor/openhab2/rules/dc_load_calc.rules
2022-02-09 09:55:09 +01:00

67 lines
1.8 KiB
Plaintext

rule "Reset DC Load Ah Wh Timer"
when
Item DC_Load_Set_Reset changed to ON
then
DC_Load_Amperehours.sendCommand("0");
DC_Load_Watthours.sendCommand("0");
DC_Load_Timer.sendCommand("0");
DC_Load_Set_Reset.sendCommand("OFF");
end
rule "Calculate DC Load Timer"
when
Time cron "* * * ? * * *"
then
if (DC_Load_OnOff.state == ON) {
val temp = (DC_Load_Timer.state as Number) + 1;
DC_Load_Timer.sendCommand(temp);
}
if (DC_Load_Timer.state == NULL || DC_Load_Timer.state == "") {
DC_Load_Timer.sendCommand("0");
}
end
rule "Calculate DC Load Power"
when
Item DC_Load_Voltage changed or Item DC_Load_Current changed
then
val temp = (DC_Load_Voltage.state as Number) * (DC_Load_Current.state as Number);
DC_Load_Power.sendCommand(temp);
end
rule "Calculate DC Load Amperehours"
when
Time cron "* * * ? * * *"
then
if (DC_Load_OnOff.state == ON) {
val temp = (DC_Load_Current.state as Number) / 3600;
DC_Load_Amperehours.sendCommand(temp + (DC_Load_Amperehours.state as Number));
}
if (DC_Load_Amperehours.state == NULL || DC_Load_Amperehours.state == "") {
DC_Load_Amperehours.sendCommand("0");
}
end
rule "Calculate DC Load Watthours"
when
Time cron "* * * ? * * *"
then
if (DC_Load_OnOff.state == ON) {
val temp = (DC_Load_Power.state as Number) / 3600;
DC_Load_Watthours.sendCommand(temp + (DC_Load_Watthours.state as Number));
}
if (DC_Load_Watthours.state == NULL || DC_Load_Watthours.state == "") {
DC_Load_Watthours.sendCommand("0");
}
end
rule "Stop Battery Discharge"
when
Item DC_Load_Voltage changed
then
if (DC_Load_Set_BattMode.state == ON) {
if (DC_Load_Voltage.state < DC_Load_Set_Batt_MinVoltage.state) {
DC_Load_Set_OnOff.sendCommand("OFF");
}
}
end