Thanks for your quick answers.
What is the proper way to set a startvalue for a virtual item?
For example a setpoint item which represents the time for opening or closing a shutter.
After a start or restart of openhab ths sitemap should show this value.
postUpdate works just fine.
But if you use it in a rule, do not expect it to have been completed before the rule moves on to the next line. It will complete in a few milliseconds, but not as quick as that.
myItem.postUpdate(xxx) // puts an update request on openHABs event bus
// does not wait for update to complete
logInfo("test",myItem.state.toString) // invariably displays OLD value
Thread::sleep(100) // let's wait
logInfo("test",myItem.state.toString) // magic, displays NEW value
That sounds like something you might want to persist and then restore on startup, so that the system remembers your settings across a reboot.
You’d probably still want a first-time rule to get an initial value.
if (myItem.state == NULL) {
// if not yet initialized or restored
myItem.postUpdate(xxx) // send a default value
}
Please show us your Item definitions and the relevant openhab.log and events.log sections.
Yes I know there won’t be logs of things not happening but your rule does other things that we can see
You’ve got errors in some xxx.things files and some xxx.sitemap files, but they’re not related to this.
home.rules loads okay, but there is no logging from your rule rule “Init virtual Items” that you first showed us.
There are some events logged
2019-06-20 14:52:01.375 [vent.ItemStateChangedEvent] - Wassertemperatur_Pool_Soll changed from NULL to 25.0
2019-06-20 14:52:01.387 [vent.ItemStateChangedEvent] - PoolPumpeAutoStart changed from NULL to 8
2019-06-20 14:52:01.393 [vent.ItemStateChangedEvent] - PoolPumpeAutoStop changed from NULL to 20
2019-06-20 14:52:01.397 [vent.ItemStateChangedEvent] - PoolPumpeAuto changed from NULL to OFF
2019-06-20 14:52:01.401 [vent.ItemStateChangedEvent] - PoolWaermepumpeAuto changed from NULL to OFF
these look like they probably were caused by your “Init virtual Items” rule - except the values do not match exactly.
If you haven’t changed your rule from what you showed before … maybe you are editing a wrong copy of rules file?
The important thing is that there is no evidence of any update to RolladenAutomatikZeitAuf (so we’d expect it to stay NULL)
Looking in openhab.log, home.rules seems to be loaded OK, no errors such as unknown Item or suchlike.
I think your postUpdates for the rolladen Items simply aren’t in your rule at the moment.
Perhaps we should see the current version of the rule?
I’ve tried a lot of things, but I don’t think I’ve changed the name. Since this value is a switch on the sitemap, it was probably not noticed that the start value was not set.