This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Status read
#1
Hi,

I need to check the current status of a data object, as a condition in an if-then-elseif.
Having the correct and current (at the exact moment of the request) status is an absolute requirement.


I use grp.read() but since this function returns immediately, the script does not await the response of the bus and continues. Any checks on the status are therefore not usable.

I read a post (I believe from admin), stating to put a os.sleep(2) after the read request in order to give the knx bus the time to put the answer to the request on the bus.

However, I can imagine something can go wrong and the status gets lost or takes longer then 2 seconds to get to the requesting script, meaning this is not a 100% reliable and slow method

Waiting longer then 2 seconds is not really an option (2 seconds is actually already pretty long) since actions to be taken would take too long to activate and possibly, the status of the object has changed in the meantime due some other bus command.

So, my question : is there a way to get the current status of a knx object and be able to use it immediately in a condition check, without delay?

Thanks for your advice.

Hendrik.
Reply
#2
You can attach another script to the object you want to monitor and check if event.type is "groupresponse". So your first script sends read and the second one handles the response once it arrives.
Reply
#3
Thank you admin for the response

However, when the read request is just part of a (or many combined) condition(s) and not linked to the main object being triggered, this might lead very quickly to complicated structures of scripts. Besides, if I understand correctly, any other read request from another source would be triggering the second script and eventually potentially starting a set of unwanted actions.

It's more like the classic prompt for user input that I need : the system needs input ( a value) and waits till the user (in this case the knx bus) gives it, but not a microsecond longer. One would expect this to be possible in any programming language.

I find it strange there seems to be no lean way to do this.
Reply
#4
There's no easy way because the bus is asynchronous, and there's no guarantee that any response will arrive. Another solution is to enable polling for your specific object, so the actual value is updated frequently.
Reply


Forum Jump: