QuailAutomation / openhab2-addons

The next-generation open Home Automation Bus (openHAB)
Eclipse Public License 2.0
8 stars 7 forks source link

button presses #20

Closed digitaldan closed 5 years ago

digitaldan commented 7 years ago

I noticed that in https://github.com/QuailAutomation/openhab2-addons/blob/digitaldan-omnilink-binding-thing-types/addons/binding/org.openhab.binding.omnilink/src/main/java/org/openhab/binding/omnilink/handler/ButtonHandler.java#L32 we are setting the state of a button to on or off if we get a event notification. Is this the correct behavior? I think a button press just means a macro was executed (like a event), but does not represent state, and for example this would never get set to off? I think buttons are stateless. We might want to look at triggers in OH for button events, I have not played with them yet, but I think this may be what we want.

craigham commented 7 years ago

ya, I think the way it was coded just so someone could write rules which trigger on button presses. I was unaware of triggers.

boc-tothefuture commented 7 years ago

Yeah, having a button 'on' doesn't make a lot of sense in am omni world. But we do need a way of detecting when a button is pressed and having some rules driven off that where necessary. As long as triggers support that, I think that would be good.

boc-tothefuture commented 7 years ago

@digitaldan I am not seeing anything on triggers, do you have a link you can share?

digitaldan commented 7 years ago

I have not used them personally, but here is kai announcing them. https://github.com/eclipse/smarthome/issues/1043 I believe we would have a button channel still for UI's or rules to issue a button command, but the trigger notification would be translated to a trigger channel where rules could respond. Again, this is my understanding of triggers, but I have not used them at all yet.

digitaldan commented 7 years ago

but the trigger notification would be translated to a trigger channel where rules could respond

Sorry i typed that on my mobile, I meant button notifications (from omnilink) would be translated to trigger channel events.

boc-tothefuture commented 7 years ago

@craigham and @digitaldan what is the status on this issue?

digitaldan commented 7 years ago

So I have this PR https://github.com/digitaldan/jomnilink/pull/13 which implements the system event notifications and then this branch https://github.com/digitaldan/openhab2-addons/tree/omni-system-events which implements those into trigger channels.

The good news is that the button trigger events work great. So this issue will be closed when I submit the PR and we merge it.

The bad news is that I don't see any of the other events get triggered. I have not tested them all, but the phone line events and zone events are not coming across the omnilink connections ( no data on the wire period).

This is where the omni documentation is not clear. Some of these events may need to be queried, and it says that apps may "poll" for updates and will get any that happened since the last poll (boo). But it also says that events will be generated as they happen, which is what happens with button events. I'm away from my system on vacation this week so I have not touched this in about a week.

W6HBR commented 6 years ago

Since this issue is still open, I'm inquiring here as to the status of how HAI buttons are handled.

Currently, my buttons are configured as an on/off switch. When activating the button from either BasicUI or the IOS app, the button briefly toggles to ON, then quickly back to OFF. This works as I would expect.

However, after OpenHAB has been running for a period of time, all buttons stop doing the quick on/off and instead will stay on when activating the button. It then requires a second tap to turn it off, which also triggers the button actions a second time. If I stop and restart OpenHAB, the brief on behavior returns to normal again, but only for a period of time. I have not determined yet how long it needs to run before it reverts to the unwanted behavior.

Possibly, something is wrong with my configuration of buttons. My items file includes button examples as follows: Switch hai_button_010 "Espresso On" (Group_Buttons) {channel="omnilink:button:home:10:press"} Switch hai_button_011 "Espresso Off" (Group_Buttons) {channel="omnilink:button:home:11:press"} My sitemap file includes button examples as follows: Switch item=hai_button_010 label="Espresso On" icon="switch" Switch item=hai_button_011 label="Espresso Off" icon="switch"

boc-tothefuture commented 6 years ago

@BCS-JonW HAI buttons are tricky because they aren't really a switch because they don't actually have state. Your item needs to turn off autoupdate Switch Buttons_Goodnight "Goodnight []" { channel="omnilink:button:home:goodnight:press", autoupdate="false" } In your sitemap, it should look like the following: Switch item=Buttons_Goodnight label="" mappings=[ON='Goodnight'] icon="moon" That gets you a momentary button that you can press to act like a macro - which is essentially what an HAI button is.

Also, there is no 'state' associated w/ the buttons so we can't tell if a button is running or not, etc. So it can't really have an on/off. The reason it looks like it starts to work in your case is because you have autoupdate on which is really just a lie from openhab.

boc-tothefuture commented 5 years ago

@craigham - I think buttons are correctly implemented so we can close this.

boc-tothefuture commented 5 years ago

@craigham - bump to close.