Using excess pv power for doing something

hello so been testing this script for some time but i still cannot find any solution for the constant on and off .
This script is as follows

rule "put some load on the system if the production is high"
when
    Item Grid_load changed
then
    if(Grid_load.averageSince(now.minusMinutes(20)) > -800.0 |"W" && Boiler_technical_room.state == ON){
        Boiler_technical_room.sendCommand(OFF)
        logWarn("load", "to low production boiler OFF")
        } if(Grid_load.averageSince(now.minusMinutes(10)) >= 2000.0 |"W" && Boiler_technical_room.state == OFF){
                    Boiler_technical_room.sendCommand(ON)
                    logWarn("load", "high production boiler ON")
                }
    
end

Some explaining
the Grid_load is a number that can go from positive to negative positive mean export to the grid negative taking from the grid
and in the logs it goes crazy something like this

β”‚2022-10-04 17:02:23.100 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:02:28.865 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:02:34.503 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:02:40.254 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:02:45.883 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:02:51.664 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:02:57.289 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:03:03.043 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:03:08.687 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:03:14.449 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:03:20.101 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:03:25.734 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:03:31.363 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:03:37.103 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:03:42.850 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:03:48.468 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:03:54.216 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:03:59.957 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:04:05.618 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:04:11.362 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:04:16.996 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:04:22.743 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:04:28.385 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:04:34.131 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:04:39.777 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:04:45.522 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:04:51.164 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:04:56.927 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:05:02.565 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:05:08.332 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:05:13.852 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:05:19.594 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF                                                                                                          β”‚β”‚2022-10-04 17:05:25.339 [WARN ] [org.openhab.core.model.script.load  ] - high production boiler ON                                                                                                             β”‚β”‚2022-10-04 17:05:30.972 [WARN ] [org.openhab.core.model.script.load  ] - to low production boiler OFF 

Searching the forums doesnt give any information about the constant on and off because the average can change quite alot if there are clouds.

Any good ideea ?
thanks

So if I’m interpreting your logic correctly, when the overall load is low you switch a load on. This of course results in higher overall load, and it switches off again, yes?

You’ll need to decide what to do about it yourself. Likely methods involve hysterisis - have a different threshold for on and off actions. And most likely a delay - once you’ve taken an action don’t do anything again for 5 minutes or something.

No so when lets say grid load is high positive put the load on if it becomes low negative put the load off.
I was also thinking of adding a delay but again the problem is maybe in that period i will take energy from the grid wich i dont like but then again i also dont like the constant on off for the boiler relay.

now i am playing with something else

rule "put some load on the system if the production is high"
when
    Item Grid_load changed
then

        if(Grid_load.averageSince(now.minusMinutes(5)) > 2000 |"W" && Boiler_technical_room.state == OFF){
                Boiler_technical_room.sendCommand(ON)
                logWarn("load", "high production boiler ON")
        }
        else if(Grid_load.deviationSince(now.minusMinutes(5)) > -2000 |"W" && Boiler_technical_room.state == ON){
            Boiler_technical_room.sendCommand(OFF)
            logWarn("load", "to low production boiler OFF")
        }
end

but i dont know if it gets to negative i will need to investigate more how openhab calculates all this stuff

Yes. You have to make the choices for yourself.
It’s not a β€œdelay” as such that you want, it’s more of a β€œlockout”.
β€œI’ve just done this, now don’t do it again for X minutes”
Ideas -

Maths is maths, -1500W is more than -2000W

what do you mean by that ?
do i need to put less ?

rule "put some load on the system if the production is high"
when
    Item Grid_load changed
then

        if(Grid_load.averageSince(now.minusMinutes(5)) > 2000 |"W" && Boiler_technical_room.state == OFF){
                Boiler_technical_room.sendCommand(ON)
                logWarn("load", "high production boiler ON")
        }
        else if(Grid_load.averageSince(now.minusMinutes(5)) < -2000 |"W" && Boiler_technical_room.state == ON){
            Boiler_technical_room.sendCommand(OFF)
            logWarn("load", "to low production boiler OFF")
        }
end

I don’t know. You said you needed to investigate how openHAB calculates, so I just pointed out that -1500W is greater than -2000W. I find it very easy to make mistakes there.

well it calculates towards negative the average

I’m not really sure what you mean. Why don’t you find out what the average is, if you’re worried about it?

var x = Grid_load.averageSince(now.minusMinutes(5)
logInfo("power", "5 min average is " + x.toString)
if(x > 2000 |"W" etc...

thanks for pointing that out now i understand why the constant on and off …

It always average negative if the values are negative for that period
So final verdict simple load 800 w solar panels producing more than than an estimated idle consumption like 2000w then we can heat up if this goes negative then we turn off the boiler

rule "put some load on the system if the production is high"
when
    Item Grid_load changed
then

        if(Grid_load.averageSince(now.minusMinutes(5)) > 2000 |"W" && Boiler_technical_room.state == OFF){
                Boiler_technical_room.sendCommand(ON)
                logWarn("load", "high production boiler ON")
        }
        else if(Grid_load.averageSince(now.minusMinutes(5)) < -2000 |"W" && Boiler_technical_room.state == ON){
            Boiler_technical_room.sendCommand(OFF)
            logWarn("load", "to low production boiler OFF")
        }
end
1 Like

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