the buttons are triggert the way they should…
So… when the vibration sensor is “ON” the Button “received mail” is pressed.
Unfortunately it is triggered to the OFF-state also as the script is written.
What I would like to have: I want the button to stay at “received mail” till I got out the my mails from the letterbox and press the second button “mail is empty”…
And here is the problem I am too dumb to solve (tried about 2 hours without any good results)…
How can I tell the script that it should jump to “OFF” by clicking on the button and else stay at “ON”?
With a system as flexible and complex as OH there are several ways to go about this. The best way to do this is partially outside the widget system. What you want to do here is work with an additional item and then use that item in the widget.
Your vibration sensor item is “linked” to the sensor channel of the sensor thing. You’ve clearly gotten that far. But because the item is linked, it will always respond to information sent to it by the thing via the channel. So that vibration sensor item simply cannot have the behavior you want. What you are looking for is an item that turns on when the sensor turns on, but only turns off when manually operated. So you’ll have to create that item and tell it about what you want it to do.
Create an switch item that is not linked to any channel. Settings → Items → blue plus button → Add item:
This is one of the most important ideas when starting to work with more advanced OH functionality. Items do not just have to be linked to channels, items can also exist on their own and be used in dozens of different ways.
Next you want to configure it so that when your vibration sensor turns on, then this new switch item turns on. Well, that’s just an OH rule: when X then Y. This very simple rule can be configured right in the rule UI easily. Create a new rule and give it some readable name in the Name section (and an optionally a brief description if you want to). In the When section you set an item event that uses your vibration sensor item and says changed and set to state to ON (depending on how your vibration alarm is configured it may say ALARM instead of ON, that’s fine, they’re the same thing as far as OH is concerned). In the Then section you set an item action that has your new switch item and sends it an ON command.
Now you’re ready for a UI button for the new switch item, but it’s actually much simpler now because the rule is doing most of the logic for you; you just want to be able to control the switch manually. In this case props.item should now be set to your new switch item, but it would look something like this:
OpenHub is quite powerfull… but also very confusing…
Yesterday I tried to send messages to Telegram…
Was no problem… to send a testmail… but what works in one programming language of course doesn’t work in another