Comments (7)
This would be a good addition to Expire I think.
In the past I've worked around this through a rule. Basically it's a system started rule that updates the Items with Expire metadata with the Item's current state. However, that approach will only work for Expire configs that work on updates and won't work for Expire that only look for changes.
But such a rule's script action would look something like this (JS Scripting):
items.getItems().filter( i => i.getMetadata('expire') !== null ).forEach( i => i.postUpdate(i.state));
I've also on my list of things to do to add a startup behavior to https://community.openhab.org/t/threshold-alert-and-open-reminder-4-0-0-0-4-9-9-9/144863 as that rule template has the same problem as Expire of not starting the timers after OH starts but the Items don't update/change after startup. It does however, support alerting when an Item stops changing or updating later on, which is part of this. issue.
from openhab-core.
What happens when you have mapdb
configured for the items?
Wouldn't then the item state be restored and expire run as expected?
Could also have "initial expiration duration"
While I get the idea I think an on_startup
flag would be both sufficient and easier to use.
from openhab-core.
I actually did not realize that there is such a generic simple rule to "fix" this issue with all items...solves my immediate problem
There's a rule template on the marketplace. https://community.openhab.org/t/restart-expire-4-0-0-0-4-9-9-9/146377. It has a couple more config options than the simple forEach above but it basically does the same job.
would be easier to use and for almost all use cases sufficient.
Based on my reading of "expire items with no events" I see two cases where an Item no longer receives events:
-
It never received any events after OH started up. This case is handled easily with a boolean flag.
-
The Item was receiving events for awhile but stopped receiving events. You want the Item to change to one state when the Item remains different from a given state for a given time but you want it to expire to a different state if the Item doesn't receive an update for a given time. For example, an Item gets updated every hour. When it changes to ON you want to command it OFF after five minutes. But it if doesn't receive an update for two hours you want it to become UNDEF to indicate it might be offline.
Maybe 2 isn't worth the effort to address in Expire, but it is a useful and relevant use case.
from openhab-core.
Could also have "initial expiration duration", used only for the situation when there is no incoming events
from openhab-core.
Wouldn't then the item state be restored and expire run as expected?
No, restoreOnStartup happens before Expire is enabled. Only when an Item is updated after runlevel 80 (IIRC) trigger expire. Any updates before that (restoreOnStartup occurs around 30 I think) will not trigger expire.
While I get the idea I think an on_startup flag would be both sufficient and easier to use.
There are two parts to this. The first is dealing with the startup behavior and dealing with the fact that whether there is restoreOnStartup or not if the Item never changes or is updated after expire starts to run the Item will never expire.
The second one is dealing with the case where an Item doesn't receive any update for a time. Presumably this would be a case where the Item remains in the expired state. It is useful to get some sort of indication that an Item that normally periodically is updated stops being updated (e.g. expire to OFF after it's been ON for five minutes but expire to UNDEF when the Item is not updated for 30 minutes).
from openhab-core.
Sorry - I don't understand your last two points. Can you rephrase them a little bit.
My suggestion was that instead of
Number MyNumber { expire="5s,state=0,initial_expiration_duration=5s" }
this
Number MyNumber { expire="5s,state=0,on_startup" }
would be easier to use and for almost all use cases sufficient.
Just a flag that this expire should be run on startup, too.
Both would run an expire after startup (which is the new suggested feature).
Maybe it even would make sense to run expire on startup as a default and have the user explicitly opt out, e.g.
Number MyNumber { expire="5s,state=0,no_startup" }
from openhab-core.
The case of "initial expiration duration" can already be implemented similar to @rkoshak suggested, so I agree to keep it simple with a yes/no flag.
I actually did not realize that there is such a generic simple rule to "fix" this issue with all items...solves my immediate problem
from openhab-core.
Related Issues (20)
- Allow offset for "at the time specified in an item's state" trigger HOT 7
- customTags.yaml not loading after reboot HOT 6
- Thing File based configuration not loaded correctly after changing HOT 33
- Attempting to send a state update of an item which doesn't exist: __v_isRef HOT 7
- Default statedescription pattern for NumberItem HOT 3
- Error during logger activation HOT 3
- Snapshot 4069: failed to install bundles at startup HOT 39
- Missmatch between system:start-level and openhab.event.StartlevelEvent HOT 5
- OpenHAB 4.1.2 - Karaf cannot start HOT 4
- Add SDDP service to core HOT 4
- Sitemap widget grid
- [ephemeris] Calls to `isBankHoliday` failing with exception HOT 6
- Local build failing in config.core due to violation in schema\config-description-1.0.0.xsd HOT 2
- Thing file loading issue HOT 12
- Persisted group items with base type Number:Dimension not restored correctly in persistence extensions HOT 3
- What to do with my 'fake' device code
- Possible Startup loop HOT 2
- Skipping setup causes issues due to locale not being set HOT 2
- [Feature] Add support to format channel-type description using `html` tags HOT 1
- oh-rollershutter-item with stateInCenter set doesn't respect State Description Pattern HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openhab-core.