OH4: Script execution of rule failed

Hi,

I´m running OH 4.0.2 on a raspberry cm4
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
everything updated to the latest version yesterday.

Now I get an error in the log from a new rule:

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘rolladen_mit_sonne-1’ failed: The name ‘START’ cannot be resolved to an item or type; line 16, column 44, length 5 in rolladen_mit_sonne

the rule is

rule "Rollershutter Control based on Luminance"
when
    Item Helligkeit changed 
then
    if(Helligkeit.state instanceof Number) { 
        val int luminanceValue = (Helligkeit.state as Number).intValue()

        val int closeThreshold = 200 
        val int openThreshold = 500  

        if (luminanceValue < closeThreshold) {
            EG_Kueche_Rolladen.sendCommand(DOWN)
            EG_Kueche_Rolladen.sendCommand(START) 
        } else if (luminanceValue > openThreshold) {
            EG_Kueche_Rolladen.sendCommand(UP)
            EG_Kueche_Rolladen.sendCommand(START) 
        }

        if (luminanceValue < closeThreshold) {
            EG_Speis_Rolladen.sendCommand(DOWN)
            EG_Speis_Rolladen.sendCommand(START) 
        } else if (luminanceValue > openThreshold) {
            EG_Speis_Rolladen.sendCommand(UP)
            EG_Speis_Rolladen.sendCommand(START) 
        }

        if (luminanceValue < closeThreshold) {
            EG_Fernsehzimmer_Rollo.sendCommand(DOWN)
            EG_Fernsehzimmer_Rollo.sendCommand(START) 
        } else if (luminanceValue > openThreshold) {
            EG_Fernsehzimmer_Rollo.sendCommand(UP)
            EG_Fernsehzimmer_Rollo.sendCommand(START) 
        }
    } else {
        logWarn("Rollershutter Control", "Invalid luminance value: " + Helligkeit.state.toString)
    }
end

I use this in other rules for example

rule "Szene Urlaub Fenster rauf"
 when
         Time cron "0 27 07 * * ?"
 
 then
        EG_Fernsehzimmer_Rollo.sendCommand(UP)
         EG_Fernsehzimmer_Rollo.sendCommand(START)
end

and I don´t get any log and everything works expected. Any hint?

Many thanks
Paul

Accepted commands are UpDown, StopMove, Percent, Refresh

Hi,

thanks - I have this in my knx.things

 Type rollershutter      :       EG_Fernsehzimmer_Rollo   "Rollladen"     [ upDown="6/0/16", stopMove="6/0/17" ]

When I use the command UP or DOWN in a rule, nothing happens. It only works when I send a START command after it.
I also tried to send just “0” or “100” - maybe I´m doing something completely wrong.

Many thanks

Paul

Does your knx actuator has group adress for position ?

Maybe you mixed up the GA

upDown   ->  Long Movement (Langzeit) DPT 1.008
stopMove -> Short Movement (Kurzzeit) DPT 1.008
position -> absolute position (command and status) DPT 5.001

Long Movement is used to drive a shutter to open or to close.
Short Movement is used to drive a shutter to do a tiny step. If the shutter is in movement after a Long Movement command, a Short Movement command will result in a stop.

A modern shutter actuator has several CO (Commnication Objects) in addition to Long and Short Movement, if direct positioning is supported, you will find at least a Byte (DPT 5.001) for absolute position command and a Byte for abolute position status. A correct configuration may look like this:

Type rollershutter : ch1 "EG Fernsehzimmer" [ upDown="6/0/16", stopMove="6/0/17", position="5.001:6/018+<6/0/19" ]

You may not need to set the DPT.
Only if all four GA are set correctly, the rollershutter Item will work as expected, i.e. a command

UP -> Shutter moving up (opens)
DOWN -> Shutter moving down (closes)
STOP -> Shutter stops (if moving...)
0 -> Shutter completely opens
100 -> Shutter completely closes
50 -> Shutter closes to more or less two thirds (be aware that a shutter will set onto the windowsill and then fully close, therfor 50% is NOT half the window height)

Any stop will result in a status change to a number 0 to 100 (percent).

May thanks for your input. After spending the afternoon in debugging I found a solution.

rollershutter.sendCommand(START) 

doesn’t work anymore - in no rule. Something has been changed from OH 4.0.1 to 4.0.2.

rollershutter.sendCommand(DOWN) 
rollershutter.sendCommand(UP)

now works. I think it is now as it should be. Now this one works

rule "Rollershutter Control based on Luminance"
when
    Item Helligkeit changed 
then
    if(Helligkeit.state instanceof Number) { 
        val int luminanceValue = (Helligkeit.state as Number).intValue()

        val int closeThreshold = 200 
        val int openThreshold = 500  

        if (luminanceValue < closeThreshold) {
            EG_Kueche_Rolladen.sendCommand(DOWN)
        } else if (luminanceValue > openThreshold) {
            EG_Kueche_Rolladen.sendCommand(UP)
        }

        if (luminanceValue < closeThreshold) {
            EG_Speis_Rolladen.sendCommand(DOWN)
        } else if (luminanceValue > openThreshold) {
            EG_Speis_Rolladen.sendCommand(UP)
        }

        if (luminanceValue < closeThreshold) {
            EG_Fernsehzimmer_Rollo.sendCommand(DOWN)
        } else if (luminanceValue > openThreshold) {
            EG_Fernsehzimmer_Rollo.sendCommand(UP)
        }
    } else {
        logWarn("Rollershutter Control", "Invalid luminance value: " + Helligkeit.state.toString)
    }
end

Regarding the position I need to look into ETS and maybe change this. I don´t need it as I´m just going 0/100

Many thanks

Paul

A maybe more direct way:

rule "Rollershutter Control based on Luminance"
when
    Item Helligkeit changed
then
    if(!(Helligkeit.state instanceof Number)) {
        logWarn("rscontrol", "Invalid luminance value: {}", Helligkeit.state)
        return;
    }
    val iLuminance = (Helligkeit.state as Number).intValue 
    val iCloseThreshold = 200
    val iOpenThreshold  = 500

    if(iLuminance < iCloseThreshold) {
        EG_Kueche_Rolladen.sendCommand(DOWN)
        EG_Speis_Rolladen.sendCommand(DOWN)
        EG_Fernsehzimmer_Rollo.sendCommand(DOWN)
    } else if(iLuminance > iOpenThreshold) {
        EG_Kueche_Rolladen.sendCommand(UP)
        EG_Speis_Rolladen.sendCommand(UP)
        EG_Fernsehzimmer_Rollo.sendCommand(UP)
    }
end
1 Like

Hi,

I am experiencing a problem with this rule as it doesn`t allow me to manually open or close the rollershutters via knx anymore. If I want to close the rollershutter during the day the rule is firing and opening the rollershutter. This is clear as the luminance is above 500.
I have tried various things but I ran out of ideas how I could solve this in the code.

Many thanks for an hint

Paul

luminanceValue <= 500

no this doesn‘t change anything.

You misunderstood my ideea was to play with the limits to keep it within a certain lux margin so that afterwords it will not trigger again.
Maybe a more elegant solution:

var boolean upCommandSent = false
var boolean downCommandSent = false

rule "Rollershutter Control based on Luminance"
when
    Item Helligkeit changed 
then
    if(Helligkeit.state instanceof Number) { 
        val int luminanceValue = (Helligkeit.state as Number).intValue()

        val int closeThreshold = 200 
        val int openThreshold = 500  

        if (luminanceValue < closeThreshold && !downCommandSent) {
            EG_Kueche_Rolladen.sendCommand(DOWN)
            EG_Speis_Rolladen.sendCommand(DOWN)
            EG_Fernsehzimmer_Rollo.sendCommand(DOWN)
            downCommandSent = true 
            upCommandSent = false
        } 
        else if (luminanceValue >= openThreshold && !upCommandSent) {
            EG_Kueche_Rolladen.sendCommand(UP)
            EG_Speis_Rolladen.sendCommand(UP)
            EG_Fernsehzimmer_Rollo.sendCommand(UP)
            upCommandSent = true 
            downCommandSent = false
        }
    } else {
        logWarn("Rollershutter Control", "Invalid luminance value: " + Helligkeit.state.toString)
    }
end

Hi,

tested and works as expected. Many thanks very elegant.

Best

Paul

You should have a look at the profiles session of item configuration https://www.openhab.org/docs/configuration/items.html#profiles. Profile “hysteresis” lets you define an item with 3 states (lower closeThreshold, middle, greater openThreshold). Changes to this item are only triggered when your “Rolladen” should be closed or opened.

Hi,

thanks for the hint. Thats indeed very interesting.

Many thanks

Paul