WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Addons working together? Cross-addon communication? #2788

Open flatsiedatsie opened 3 years ago

flatsiedatsie commented 3 years ago

This is a bit speculative, but I'm running into some scenario's where I'd like some addons to work together, so that one addon can check if another addon exists (easy enough), and has done some things (harder), or could even provide some information on demand. For example:

I know the macros addon has this macrozilla-variables feature. Is there an official / prefered way for addons to maybe have a shared variable pool? I could hack something together, but I'm curious what the ideal/official way of handling this would be.

mrstegeman commented 3 years ago

WebExtensions support similar functionality: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/externally_connectable

flatsiedatsie commented 3 years ago

Interesting, thanks.

How do you feel about a shared variable store? Addons could purposefully share some things with each other in an indirect manner. Might be relatively easy to implement?

mrstegeman commented 3 years ago

There’s nothing stopping you from doing that yourself. You could just put something in the data directory.

This would just be a more explicit, general-purpose solution. It adds to the whole add-on permission system I’d like to have eventually.

kgiori commented 3 years ago

Also, some add-ons use location (latitude, longitude), and for each one I have to re-copy it into the add-on config. If it were saved as part of the localization config, then I presume add-ons could fetch that as shared info, with perhaps a check-box in the add-on config to override with a different lat/lon.

mrstegeman commented 3 years ago

@kgiori We deliberately chose not to add that as a global setting for privacy reasons. We didn't automatically want to share location info with every add-on.

Here's a related comment/discussion: https://github.com/WebThingsIO/gateway/issues/2249#issuecomment-584768047