hi,
I’d like to wait for an item to update before continuing a rule, if the item does not update within 10sec, the rule should continue anyway. with my example below I always end up in a loop forever. can anyone help pls? thx
hi,
I’d like to wait for an item to update before continuing a rule, if the item does not update within 10sec, the rule should continue anyway. with my example below I always end up in a loop forever. can anyone help pls? thx
The problem is that I am not sure what you want.
I think the reason noone yet answered is because it is not really clear what you want to do …
my screenshot above shows only the timer part I’m struggling with. I know how to trigger a rule.
I’m triggering an chatGPT channel that updates item NSPanel_weather. as this is a cloud based service it takes between 0,5 and 4 secs to update the item. the “while” loop should run until the item is changed. if for some reason something fails, the loop should not run longer than 10sec.
Ok,
As a general rule: never use a loop to wait for something.
if you ever want to “wait” for something, then use a timer like shown in your example and WITHIN that timer check what you are wating for:
Does NSPanel_weather update under other circumstances or only in response to this rule? If it’s only in response to this rule, than the easiest thing to do would be to create a separate rule that triggers when NSPanel_weather updates and do what ever you need to there.
Based on my experiments, linking to ChatGPT causes autoupdate to be turned off on that Item. This is good because it means the Item won’t actually update until after ChatGPT responds and not on the command you send to the Item with your query. So a separate rule will only trigger once ChatGPT responds.
Beyond that, OHRT includes a looping timer which implements exactly what @stefan.hoehn describes.
OHRT can be installed from openhabian-config, maunally from the command line (npm install openhab_rules_tools), or there is a rule template to install OHRT (install the template, create a rule based on the template, and run it, watching the logs for errors). Then there is a block library that needs to be installed to access OHRT from Blockly.
The rule template and block library can be installed from the Add-on store in MainUI.
The looping timer block looks like this:
The condition on the until dictates when the loop stops. So this example will create a timer that runs every second until loopCount is >= 5. When it runs, it logs out the loop count and increments it. But for your use case, you’d test to see NSPanel_weather changed and do what ever it is you need to when it does and then the exit condition is if the loop > 10 or NSPanel_weather changed.
Note that timers are not blocking. The rest of the rule will run after the timer is created. Then in the background the timer runs in the background.
hi,
more background info on the timer requirement:
this is a NSPanel mounted in my guestroom, displaying a welcome screen. the welcome screen can be confirmed with a button that calls another screen with the latest weather information, assembled by chatGPT. usually if a button press does not react within milliseconds, people tend to press it again and again…
the button press will trigger chatgpt to update the nspanel_weather and change to the weather screen. the weather screen is static, that means I need to make sure the item is updated before I call the screen.
my requirement for the timer is that multiple button presses should be ignored after the first button press (this should start a timer and if another button press is detected and the timer is still active it should be ignored). when the chatgpt item is updated, the timer can cancel and the rule should call the weather screen.
I was able to apply your looping timer, however, I had a mistaken thinking here: as I try to catch the case when the item changed
![]()
I do also catch the moment the chatgpt item was fed with input data for processing, which is not want I need to continue the script.
if anybody has a simple idea for how to track change number two within a time range, this would solve my problem.
alternatively I found a workaround by triggering the chatgpt item in a separate rule, independedly from the nspanel scripts…
for a completeness of this post, here is the looping timer which in theory works for items other than a chatgpt item.
Hi,
I’m not sure if I understood that correctly…
If so - you could equip the rule with the button and ChatGPT alt trigger and react according to the trigger.
PS: for comparisons of numbers like loopcount, it’s better to use math numbers and no text “0”
Use the denounce profile from the Basic Profiles add-on. No rule required.