I am currently runing OH3.2. I need to have a script, running at sytem start, which collects some IP addresses. Even when set the trigger in the rule to system level 100 it looks like, that it does not work 100%. So tried to create a timer, to delay the execution for 30s after the trigger.
When this is part of a rule, it gives an error:
Script execution of rule with UID ‘Startup’ failed: :23:35 Expected an operand but found |
createTimer(now.plusSeconds(30), [ |
^ in at line number 23 at column number 35
The same code copied into a script runs perfectly. Any idea, what I am doing wrong?
one additional question: what is the appropriate time to wait after startup, until the script can run safely?
I have extended the time to 2 mins, however, after startup the items with _IP have still the value NULL. I then startet the startup script manually abt. 50 mins after startup, now the values are correct.
You don’t necessarily need one rule out Thing. Again it depends on what your rule does and what it’s means when a Thing comes online for that rule.
The danger goes for the Item’s. It depends on what the rule does with/to the items and whether there’s any external dependencies involved. For example, if the rule expects the items to restoreOnStartup using InfluxDB but InfluxDB is down, the Items will not have been restored when the rule runs.
Again, there is no universal answer here. You have to know and understand what the dependencies are to answer that question.
What I want to achieve with the startup script is the following: I have integrated several Tasmota devices via MQTT. As these devices have an internal browser, sometime the ip address is important. Unfortunaley, OH sees the ip address only, when the Tasmota devices is bootet after OH. I have learned, that the “Status5” reads the IP address back, so the goal is, to get the address shortly after an OH reboot (which I do every night, after a system backup).