- openHABian 3.4.2 on rPi4 with 4GB
Much to my surprise, I am getting this error.
2024-06-02 12:09:16.870 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'sppro_modbus-6' failed: An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.BooleanExtensions.operator_equals(boolean,boolean) on instance: null in sppro_modbus
I have reduced the rule for troubleshooting to:
val LOG_PREFIX = "Modbus."
var g_b_grid_off_detected = false
rule "Modbus: Switch OFF inverter 3 if grid is gone"
when
Item spm_AC_Source_Status received update or
Item spm_Battery_SoC changed
then
val RULE_ID = 06
// Exit for all stati other than grid OFF = 0
if (spm_AC_Source_Status.state != 0)
{
if (g_b_grid_off_detected == true)
{
g_b_grid_off_detected = false
logInfo(LOG_PREFIX + RULE_ID + ".01",
"Grid connection is......: ON")
}
return
}
end
I have no idea why this would create an error, as I am the same construct in other rules and it works there.
Now comes the kicker; if I take this rule out of one rule file (modbus), and put into another (test), it works.
If I comment the boolean operations/conditions, I have no error.
Any hints appreciated.
FYI, here the complete rule:
// switch OFF KACO #3
rule "Modbus: Switch OFF inverter 3 if grid is gone"
when
Item spm_AC_Source_Status received update or
Item spm_Battery_SoC changed
then
val RULE_ID = 06
// Exit for all stati other than grid OFF = 0
if (spm_AC_Source_Status.state != 0)
{
if (g_b_grid_off_detected == true)
{
g_b_grid_off_detected = false
logInfo(LOG_PREFIX + RULE_ID + ".01",
"Grid connection is......: ON")
}
return
}
if (g_b_grid_off_detected == false)
{
g_b_grid_off_detected = true
logInfo(LOG_PREFIX + RULE_ID + ".02",
"Grid connection is......: OFF")
}
// Exit if less than 1 W is generated by solar PV; basically no solar PV
// generation.
if ((grp_spm_AC_Coupled_Solar_Power.state as DecimalType).intValue < 1)
{
return
}
// Exit if the inverter is already OFF
if (DIN_Rail_Relay_03_ON_OFF_Switch.state == OFF)
{
return
}
// grid went offline
// Establish generation and load values
val SOLAR_PV_TOTAL = (grp_spm_AC_Coupled_Solar_Power.state as DecimalType).intValue
val AC_LOAD_POWER = (spm_AC_Load_Power.state as DecimalType).intValue
// Calculate how much power the battery can absorb
val BATTERY_CAPACITY = 20000
var missing_battery_capacity = Math::abs((BATTERY_CAPACITY
* (spm_Battery_SoC.state as DecimalType).intValue / 100)
- BATTERY_CAPACITY)
// Logic here: if total solar PV generation is greater than load, that
// is battery charging and load, then switch OFF inverter #3.
// Why? Because the outputs of inverter #1 and #2 are being limited by
// the Selectronic Inverter / Charger while #3 is not, because it does
// not have the limiting capability.
logInfo(LOG_PREFIX + RULE_ID + ".03", "SOLAR_PV_TOTAL..........: {}", SOLAR_PV_TOTAL)
logInfo(LOG_PREFIX + RULE_ID + ".04", "AC_LOAD_POWER...........: {}", AC_LOAD_POWER)
logInfo(LOG_PREFIX + RULE_ID + ".05", "missing_battery_capacity: {}", missing_battery_capacity)
// Charge power is constrained to 5kW; = 53 V * 100 A = 5300 W
// However, for a safety margin reduced to 5000
val MAXIMUM_CHARGE_POWER = 5000
if (missing_battery_capacity > MAXIMUM_CHARGE_POWER)
{
missing_battery_capacity = MAXIMUM_CHARGE_POWER
logInfo(LOG_PREFIX + RULE_ID + ".06",
"missing_battery_capacity: {}",
missing_battery_capacity)
}
if (SOLAR_PV_TOTAL > (AC_LOAD_POWER + missing_battery_capacity))
{
// Set visual alarm by switching LED light ON in red
Shed_KDL_Colour.sendCommand("10,100,30")
// Switch OFF inverter #3
DIN_Rail_Relay_03_ON_OFF_Switch.sendCommand(OFF)
// Send email
val mailActions = getActions("mail", "mail:smtp:argylecourt")
val mailSubject = "Alarm: Inverter #3 has been switched OFF!"
mailActions.sendMail
(
Const_Email_Admin.state.toString(),
mailSubject,
mailSubject
)
logWarn(LOG_PREFIX + RULE_ID + ".06", mailSubject)
}
end