Hi thank you for the explanation.
It is all clear now
I have do edit in your code where you comment with
//action to close shutter
send.command?
I don’t have any experience at scripting.
yes some like
items.getItem('your item name').sendCommand('whatever the valid command is');
you can also change all the console.warn or console.info to console.debug once you are ok and reduce you log entrys. or simply comment them out with 2 forward slashes in front of them like
// console.warn('some comment');
Edit : I updated the original sample I posted as it was not using interval correctly.
Also I tested this more with a item value that changes over the 10 second period and it was not exactly what I expected so this may not pull a new item wind speed value each time due to some other limitations
I will play around with a few other approaches as I have some time and post back.
Thank you indeed
Really appreciate.
I believe it could be useful reduce this interval of 10 second to 5/6 seconds
In this case is it enough to cut the sample lines in your template? Isn it?
yes, all you would need to do is change the value of number_of_samples_to_take to lower number and that is all it will sample.
edit; I updated the script to make it a lot better and insure it actually gets new values for each sample.
Pay close attention to any comments I put in all CAPITAL letters they need you to adjust those values! for your usage. Drop this in your rule as an inline ECMAScript Then area
You can next create a simple generic switch item and name it wind_monitor_active
under your rules use the When and make that your wind speed sensor changed as trigger
under your rules But only if
If wind_monitor_active=OFF
(OPTIONAL) is Add a second But only if
to prevent it running if your roller shutter is already closed
Update the script variables for your wind speed sensor name your roller shutter item Name also you can adjust the interval number and time between samples as you see best I tested many differnt intervals and it seemed to work good with any I tried…
var current_windspeed = items.getItem('Wind_Sensor').numericState; // UPDATE THIS TO YOUR WIND SPEED SENSOR ITEM NAME this would be your item that provides the actual wind speed
var windspeed_too_high = 1.0; //UPDATE THIS TO YOUR MAXIMUM WIND SPEED This sets your wind level to act on so if your first wind speed change is greater or equal to this value then this your monitor will start
var number_of_samples_to_take = 10; //UPDATE THIS TO NUMBER OF SAMPLES TO COLLECT This sets your number of samples if you change greater then 10 you must add samples and if statments to populate them
var interval_time = 1000; // UPDATE THIS TO YOUR DESIRED INTERVAL TIME BETWEEN SAMPLES IN MILLISECONDS. 1000 milliseconds = 1 second. This sets the interval time between samples value MUST be in milliseconds.
var windspeed_sample_sum = 0; //this is a sum of all 10 samples
var windspeed_sample_1 = 0; //this is your first live measurement during your 10 second intraval
var windspeed_sample_2 = 0; //this is your second live measurement during your 10 second intraval
var windspeed_sample_3 = 0; //this is your third live measurement during your 10 second intraval
var windspeed_sample_4 = 0; //this is your forth live measurement during your 10 second intraval
var windspeed_sample_5 = 0; //this is your fifth live measurement during your 10 second intraval
var windspeed_sample_6 = 0; //this is your sixth live measurement during your 10 second intraval
var windspeed_sample_7 = 0; //this is your seventh live measurement during your 10 second intraval
var windspeed_sample_8 = 0; //this is your eighth live measurement during your 10 second intraval
var windspeed_sample_9 = 0; //this is your nineth live measurement during your 10 second intraval
var windspeed_sample_10 = 0; //this is your tenth live measurement during your 10 second intraval
var sample_count = 0; //this sets your count back to 0 at start of rule run
var windspeed_monitor_cycle_active = 0; //This sets the state of your monitor you could make this a switch item and when it is on then you could have your rule be blocked from retriggering till it is set to off after sample run is complete
var wind_speed_average = 0; //this sets your wind speed average back to 0 at start of rule run
var future_predictor = setInterval(MySampleCollector, interval_time); //this is your 1 second timer the interval time "interval_time" is in milliseconds you could change that to a higher of lower value as you see fit with the interval_time varible.
if(current_windspeed >= windspeed_too_high) // this compares your wind speed value based on your first event change and if it the intial wind speed or gust is equal to or greater then the defined value it starts the counter
{
windspeed_monitor_cycle_active = 1; //this sets the monitor cycle to track script is still running
items.getItem('wind_monitor_active').sendCommand('ON'); //UPDATE THIS TO YOUR GENERIC SWITCH ITEM USED TOO BLOCK/UNBLOCK RETRIGGER
sample_count = 0;
console.warn('Wind is too high starting monitor cycle '+'The wind speed is '+current_windspeed);
}
else if(current_windspeed < windspeed_too_high)
{
console.info('windspeed was not high enough to start measurement cycle ' + current_windspeed )
clearInterval(future_predictor);
}
function MySampleCollector()
{
sample_count = sample_count + 1;
if(sample_count == 1)
{
windspeed_sample_1 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_1 = current_windspeed;
console.debug('this is windspeed at intraval 1 '+ windspeed_sample_1 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 2)
{
windspeed_sample_2 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_2 = current_windspeed;
console.debug('this is windspeed at intraval 2 '+ windspeed_sample_2 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 3)
{
windspeed_sample_3 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_3 = current_windspeed;
console.debug('this is windspeed at intraval 3 '+ windspeed_sample_3 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 4)
{
windspeed_sample_4 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_4 = current_windspeed;
console.debug('this is windspeed at intraval 4 '+ windspeed_sample_4 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 5)
{
windspeed_sample_5 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_5 = current_windspeed;
console.debug('this is windspeed at intraval 5 '+ windspeed_sample_5 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 6)
{
windspeed_sample_6 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_6 = current_windspeed;
console.debug('this is windspeed at intraval 6 '+ windspeed_sample_6 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 7)
{
windspeed_sample_7 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_7 = current_windspeed;
console.debug('this is windspeed at intraval 7 '+ windspeed_sample_7 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 8)
{
windspeed_sample_8 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_8 = current_windspeed;
console.debug('this is windspeed at intraval 8 '+ windspeed_sample_8 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 9)
{
windspeed_sample_9 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_9 = current_windspeed;
console.debug('this is windspeed at intraval 9 '+ windspeed_sample_9 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 10)
{
windspeed_sample_10 = items.getItem('Wind_Sensor').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_10 = current_windspeed;
console.debug('this is windspeed at intraval 10 '+ windspeed_sample_10 );
console.debug('this is sample_count '+ sample_count );
}
if(windspeed_monitor_cycle_active = 1)
{
//you can uncomment use this as a way to show like maybe a change a icon or card background a switch state on your UI while monitor is running
//items.GetItem('My_Generic_Switch').sendCommand('ON');
}
if(sample_count == number_of_samples_to_take)
{
console.debug('This is sample_count value = '+ sample_count +' This is number of samples to take value = '+ number_of_samples_to_take );
clearInterval(future_predictor);
windspeed_monitor_cycle_active = 0;
items.getItem('wind_monitor_active').sendCommand('OFF'); //UPDATE THIS TO YOUR GENERIC SWITCH ITEM USED TOO BLOCK/UNBLOCK RETRIGGER
Do_all_math_and_control_shutter();
}
};
function Do_all_math_and_control_shutter()
{
windspeed_sample_sum = (windspeed_sample_1 + windspeed_sample_2 + windspeed_sample_3 + windspeed_sample_4 + windspeed_sample_5
+ windspeed_sample_6 + windspeed_sample_7 + windspeed_sample_8 + windspeed_sample_9 + windspeed_sample_10);
//var Wind_10_second_average = (windspeed_sample_sum / number_of_samples_to_take);
wind_speed_average= (windspeed_sample_sum / number_of_samples_to_take);
if(wind_speed_average >= windspeed_too_high)
{
console.warn('wind is too high closing shutter '+ 'Wind speed average is '+ wind_speed_average );
items.getItem('Test_Roller_Shutter').sendCommand('0'); //UPDATE THIS TO YOUR ROLLER SHUTTER CONTROL
// action to close shutter
}
else
{
console.info('wind is not high '+ 'Wind speed average is '+ wind_speed_average );
//No action required
}
console.debug('this is sum '+ windspeed_sample_sum );
console.debug('this is '+number_of_samples_to_take+' second average '+ wind_speed_average );
console.debug('this is sample_count '+ sample_count );
sample_count = 0;
}
hope it helps and you enjoy.
Thank you indeed Justaoldman. It works like a charm!!!
Masterpiece!
It would be useful to roll up 30% if this wind average is grater than a value. (14km/h) and to roll up completely if the average is grater than an higher value (20 km/h)
But I can confirm that iy works perfectly now.
Many thanks
Hi, glad it works for you.
You could try something like
below this line
var windspeed_too_high = 1; //UPDATE THIS TO YOUR MAXIMUM WIND SPEED This sets your wind level to act on so if your first wind speed change is greater or equal to this value then this your monitor will start
add this new line
var windspeed_super_high = 2; //UPDATE THIS FOR YOUR SUPER HIGH WIND VALUE
then below the last close bracket “}” of this if statement else leg.
if(wind_speed_average >= windspeed_too_high)
{
console.warn('wind is too high closing shutter '+ 'Wind speed average is '+ wind_speed_average );
items.getItem('Test_Roller_Shutter').sendCommand('30'); //UPDATE THIS TO YOUR ROLLER SHUTTER CONTROL
// action to partly close shutter to specific position
}
else
{
console.info('wind is not high '+ 'Wind speed average is '+ wind_speed_average );
//No action required
}
add this new if statement
if(wind_speed_average >= windspeed_super_high)
{
items.getItem('Test_Roller_Shutter').sendCommand('0'); //UPDATE THIS TO YOUR ROLLER SHUTTER CONTROL
console.warn('wind is super high fully closing shutter '+ 'Wind speed average is '+ wind_speed_average );
// action to fully close shutter to specific position
}
that should work to give you two different thresholds to compare.
Edit forgot the console log statement on new action updated it.
Thank you again Justanoldman.
I can confirm it works perfectly and do exactly what I wanted.
Reading your script to learn something I would ask how you ensure when the math avarage after the cicle is higher then windspeed_super_high that also action for windspeed_too_high would be triggered
Cheers
Yes, you are correct a value of wind_super_high does resolve true for both If conditions because obviously 2 is greater than 1 so both if conditions do resolve as true.
Now since wind_super_high value is greater than wind_too_high value it first resolves as true for wind_too_high if condition and sends the command to start closing to partly position next since the if condition check for wind_super_high value also resolves true it sends second command to fully close.
There are ways to refine the checks to only send 1 command instead but sending 2 commands should not be a problem in this use case.
I will let you puzzle on what needs to happen to do that.
Hint: think about how the order of the “if” condition checks are arranged and work. Consider how the “else” condition works. Also think about how an “else if” condition may work in this scenario. You may then consider how “and &&” “or ||” and “not !” operators work and how those behaviors alter " if", “else”, "else if "condition statements.
Thanks Justanoldman.
I will play around with that. Hopefully not messing around and make some mistakes as now works perfectly. Can I leave the script like that without problems so?
Here the complete script updated
var current_windspeed = items.getItem('Vento_Terrazza').numericState; // UPDATE THIS TO YOUR WIND SPEED SENSOR ITEM NAME this would be your item that provides the actual wind speed
var windspeed_too_high = 14; //UPDATE THIS TO YOUR MAXIMUM WIND SPEED This sets your wind level to act on so if your first wind speed change is greater or equal to this value then this your monitor will start
var windspeed_super_high = 25; //UPDATE THIS FOR YOUR SUPER HIGH WIND VALUE
var number_of_samples_to_take = 6; //UPDATE THIS TO NUMBER OF SAMPLES TO COLLECT This sets your number of samples if you change greater then 10 you must add samples and if statments to populate them
var interval_time = 1000; // UPDATE THIS TO YOUR DESIRED INTERVAL TIME BETWEEN SAMPLES IN MILLISECONDS. 1000 milliseconds = 1 second. This sets the interval time between samples value MUST be in milliseconds.
var windspeed_sample_sum = 0; //this is a sum of all 10 samples
var windspeed_sample_1 = 0; //this is your first live measurement during your 10 second intraval
var windspeed_sample_2 = 0; //this is your second live measurement during your 10 second intraval
var windspeed_sample_3 = 0; //this is your third live measurement during your 10 second intraval
var windspeed_sample_4 = 0; //this is your forth live measurement during your 10 second intraval
var windspeed_sample_5 = 0; //this is your fifth live measurement during your 10 second intraval
var windspeed_sample_6 = 0; //this is your sixth live measurement during your 10 second intraval
var sample_count = 0; //this sets your count back to 0 at start of rule run
var windspeed_monitor_cycle_active = 0; //This sets the state of your monitor you could make this a switch item and when it is on then you could have your rule be blocked from retriggering till it is set to off after sample run is complete
var wind_speed_average = 0; //this sets your wind speed average back to 0 at start of rule run
var future_predictor = setInterval(MySampleCollector, interval_time); //this is your 1 second timer the interval time "interval_time" is in milliseconds you could change that to a higher of lower value as you see fit with the interval_time varible.
if(current_windspeed >= windspeed_too_high) // this compares your wind speed value based on your first event change and if it the intial wind speed or gust is equal to or greater then the defined value it starts the counter
{
windspeed_monitor_cycle_active = 1; //this sets the monitor cycle to track script is still running
items.getItem('wind_monitor_terrazza').sendCommand('ON'); //UPDATE THIS TO YOUR GENERIC SWITCH ITEM USED TOO BLOCK/UNBLOCK RETRIGGER
sample_count = 0;
console.warn('Wind is too high starting monitor cycle '+'The wind speed is '+current_windspeed);
}
else if(current_windspeed < windspeed_too_high)
{
console.info('windspeed was not high enough to start measurement cycle ' + current_windspeed )
clearInterval(future_predictor);
}
function MySampleCollector()
{
sample_count = sample_count + 1;
if(sample_count == 1)
{
windspeed_sample_1 = items.getItem('Vento_Terrazza').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_1 = current_windspeed;
console.debug('this is windspeed at intraval 1 '+ windspeed_sample_1 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 2)
{
windspeed_sample_2 = items.getItem('Vento_Terrazza').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_2 = current_windspeed;
console.debug('this is windspeed at intraval 2 '+ windspeed_sample_2 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 3)
{
windspeed_sample_3 = items.getItem('Vento_Terrazza').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_3 = current_windspeed;
console.debug('this is windspeed at intraval 3 '+ windspeed_sample_3 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 4)
{
windspeed_sample_4 = items.getItem('Vento_Terrazza').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_4 = current_windspeed;
console.debug('this is windspeed at intraval 4 '+ windspeed_sample_4 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 5)
{
windspeed_sample_5 = items.getItem('Vento_Terrazza').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_5 = current_windspeed;
console.debug('this is windspeed at intraval 5 '+ windspeed_sample_5 );
console.debug('this is sample_count '+ sample_count );
}
if(sample_count == 6)
{
windspeed_sample_6 = items.getItem('Vento_Terrazza').numericState; //UPDATE THIS TO YOUR WIND SENSOR ITEM NAME
//windspeed_sample_6 = current_windspeed;
console.debug('this is windspeed at intraval 6 '+ windspeed_sample_6 );
console.debug('this is sample_count '+ sample_count );
}
if(windspeed_monitor_cycle_active = 1)
{
//you can uncomment use this as a way to show like maybe a change a icon or card background a switch state on your UI while monitor is running
//items.GetItem('wind_monitor_terrazza').sendCommand('ON');
}
if(sample_count == number_of_samples_to_take)
{
console.debug('This is sample_count value = '+ sample_count +' This is number of samples to take value = '+ number_of_samples_to_take );
clearInterval(future_predictor);
windspeed_monitor_cycle_active = 0;
items.getItem('wind_monitor_terrazza').sendCommand('OFF'); //UPDATE THIS TO YOUR GENERIC SWITCH ITEM USED TOO BLOCK/UNBLOCK RETRIGGER
Do_all_math_and_control_shutter();
}
};
function Do_all_math_and_control_shutter()
{
windspeed_sample_sum = (windspeed_sample_1 + windspeed_sample_2 + windspeed_sample_3 + windspeed_sample_4 + windspeed_sample_5
+ windspeed_sample_6);
//var Wind_10_second_average = (windspeed_sample_sum / number_of_samples_to_take);
wind_speed_average= (windspeed_sample_sum / number_of_samples_to_take);
if(wind_speed_average >= windspeed_too_high)
{
console.warn('wind is too high closing shutter '+ 'Wind speed average is '+ wind_speed_average );
items.getItem('Tende_camere').sendCommand('70'); //UPDATE THIS TO YOUR ROLLER SHUTTER CONTROL
// action to close shutter
}
else
{
console.info('wind is not high '+ 'Wind speed average is '+ wind_speed_average );
//No action required
}
if(wind_speed_average >= windspeed_super_high)
{
console.warn('wind is super high fully closing shutter '+ 'Wind speed average is '+ wind_speed_average );
items.getItem('Tende_camere').sendCommand('100'); //UPDATE THIS TO YOUR ROLLER SHUTTER CONTROL
// action to fully close shutter to specific position
}
console.debug('this is sum '+ windspeed_sample_sum );
console.debug('this is '+number_of_samples_to_take+' second average '+ wind_speed_average );
console.debug('this is sample_count '+ sample_count );
sample_count = 0;
}
sure, it should be ok as is. since you are just changing the command to a different position.
Hi found this in the log
2024-04-24 17:51:55.720 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule '9ac339e384': Failed to execute action: 3(Multi threaded access requested by thread Thread[OH-rule-9ac339e384-1,5,main] but is not allowed for language(s) js.)
But rule works anyway and I confirm command is sent twice on trigger windspeed_super_high condition
2024-04-24 17:51:55.725 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Tendadasole4_BlindsControl' received command 70
2024-04-24 17:51:55.727 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Tendadasole3_BlindsControl' received command 70
2024-04-24 17:51:55.730 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Tendadasole5_BlindsControl' received command 70
2024-04-24 17:51:55.755 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Percentuale_vetrata' received command ON
2024-04-24 17:51:55.757 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Tende' received command 100
2024-04-24 17:51:55.764 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Tendadasole4_BlindsControl' received command 100
2024-04-24 17:51:55.766 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Tendadasole3_BlindsControl' received command 100
2024-04-24 17:51:55.768 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Tendadasole5_BlindsControl' received command 100
Not sure the error is due to the 2 commands but I was able to repro it by manually launching the script repeatedly (more then 50 times in the 6 second period it takes to run to completion) while other instance was still running which I mentioned before was not a good thing. I will try and look a bit further at this behavior when I have some bandwidth.
You see that error when you have two threads trying access data from a single rule at the same time. There are locks in place to prevent this from happening in many but not all cases. I don’t think set_interval
timers are locked so it’s possible to have two threads (i.e. the rule and the interval) running at the same time which will generate this error.
There are locks around actions.ScriptExecution.createTimer
though. Moving to that should eliminate the error.
Thank you Rich for your explanation.
I understand what is happening but I haven’t so clear how to fix it. Do I have to include this ‘actions.ScriptExecution.createTimer ‘in the rule somewhere?
Where the code is calling setInterval
change that to use actions.ScriptExecution.createTimer
. Of course, the syntax is also different so please review the reference for how to use createTimer
.
Hi,
I am quite sure what @rlkoshak stated is 100% correct regarding the reason for the error but I still would like to understand how many times you have received that error and how many instance of the rule you had running simultaneously?
After my last post I enable that rule set a high wind that would trigger the rule every time the last rule completed and did not recreate the error. I fired every 10 seconds for 7 full days with no repeat of the error.
As I stated then the only 2 times I could repro that was if I had a high number of that rule running at same time.
see below
2024-04-24 12:33:39.394 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:39.825 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:40.566 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:41.155 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:41.713 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:42.038 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:42.204 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:42.389 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.23
2024-04-24 12:33:42.570 [WARN ] [e.automation.internal.RuleEngineImpl] - Failed to execute action: 1(Multi threaded access requested by thread Thread[qtp1061994813-706,5,main] but is not allowed for language(s) js.)
notice in both cases the time in between the log entrys.
2024-04-24 12:35:47.206 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:48.206 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:49.206 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:50.207 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:51.205 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:52.208 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:53.205 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:54.205 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:55.205 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.75
2024-04-24 12:35:55.825 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule '74bd233d95': Failed to execute action: 1(Multi threaded access requested by thread Thread[OH-rule-74bd233d95-1,5,main] but is not allowed for language(s) js.)
2024-04-24 12:35:56.209 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 38.05500000000001
2024-04-24 12:35:57.204 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 38.36000000000001
look at the times carefully. notice the entry’s are just milliseconds apart.
As for using create timer approach it should work as well but I am still wondering exactly how many times you had the rule triggered and running at same time.
notice here over a full 1 hour period the rule ran every 10 seconds and not once did it error (I have 7 days worth of that same log btw)
2024-04-30 21:00:34.431 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.63
2024-04-30 21:00:44.433 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.63
2024-04-30 21:01:34.681 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.03
2024-04-30 21:01:44.684 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.029999999999994
2024-04-30 21:01:44.719 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.23
2024-04-30 21:01:54.721 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.230000000000004
2024-04-30 21:02:14.841 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.03
2024-04-30 21:02:24.843 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.029999999999994
2024-04-30 21:02:34.915 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.23
2024-04-30 21:02:44.917 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.230000000000004
2024-04-30 21:02:54.995 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.03
2024-04-30 21:03:04.995 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.029999999999994
2024-04-30 21:03:35.155 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.23
2024-04-30 21:03:45.157 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.230000000000004
2024-04-30 21:03:45.192 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.03
2024-04-30 21:03:55.193 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.029999999999994
2024-04-30 21:03:55.236 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.43
2024-04-30 21:04:05.237 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.43
2024-04-30 21:06:15.810 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.43
2024-04-30 21:06:25.811 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.43
2024-04-30 21:06:25.843 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.63
2024-04-30 21:06:35.843 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.63
2024-04-30 21:07:26.084 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.82
2024-04-30 21:07:36.085 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.82
2024-04-30 21:08:36.360 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.53
2024-04-30 21:08:46.361 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.529999999999994
2024-04-30 21:08:56.437 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.82
2024-04-30 21:09:06.440 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.82
2024-04-30 21:10:46.899 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.43
2024-04-30 21:10:56.901 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.43
2024-04-30 21:10:56.927 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.73
2024-04-30 21:11:06.929 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.730000000000004
2024-04-30 21:11:06.971 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.93
2024-04-30 21:11:16.973 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.93
2024-04-30 21:11:47.125 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.82
2024-04-30 21:11:57.127 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.82
2024-04-30 21:12:37.340 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.83
2024-04-30 21:12:47.339 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.82999999999999
2024-04-30 21:12:57.425 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.23
2024-04-30 21:13:07.425 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.230000000000004
2024-04-30 21:13:37.585 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.03
2024-04-30 21:13:47.587 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.029999999999994
2024-04-30 21:13:47.624 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.43
2024-04-30 21:13:57.626 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.43
2024-04-30 21:15:38.074 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.03
2024-04-30 21:15:48.074 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.029999999999994
2024-04-30 21:15:48.113 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.02
2024-04-30 21:15:58.115 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.019999999999996
2024-04-30 21:15:58.160 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.83
2024-04-30 21:16:08.162 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.82999999999999
2024-04-30 21:16:08.199 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.43
2024-04-30 21:16:18.199 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.43
2024-04-30 21:16:18.239 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.53
2024-04-30 21:16:28.240 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.529999999999994
2024-04-30 21:16:58.409 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.02
2024-04-30 21:17:08.411 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.019999999999996
2024-04-30 21:17:08.440 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.53
2024-04-30 21:17:18.442 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.529999999999994
2024-04-30 21:17:58.645 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.82
2024-04-30 21:18:08.645 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.82
2024-04-30 21:19:18.970 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.35
2024-04-30 21:19:28.971 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.35000000000001
2024-04-30 21:19:29.009 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.43
2024-04-30 21:19:39.011 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.43
2024-04-30 21:19:39.047 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.35
2024-04-30 21:19:49.049 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.35000000000001
2024-04-30 21:19:49.089 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.74
2024-04-30 21:19:59.090 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.74
2024-04-30 21:27:30.971 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.35
2024-04-30 21:27:40.972 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.35000000000001
2024-04-30 21:30:21.648 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.34
2024-04-30 21:30:31.649 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.34000000000001
2024-04-30 21:31:11.850 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.74
2024-04-30 21:31:21.849 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.74
2024-04-30 21:31:21.889 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.44
2024-04-30 21:31:31.890 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.44
2024-04-30 21:31:41.970 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.95
2024-04-30 21:31:51.972 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.949999999999996
2024-04-30 21:35:02.792 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.24
2024-04-30 21:35:12.794 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.24
2024-04-30 21:35:12.829 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.95
2024-04-30 21:35:22.832 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.949999999999996
2024-04-30 21:35:22.872 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.24
2024-04-30 21:35:32.874 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.24
2024-04-30 21:35:32.915 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.04
2024-04-30 21:35:42.916 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.040000000000006
2024-04-30 21:36:43.199 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.65
2024-04-30 21:36:53.200 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.64999999999999
2024-04-30 21:37:03.269 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.95
2024-04-30 21:37:13.271 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.949999999999996
2024-04-30 21:37:53.475 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 37.05
2024-04-30 21:38:03.477 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 37.050000000000004
2024-04-30 21:38:03.511 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.64
2024-04-30 21:38:13.513 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.63999999999999
2024-04-30 21:38:13.557 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.85
2024-04-30 21:38:23.559 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.85000000000001
2024-04-30 21:38:33.631 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.15
2024-04-30 21:38:43.632 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.14999999999999
2024-04-30 21:38:43.666 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.54
2024-04-30 21:38:53.667 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.540000000000006
2024-04-30 21:38:53.708 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.15
2024-04-30 21:39:03.710 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.14999999999999
2024-04-30 21:39:33.882 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.64
2024-04-30 21:39:43.882 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.63999999999999
2024-04-30 21:40:24.093 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.54
2024-04-30 21:40:34.095 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.540000000000006
2024-04-30 21:40:34.130 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.74
2024-04-30 21:40:44.131 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.74
2024-04-30 21:41:04.252 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.35
2024-04-30 21:41:14.253 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 36.35000000000001
2024-04-30 21:41:14.294 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 35.64
2024-04-30 21:41:24.296 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly closing shutter Wind speed average is 35.63999999999999
2024-04-30 21:42:04.502 [WARN ] [nhab.automation.script.ui.74bd233d95] - Wind is too high starting monitor cycle The wind speed is 36.15
2024-04-30 21:42:14.504 [WARN ] [nhab.automation.script.ui.74bd233d95] - wind is too high partly c
so if this was really a case of it calling the interval at same time it was calling data states from a item state I would have expected to at least repro’d the error at least 1 more time during the 7days it ran .
Just saying you may want to review a bit more of how you set up the “but only if” condition on your rule set to insure you are not letting multiple copys of the rule be active at same time.
You cannot have more than one instance of the rule running simultaneously. There are locks in place to prevent that. However, you could have a timer running at the same time as the rule is running which will generate the Multithreaded exception. There are locks in place for openHAB Timers to prevent that too.
Ultimately, only one thread can access a rule’s context at a time.
Those rules are not running at the same time. However what probably happened was the timer went off to run while the rule was running. You increased the likelihood of that happening by running the rule rapidly.
On a decent machine, a rule only takes milliseconds to run typically. This is particularly true of an algorithmically simple rule like this.
This is impossible to do in OH. You cannot have more than one instance of a rule running at the same time. This is implemented and enforced in the core and has been true since the NGRE in OH 2.5 and for all rules since OH 3.0. If the rule is running when it’s triggered again, the subsequent trigger(s) are queued up and worked off in sequence.
But there appear to be no locks for setInterval
.
BTW, why setInterval
and not setTimeout
? Do you really intend for the timer to run repeatedly every second?
Also, since you never check to see if there is already an interval running before you create a new one, if you trigger the rule five times, you’ll have five timers running every second. That greatly increases the likelihood that you’ll have two intervals that end up trying to run at the same time or an interval trying to run at the same time as the rule even if each only takes a dozen milliseconds to complete. And since you lose the reference to the interval when you create the new one, you may end up with those earlier timers never being cleared.
Yes
The approach was to set an interval that every 1 second or what ever was defined in the “interval_time” var call the “My_sample_collector” function witch would increment the “sample_count” var and call for a updated value of the “current_wind_speed” and update that value to the respective "wind_speed_sample var that matched the “sample_count” var using set interval for this approach seemed like an appropriate way to do this without calling/creating and disposing of multiple Timeouts
After the sample count equated the “number_of_samples_to_take” var then it would clear the interval and call the math and shutter control function.
As for only one rule running at a time ok I am not questioning that I was attempting to prevent queing/multiple rules trying to run if the wind speed changed multiple times during the sample period the rule was running thus the reason I asked OP to check if the But only if condition.
I agree this was a very simple script and was offered as a way to help the OP better understand and or clarify what he was wanting to do.
I was bypassing the “WHEN” trigger of the rule and manually clicking the run now(CTRL-R) as I was not able to recreate that error otherwise.
I believe I said in an early post
And I am more then happy to have anyone offer the user more ways to do this but since the OP stated he was not very good at scripting I wanted to give him something to perhaps spark a flame in his mind to see what could be done. It was by no means a statement of it being the only way to do it.
As for setinterval not having a lock was not aware of that and I did review the OpenHab docs and did not see any thing saying it should be avoided it was actually mentioned as one of the functions that was available and fully compatible with openhab BTW based on this
Ultimately, it’s reasonable to use setInterval
in most cases. However as implemented here there are two problems that make it’s use problematic as written.
-
Previously created timers are not cleared before creating a new one. Consequently every time the rule runs a new timer is created and the reference to the old timer is lost and therefore never get cleared. Over time you can have dozens of intervals running every second.
-
Because a new timer is created every time the rule runs, after a few runs of the rule the chances that they conflict increases resulting in a Multithreaded exception.
If you store what setInterval
returns into the cache, and only create a new interval if one doesn’t already exist, then both of these problems go away and the chances of a multithreaded exception goes way down.
cache.private.get('interval', () => setInterval(MySampleCollector, interval_time)); // only creates a new interval if one isn't already in the cache
...
clearInterval(cache.private.get('interval'));
cache.private.put('interval', null); // clear the cache so a new interval is created next time it's warranted
Managing the creation and clearing of the intervals should address the problem and make the multithreaded exception extremely unlikely to occur.
You would still want to do the same when using an OH Timer. However, if you did have a conflict, the locks on the OH Timer should avoid the multithreaded exception. But you’d still have dozens of orphan Timers running over time.
Using Blockly might be a good choice in that case. My fear is that @Jadblack is practicing cargo cult programming for this and will be unable to maintain this solution in the long run. With Blockly it could be more understandable for non-programmers.
Something like the following (warning, untested):
I tried to stick as closely as possible to your code above with the major differences being:
-
I use the existence of the looping timer as the flag to determine whether or not to do something when the rule is triggered instead of
windspeed_mnonitor_cycle_active
-
I only create the one looping timer and only if it doesn’t already exist
-
I use a List instead of separate variables for each sample
The two places that say “MyItem” should be changed to use the Items in question.
The Looping Timer block comes from openHAB Rules Tools [4.1.0.0;4.9.9.9]
Hi @rlkoshak
Thank you for your explanation. I am sure the OP will much happier with your approach.
Only one thing I am not clear on.
How is this not clearing the interval ?
Since I did not send this to cache this initially are you saying I now would need to
clear it now from cache?
also I should see these orphan threads in a thread dump list also right?
So far I am not seeing .them.
just curious and want to better understand this specific OpenHab behavior for future personal use.