Giter VIP home page Giter VIP logo

Comments (7)

rkoshak avatar rkoshak commented on August 15, 2024 1

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.

spacemanspiff2007 avatar spacemanspiff2007 commented on August 15, 2024 1

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.

rkoshak avatar rkoshak commented on August 15, 2024 1

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:

  1. It never received any events after OH started up. This case is handled easily with a boolean flag.

  2. 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.

ssalonen avatar ssalonen commented on August 15, 2024

Could also have "initial expiration duration", used only for the situation when there is no incoming events

from openhab-core.

rkoshak avatar rkoshak commented on August 15, 2024

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.

spacemanspiff2007 avatar spacemanspiff2007 commented on August 15, 2024

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.

ssalonen avatar ssalonen commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.