[SOLVED] REST Api SSE and Unity3d

I am trying to make an interface app in unity3d using the REST api. I’m completely new to this concept. I pretty much been able to read and write the json data and connected it to my UI. The only thing that I’ve been looking for all over the web is how to use the event stream without success. My goal is to somehow get the event stream data and integrate it into Unity3d’s eventsystem. If I manage that the possibilities is almost endless.

Was thinking about polling at first but that would result in LOADS of unnecessary network activity. And to keep that down a sluggish UI.

Anyone skilled in C# and have played around in Unity that would be able to point me in the right direction. I have been using an unity asset named “REST Client” that uses promises to simplify the api calls. I just have not been able to figure out how to open a stream. I guess one could use DownloadHandler but then the data would not be accessible until download is complete if I understand it right.

Im am not very skilled in the programming field and way out of my depth here, so please bare that in mind if the question seem stupid. The whole project is mostly for the learning experiance.

[EDIT] As I realise this might be more of a Unity3d question I took it over there. (Post)

I have used REST API elsewhere outside OH but not SSE. Have you seen this doc?


Thanks. I actually had not seen that so that’s all good.

After a little bit more research this was actually simple to achive as it is a function in .net wish Unity is intertwined with. Used this library (EvtSource) to read the data stream and setup eventsystem for future reference.

I want to control my house while beeing in a VR-Copy of my house. that would be cool …

I was thinking the same thing but AR, well it seems that there should be no problem getting the data into unity, I have managed to create an simple toggle switch at the moment. So the possibilities are pretty much endless. Was planning on releasing some prefabs when I get the most common stuff finnished if anybody is interested.

I got the idea when implementing pmpkk’s House shadow genious script when building Habpanel stuff.

Was thinking I would steal that idea and implement it on a 3d rendering of my house and incorparate current light states into “real” lights in the model when the sun is down. Then you could do weather, and all kind of unnecessary, useless but cool looking things :grin:

And if you are finished, you can sell that as a service to people who plan smart houses :slight_smile: