Im using Web Api for building web based Homey Dashboard. To retrieve updates (for devices, activities, alarms,) from my Homey, does Web Api support pushing events/notification to my web app or do I need to poll for new updates frequently?
I’m pretty sure that makeCapabilityInstance doesn’t work from a web app (one that runs in a browser). I remember having tried and got errors inside of athom-api.min.js that I didn’t bother debugging because of lack of source maps.
I see, that’s problem #1 solved. Problem #2 is that you’ll need dozens, if not hundreds of listeners if you want to catch all capability changes, but it looks like socket.io is being used under the hood, so it should be possible to tap into that event stream. I’ll try and see if I can get something to work.
Nice, this is very useful! It would be good if we could subscribe on specific topic/group in stead of each device capability, but it is still doable.
What exactly is HomeyAPI.ManagerFlowToken.getFlowTokens() used for? I thought this was also two-way sync for latest device and Homey status, but maybe I misunderstood?
I dont know anything about tapping into the socket.io event steam, but it sounds like a good way to go about it.
A dashboard is in fact incredibility similar to how the groups app works.
There are two ‘tricks’ a) you only need to subscribe to the capabilities the devices you have. b) You can easily loop though ‘all devices’ and for each device - loop through ’ all capabilities and just add a listener. - three lines of code