Mads_Bloch
(Mads Bloch)
December 8, 2021, 3:37pm
1
When did this stop working ?
“System started”
My rule never run, it use to work in older version of openhab.
I currently run openhab 3.1 release
rule "Reset timers and flags at startup"
when
System started
then
logInfo("bootup", "System startet, regle genstartet.")
//Hvis SystemKLAR er null, så er det første start. (skal kun køres ved første start)
Thanks Mads
kriznik
(kriznik)
December 8, 2021, 3:40pm
2
i think it’s since 3.0.0, it’s not yet working in 3.1.0 either. Looking forward to 3.2.0
rlkoshak
(Rich Koshak)
December 8, 2021, 4:13pm
3
Depends on what you mean by “not working”. OH 3 introduced the concept of run levels. There are a number of stages that OH goes through during a startup from 00 to 100 (fully started). This solved a number of problems in OH 2 related to when rules start running before Items or Things are loaded for example and it give us much more control over the system.
However, that change also changed the behavior of System started
triggers. These triggers now actually implement what they say. They trigger a rule when the system has started, i.e. when OH has started (technically when OH reaches run level 60. Since that event only occurs once when OH first starts up that means your rule won’t trigger when you save the .rules file after that point.
So it’s not a bug, it’s working as designed.
There is an issue open to add a “Rule Loaded” trigger (which only really makes sense in text based rules) but I’ve not followed the status of that.
In the mean time, you can manually run the rule in MainUI after you’ve changed the file and saved it. The rule will run when OH is restarted otherwise, just not when you’ve changed the file. And the System started
trigger will never again trigger the rule in that circumstance.
2 Likes
Mads_Bloch
(Mads Bloch)
December 8, 2021, 7:11pm
4
Hi
Ok, so its just working differently then is to do
I would like to use something that works as the system started use to do
For example if I manually stop and start openhab or if I reboot my rpi4 then I would like to have my rule triggered at startup.
Any suggestions
Ohh and at the moment I only use text based configuration
Thanks Mads
rlkoshak
(Rich Koshak)
December 8, 2021, 7:16pm
5
That’s literally the only time that a “System started” rule will trigger. This should work already and if that is not working you need to file an issue.
It’s only the case where you edit the .rules file and save it that will not cause the rule to trigger.
And whether or not you use text configs, you can still see and manually run your rules in MainUI. You don’t have to write a rule in the UI to run it in the UI.
1 Like
Mads_Bloch
(Mads Bloch)
December 8, 2021, 7:25pm
6
Hi
I’m not able to trigger the rule with stop/start or reboot.
I do remember that it use trigger when just changing rules, what a pain.
Is there a change I should do in mainUI or is it just broken some how?
Thanks Mads
rlkoshak
(Rich Koshak)
December 8, 2021, 7:30pm
7
If the rule is not triggering when openHAB starts up then it’s a bug and an issue needs to be filed. How to file an Issue
1 Like
rossko57
(Rossko57)
December 8, 2021, 9:03pm
8
Does your xxx.rules
file load? There will be a message in your openhab.log
.
It needs to be in the right folder.
Mads_Bloch
(Mads Bloch)
December 9, 2021, 3:28pm
9
HI
This log is after stop and reboot
2021-12-09 15:53:55.964 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Copenhagen'.
2021-12-09 15:53:56.032 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to '00.5519418606257,0.673461914062502'.
2021-12-09 15:53:56.035 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'da_DK'.
2021-12-09 15:53:56.038 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Measurement system set to 'SI'.
2021-12-09 15:54:08.120 [WARN ] [org.openhab.core.net.NetUtil ] - Invalid address '192.168.0.101/24', will use first interface instead.
2021-12-09 15:54:08.124 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring 192.168.0.101
2021-12-09 15:54:11.070 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'telefoner.items'
2021-12-09 15:54:12.578 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'timer.items'
2021-12-09 15:54:12.805 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'chromecast.items'
2021-12-09 15:54:12.885 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'xiaomi.items'
2021-12-09 15:54:13.100 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'presence.items'
2021-12-09 15:54:13.136 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'go-eCharger.items'
2021-12-09 15:54:13.547 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'milight.items'
2021-12-09 15:54:13.605 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'doorcontacts.items'
2021-12-09 15:54:13.671 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'sysinfo.items'
2021-12-09 15:54:13.742 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'bosch-indego.items'
2021-12-09 15:54:13.798 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'sonofftasmota.items'
2021-12-09 15:54:14.087 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mb-connect.items'
2021-12-09 15:54:14.315 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'demo.items'
2021-12-09 15:54:14.327 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'groups.items'
2021-12-09 15:54:15.136 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mylandroidbind.items'
2021-12-09 15:54:15.557 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'zigbee2mqtt.items'
2021-12-09 15:54:17.464 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'homemade.items'
2021-12-09 15:54:18.186 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'
2021-12-09 15:54:18.341 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mapdb.persist'
2021-12-09 15:54:19.106 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Olafsvej23.sitemap'
2021-12-09 15:54:19.823 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mb_connect.sitemap'
2021-12-09 15:54:19.871 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'goeCharger.sitemap'
2021-12-09 15:54:20.493 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'zigbee2mqtt.things'
2021-12-09 15:54:21.251 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'go-eCharger.things'
2021-12-09 15:54:21.339 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'sonofftasmota.things'
2021-12-09 15:54:21.396 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'astro.things'
2021-12-09 15:54:21.415 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'homemadeMQTT.things'
2021-12-09 15:54:21.451 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'chromecast.things'
2021-12-09 15:54:21.475 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'exec.things'
2021-12-09 15:54:21.498 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mail.things'
2021-12-09 15:54:21.525 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'xiaomi.things'
2021-12-09 15:54:21.542 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'network.things'
2021-12-09 15:54:27.966 [INFO ] [.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2021-12-09 15:54:42.617 [INFO ] [org.openhab.ui.internal.UIService ] - Started UI on port 8080
2021-12-09 15:54:42.904 [INFO ] [e.automation.internal.RuleEngineImpl] - Rule engine started.
2021-12-09 15:55:03.877 [WARN ] [org.openhab.core.net.NetUtil ] - Invalid address '192.168.0.101/24', will use first interface instead.
2021-12-09 15:55:03.885 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring 192.168.0.101
2021-12-09 15:55:05.087 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online
2021-12-09 15:55:05.470 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler MiIoVacuumHandler of thing miio:vacuum:wally tried updating channel actions#segment although the handler was already disposed.
2021-12-09 15:55:07.691 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to 'localhost' with clientid 0
2021-12-09 15:55:07.700 [WARN ] [org.openhab.core.net.NetUtil ] - Invalid address '192.168.0.101/24', will use first interface instead.
2021-12-09 15:55:07.718 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring 192.168.0.101
2021-12-09 15:55:07.739 [WARN ] [.MqttBrokerConnectionServiceInstance] - MqttBroker connection configuration faulty: host : You need to provide a hostname/IP!
2021-12-09 15:55:07.844 [WARN ] [org.openhab.core.net.NetUtil ] - Invalid address '192.168.0.101/24', will use first interface instead.
2021-12-09 15:55:07.847 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring 192.168.0.101
2021-12-09 15:55:07.915 [WARN ] [org.openhab.core.net.NetUtil ] - Invalid address '192.168.0.101/24', will use first interface instead.
2021-12-09 15:55:07.918 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring 192.168.0.101
2021-12-09 15:55:08.070 [WARN ] [org.openhab.core.net.NetUtil ] - Invalid address '192.168.0.101/24', will use first interface instead.
2021-12-09 15:55:08.087 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring 192.168.0.101
2021-12-09 15:55:09.834 [INFO ] [io.openhabcloud.internal.CloudClient] - Connected to the openHAB Cloud service (UUID = 0, base URL = http://localhost:8080)
2021-12-09 15:55:16.358 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'miio:vacuum:174DC3F3' to inbox.
2021-12-09 15:55:20.075 [INFO ] [ab.ui.habpanel.internal.HABPanelTile] - Started HABPanel at /habpanel
2021-12-09 15:55:26.183 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'googleheatmode.rules'
2021-12-09 15:55:34.859 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mainpowercalc.rules'
2021-12-09 15:55:43.264 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'lys.rules'
2021-12-09 15:56:02.901 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'milight.rules'
2021-12-09 15:56:04.808 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'badvaerelse.rules'
2021-12-09 15:56:09.355 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'presence.rules'
2021-12-09 15:56:12.185 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'lidlstringRGB.rules'
2021-12-09 15:56:20.933 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'doorcontacts.rules'
2021-12-09 15:56:27.211 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'wc.rules'
2021-12-09 15:56:30.182 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'sonofftasmota.rules'
2021-12-09 15:56:38.035 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'fidogate.rules'
2021-12-09 15:56:41.972 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'vaske-torre.rules'
2021-12-09 15:56:48.711 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'klokke.rules'
2021-12-09 15:56:54.013 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Ferie.rules'
2021-12-09 15:56:59.570 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Udsugning.rules'
2021-12-09 15:57:01.203 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'go-eCharger.rules'
2021-12-09 15:57:09.918 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'testfuktioner.rules'
2021-12-09 15:57:12.391 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'systemstarted.rules'
2021-12-09 15:57:41.729 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mb-refresh_token.rules'
2021-12-09 15:57:42.762 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'ringeklokke.rules'
2021-12-09 15:57:46.045 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'garage.rules'
2021-12-09 15:57:49.151 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'vacuum.rules'
2021-12-09 15:57:52.898 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'telefoner.rules'
2021-12-09 15:58:43.728 [INFO ] [core.model.script.Torretumbler.rules] - Tørretumbler startet
2021-12-09 15:58:53.858 [INFO ] [core.model.script.vaskemaskine.rules] - Vaskemaskine timer køre
2021-12-09 16:00:00.227 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'mainpowercalc-3' failed: cannot invoke method public abstract org.openhab.core.types.State org.openhab.core.persistence.HistoricItem.getState() on null in mainpowercalc
2021-12-09 16:07:30.632 [INFO ] [ore.model.script.SonoffTasmota.rules] - Pir wc aktiveret
2021-12-09 16:08:38.028 [INFO ] [core.model.script.Torretumbler.rules] - Tørretumbler timer køre
2021-12-09 16:09:53.987 [INFO ] [core.model.script.vaskemaskine.rules] - Vaskemaskine stoppet
2021-12-09 16:13:38.105 [INFO ] [core.model.script.Torretumbler.rules] - Tørretumbler stoppet
Thanks Mads
rossko57
(Rossko57)
December 9, 2021, 4:04pm
10
That’s nice. Are any of those the file in question? I see some other rules logging messages, are they start up rules?
Mads_Bloch
(Mads Bloch)
December 9, 2021, 4:08pm
11
Hi
Sorry, the rule is named systemstarted.rules
No i dont see the logging I have made in the rule
They are from vaske-torre.rules and lys.rules
Thanks Mads
rossko57
(Rossko57)
December 9, 2021, 4:18pm
12
Well, it loads the rules file and does not complain about syntax.
There have been issues with filenames, but systemstarted.rules
seems reasonable.
It is however just possible that is clashing with a reserved word.
Make a new file, say startup.rules
, and type in your test rule. Don’t copy-paste - sometimes people get hidden control characters in their files, which can also cause hard to find problems, so eliminate that possibility too.
Also make sure the rule name
rule "Reset timers and flags at startup"
is unique within your system - I’m sure it would be.
Mads_Bloch
(Mads Bloch)
December 9, 2021, 4:22pm
13
Hi
I will try to make a new rule file.
This is my own file, it has been working earlier in openhab 2.5
Thanks Mads
rossko57
(Rossko57)
December 9, 2021, 4:23pm
14
Don’t care, totally new rules management in OH3
Mads_Bloch
(Mads Bloch)
December 10, 2021, 7:22am
15
Hi
This is how the same rule looks from MainUI rule “reader”
The start level is only 20, which is way to early, it should be 60 or so
// Triggers:
// - When the system has reached start level 20
// context: systemstarted-1
logInfo("bootup", "System startet, regle genstartet.")
//Hvis SystemKLAR er null, så er det første start. (skal kun køres ved første start)
Thanks Mads
Mads_Bloch
(Mads Bloch)
December 11, 2021, 6:57am
16
HI
Ok, i think that in openhab 3.1 release, the “System started” trigger in DSL rules in broken, because.
This DSL rule
Ended up look like this in MainUI “rule reader”
When looking at startup levels, its my understanding that rules below level 50 will not be executed because the rule engine is not running ?
So unless there’s away to change “System started” trigger in DSL rules to a higher startup level its broken.
Thanks Mads
rossko57
(Rossko57)
December 11, 2021, 12:23pm
17
Maybe. Maybe they get queued. Maybe the start levels isn’t properly implemented in OH3.1 at all, and any/all ‘levels’ actually get triggered later.
The Big Question you haven’t answered … does that test rule work?
Mads_Bloch
(Mads Bloch)
December 11, 2021, 12:30pm
18
Hi
Sorry, No the test rule does not work.
Thanks Mads
kriznik
(kriznik)
December 11, 2021, 1:57pm
19
it’s not necessary still repeat same questions,
We’ve been discussing it since OH3 and I’m pretty sure ticket was filled in back then.
System started trigger simply does not work in 3.1. And whatever that runlevel 20 is, it’s not triggering that trigger at all, neither for me and for many others. Neither from UI rule definiton (for into)
I’ve just tried OH3 and System started doesn’t work on startup and after editing files. I’ve asked on another thread if its likely to be fixed. One workaround may be using an item restored at startup to trigger a switch to do the same thing. For example using the old rule engine
rule "dummy startup"
when Item MyStartupItem changed to OFF then
{ Startup Stuff }
end
Its similar to what I used to use to copy all my rules back into the rules folder once things were restored at startup, which b…
I have rule that sends mqtt command to get states from things.
It is triggered by system start level = 20
[Zrzut ekranu 2020-12-7 o 00.36.50]
When I turn it manually it is working.
But restart system is not triggering the rule.
Any ideas?
Hi,
I’am having a simple rule in OH3
rule System_started
when
System started
then
logInfo("System started", "STARTED------------------")
end
but this is never executed.
Not for the initial creation, not when i am touching an items file and not when i touch the rules file.
In the log is just the message the rule file is loaded. Item and Group triggered rules are working file. Logging as well.
Whats going wrong?
Personally I don’t care so much about this trigger, better to have different approach, but yes, in some cases it might be handy.
1 Like
rossko57
(Rossko57)
December 11, 2021, 2:07pm
20
There’s a whole bunch of reasons any given rule might not do what is expected; always worth identifying actual causes.
Fairly extensive exploration at -
opened 11:05AM - 12 Sep 20 UTC
closed 01:34PM - 12 Dec 20 UTC
bug
automation
DSL rules
When using the [demo.rules](https://github.com/openhab/openhab-distro/blob/0d9e3… 273e42bbd907c18bb99d22acda56ce805b5/features/distro-resources/src/main/resources/rules/demo.rules#L75-L129) file the rules with the "System started" don't seem to be executed at startup.
They do get executed when I manually trigger the rules from the UI.
It's most likely caused by https://github.com/openhab/openhab-core/pull/1451
openhab:master
← kaikreuzer:sls
opened 11:47PM - 11 Dec 20 UTC
This finally implements https://github.com/eclipse-archived/smarthome/issues/189… 6, fixes a couple of issues that currently exist due to the unpredictable startup sequence and it should also improve the startup performance, since activities do not have to be done multiple times in order to deal with lazy loaded stuff.
This service combines different ReadyMarkers into a new start level ready marker and thus lets other services depend on those, without having to know about the single markers.
This brings an important decoupling, since the set of markers for a certain start level might depend on the individual set up-
The start level service is therefore configurable (see [here](https://github.com/openhab/openhab-distro/pull/1211/files#diff-6f5d3ba8289d20be508f0997f8b24e4b48962d8f5e56df3e793a566bec2469f1R16-R21), so that users have a chance to adapt the conditions upon a certain start level is reached.
Start levels are defined as values between 0 and 100. They carry the following semantics:
- 00 - OSGi framework has been started.
- 10 - OSGi application start level has been reached, i.e. bundles are activated.
- 20 - Model entities (items, things, links, persist config) have been loaded, both from db as well as files.
- 30 - Item states have been restored from persistence service, where applicable.
- 40 - Rules are loaded and parsed, both from db as well as dsl and script files.
- 50 - Rule engine has executed all "system started" rules and is active.
- 70 - User interface is up and running.
- 80 - All things have been initialized.
- 100 - Startup is fully complete.
Note: Levels 70 and 80 are not yet implemented in this PR, but should be added at a later stage.
While still being in a level <50, no events will be logged out anymore, which reduces the logs wrt "item added" and "link added" events tremendously.
I have also further improvements in mind like automatically registering what bundles are installed and for which markers needs to be waited, so that there is less necessity to adapt the configuration, if anybody does not use a "standard" setup of openHAB. Note that for anybody using the normal distro and not removing any essential parts of it, there should be no need to configure anything with the current implementation.
Fixes https://github.com/openhab/openhab-core/issues/1637
Fixes https://github.com/openhab/openhab-core/issues/1777
Fixes https://github.com/openhab/openhab-core/issues/1734
Fixes https://github.com/openhab/openhab-core/issues/1823
Fixes https://github.com/openhab/openhab-core/issues/1808
Might also fix https://github.com/openhab/openhab-core/issues/1365
Might also fix https://github.com/openhab/openhab-core/issues/1829
Signed-off-by: Kai Kreuzer <kai@openhab.org>