Script not working anymore

Hi everyone,

I have a Fronius inverter with a script that sets a light green or red… after the latest update the script doesn’t load anymore and gives an error… probably something small but I cant find it …

rule "Set Red or Green"
when 
    Item FroniusSymoInverter_GridPower changed
then
    val offset = (FroniusSymoInverter_GridPower.state as QuantityType<Number>).doubleValue
    //logInfo("SOLAR","value -  " + offset)
    if (offset < 0) {
    //    logInfo("SOLAR","neagtive -  " + offset)
        sendCommand('velbusvmb4ryldAddress04_SolarRedGreen', "ON") 
        }else{
            sendCommand('velbusvmb4ryldAddress04_SolarRedGreen', "OFF")
        }
end

where the error is:
[el.core.internal.ModelRepositoryImpl] - Loading model ‘SolarRedGreen.rules’
[el.core.internal.ModelRepositoryImpl] - Configuration model ‘SolarRedGreen.rules’ has errors, therefore ignoring it: [7,9]: no viable alternative at input ‘offset’
input ‘offset’

t input ‘0’
t input ‘offset’
expecting ‘end’

source:

Change the variable name offset to something else like gridpower and it will work.

As you didn’t state what version you updated to or from I tested it on my system OH 4.3.3 and it worked.
I commented out your ON and OFF commands as I don’t have those.

rule "Test 1 2 3"

when Item FroniusSymoInverter_GridPower changed

then
    val gridpower = (FroniusSymoInverter_GridPower.state as QuantityType<Number>).doubleValue
    logInfo("SOLAR","value -  " + gridpower)
    if (gridpower < 0) {
        logInfo("SOLAR","neagtive -  " + gridpower)
    //    sendCommand('velbusvmb4ryldAddress04_SolarRedGreen', "ON")
        }else{
        logInfo("SOLAR","positive -  " + gridpower)
    //        sendCommand('velbusvmb4ryldAddress04_SolarRedGreen', "OFF")
        }
end

If I change the name to offset I got the same error as you did.

1 Like

You might like this I did as well.

I have a fronius inverter as well.