openhab / openhab-windows

Universal Windows App for openHAB
Eclipse Public License 2.0
89 stars 55 forks source link

Sync app widgets with openHAB server #36

Closed NicoVermeir closed 6 years ago

NicoVermeir commented 7 years ago

the widgets should respons to actions taken from other clients.

for example: when I change a slider value from an android device with habdroid, the corresponding widget on the windows app should set the new value as well so that the app stays in sync with the server

Alex-Witkowski commented 7 years ago

Maybe you can have a look at : https://github.com/Alex-Witkowski/openhab.windows/tree/EventSubscriptionTest

It is a first proof of concept with event stream. Currently I'm not very happy with the quality but its time for bed :)

I tried to get long polling to work but was not successful. @NicoVermeir Do you have any documentation that is up to date?

NicoVermeir commented 7 years ago

@Alex-Witkowski There are two mechanisms:

  1. General „item update push events“: https://www.eclipse.org/smarthome/documentation/features/rest.html#server-sent-events-sse
  2. Specific subscription for a certain page of a sitemap. This has been recently implemented for the Basic UI. You will find it described here: https://github.com/eclipse/smarthome/pull/2030#issuecomment-243067684

Both use SSE, I've ported EventSource4Net to win8.1 universal in the past for a similar project. not sure if that's better than your version https://github.com/NicoVermeir/HomeGenie-WindowsPhone/tree/master/EventSource4Net.Universal

NicoVermeir commented 7 years ago

@Alex-Witkowski are you still working on this? just to make sure that we're not working on the same things :)

Alex-Witkowski commented 7 years ago

At the moment I have a lot of load at work and therefor don't have time to code on the app.

So my approach was the "General item update push" and send update events over messenger. Widgets that where actually displayed subscribe to update messages. I think it's not the worst solution but the SSE handling needs improvement.

Any time frame for the next release?

NicoVermeir commented 7 years ago

depends on when I actually figure out how git works...

also need to discuss a release cycle with the openhab guys so no idea at the moment

NicoVermeir commented 6 years ago

fixed in upcoming version

lolodomo commented 6 years ago

That was THE bug that makes the application unusable. Thank you.

For my information, what mechanism are you using for updates ? SSE events ?

NicoVermeir commented 6 years ago

SSE events indeed. the openHAB api exposes the events through a stream

the code is at the bottom of this file https://github.com/openhab/openhab.windows/blob/master/Openhab.Core/SDK/OpenHAB.cs