One Shot Items

Hi,
I have a lot of events I trigger via Tasker of my cell phone. Some of them are just items that have a “state” (e.g. an Item NightMode) but I have several events I want to trigger and forget (alarm clock is ringing), where the is no “OFF” state.

Is there an item for this kind of “one shot” events (didn’t know what to type in the search here) to use in the rule files?

How can I implement that in a sitemap?

regards, Dave

Hi,
I might have missunderstood, but it looks like you would like to show something in sitemap conditionally?
You can put attribute next to pretty much anything in sitemaps and hide it if it is not relevant. Check out the documentation here
https://docs.openhab.org/configuration/sitemaps.html#visibility

I use it to display some important events/alarms, f.eks. I have a “AlarmText” item that is shown in the sitemap only if it has some text, like “Water leakage in dishwasher” or “Smoke Alarm triggered”. I also have a “dismiss” button next to it that will set its value to empty, and thus hiding it basically.

Did that help?

Not that clear what you want ovetall.

The ‘expire’ binding is very handy to set up an Item that can respond to an event, and later after a period revert to a passive state.

The ‘visibility’ option in Sitemaps allows to display an Item only when it is in certain state.

Are these the kind of building bricks needed?

No, sorry, if I described it unclearly… In short: I want to have buttton instread of a switch in the sitemap…

I want to have the same in the rules: An event that is triggert one time, but has no state…

Rules are always triggered by events, typically by a change in state of some Item.

There is no reason why a rule cannot change the value of a triggering Item e.g. back to an ‘inactive’ state. It’s a good way to build a pushbutton effect on a sitemap.

For myself, I use the expire binding to revert the state of the pushbutton Item after a second or three. That prevents multiple pushes at the sitemap and the rule only triggers at first push.

1 Like

A search for “pushbutton” would have lead you here:

2 Likes

Without knowing the correct term to search for, how would it have helped? Please be kind to us beginners; we are still learning and trying to understand.

1 Like
Switch TEST "TEST" {autoupdate="false"}

Then only the Commands/Events in Openhab

15:53:16.774 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TEST' received command ON

The Item only Updates wenn you make a postUpdate

Thanks, that was I was looking for…

Yeah… maybe… but it’s bad software design if You have to use a two state item (switch) to trigger a one shot event.
it would be better if there is a seperate item (e.g. “button”) that could trigger a one shot rule…

Or better: It should be possible to trigger a rule manually without the events (ignoring the “when”-part).

1 Like

Sorry, did not mean to be rude, so please appologise.

If it makes you feel better, you could think of it as ‘event’ and ‘not event’.
Bear in mind it’s a home automation system, not a general programming language. In the real world that we are modelling, all switches and sensors are at least two-state.

You might want a one-shot, others might want a single event (state change) that triggers multiple rules. Either case can be built in OpenHAB.

I can’t see any case to trigger a rule manually. It’s very easy to create test/diagnostic Items (switches, buttons) and use them as tools. Rules support OR triggering of one rule by different events, which makes that easy. And would also make ‘manual’ triggering difficult … you’d have to also select which one of several triggers was supposed to have been simulated.

(I keep two sitemaps - a normal one, and a toolkit one with various extras to clear states or force conditions)

It’s probably just a familiarity thing, like most languages you find a preferred way to develop using whatever is convenient.

No… exactly that’s the problem…
In Germany we have “switches” (German Schalter) and “buttons” (Taster)… not sure what the correct English term is… But a “Taster” just gives an electrical impulse (one shot) to trigger a relais that (for example) switches a light on. I’m sure that there is something similar in the US.

Year… But as I said, it’s not SW design if you are forced to missuse a switch as a one shot button (or push button, or what ever the term is).

Hmmm… But it should be… I’m missing some general feature… especially an easy-to-use option to implement reusable procedures/functions (today I for example implemented a loop that simulates a sun set with philipps hue… I used it several times and it’s a lot of redundant code since I can’t reuse the code).

I can’t see any case to trigger a rule manually

It would be a neat alternative to one shot Items… I have a lot of stuff that I trigger via Tasker… It’s just not right, that my “GoToBed” Item has an OFF and an ON state (I also have a “BeInBed-Item” there it makes sense)…

I think this is an important missing “feature”…

regards, Dave

I’m not in the US either, but of course pushbuttons or pushswitches exist.
These have two states, pressed and not-pressed.
It follows there are two associated events, changing to pressed and changing to not-pressed.

In OpenHAB you can trigger rules from the events.
These triggers are automatically a one-shot event.
The rule won’t run again until the event happens again.
Inside the rule, you can examine the state if you wish.

That seems simple enough. It’s not that difficult to add rules to look for long presses, double presses etc. if you want.

The various UI’s lack an instant pushbutton simulation, perhaps because different folk want different effects (timed release, manual release, feedback from end device etc.)
But it’s not difficult to construct the type of effect you want in a combination of Item definitions and Sitemap display.

I think this is just terminology.

I think there is a misunderstanding. In openHab, you would define a switch to reflect the state of your relais, not the „Taster“. For example using digitalSTROM devices, you need to change your installation from switches to „Taster“, but you setup the device in openHAB, not the „Taster“.

You can have reusable code in your rules file, defining this part as a lambda (function). If you search for iCloud data integration, you will find a discussion showing a great example for lambdas.
Before the according binding was written, a rule was created to retrieve data from iCloud and parse this as String Items.
Having more than one device or even more than one iCloud account, the complete rule was copied for each device.
We then optimised the rule and created several lambdas to avoid code redundancy.

I think this will be implemented in the near future, as we already introduced trigger channels, which don‘t have a real state, e.g. used in Milight Binding for acticating the NightMode.

1 Like

I know that it’s possible to implement that with OH, I only said that it’s not good design if you are forced to simulate a simple thing like a pushbutton using a switch (withautoupdate and mappings etc) instead of having a seperate oneshot Item from type “pushbutton” or something like that…

[quote=“hmerk, post:14, topic:38178”]
this part as a lambda (function)[/quote]
Thanks… that was the keyword I was looking for… Doesn’t look very intuitive, but well…

If you don’t like the design of the Rules DSL and don’t find lambdas intuitive then you might be happier using the JSR223 add-on and coding your rules in Jython, JavaScript, or Groovy.

Or submit an issue and a PR to add the feature you are missing.

The referred to switches sound like a contact switch, like a start or stop button on a machine.

Hi guys,

i am looking for a similar thing i guess…
i have 12V led pool spots which changes the color buy turning it off and on again very quick… so beside thenormal on/off switch of the leds I would like to put a button which sent this event to the knx gateway. so it sends a fast off and on statement to that groupaddress… any idea how to make it?

kind regards,

Oliver