openhab / openhab-vscode

VS Code extension for openHAB configuration files
https://marketplace.visualstudio.com/items?itemName=openhab.openhab
Eclipse Public License 2.0
159 stars 47 forks source link

[RFC] Add a FileSystemProvider to allow editing objects remotely #248

Open ghys opened 3 years ago

ghys commented 3 years ago

VS Code provides an API for extensions to register new filesystem schemes: https://code.visualstudio.com/api/references/vscode-api#FileSystemProvider.

It could be very cool to be able to map openHAB objects as reported by the REST API (therefore allowing to edit managed objects the JSON DB remotely) to virtual files in a openhab:// scheme, maybe like this:

openhab://{host}[:{port}]/
  +-- items
   |- gKitchen.yaml
   |- HueKitchen.yaml
   |- HueKitchen_Brightness.yaml
   \ ...
  +-- pages
   |- floorplan_groundfloor.yaml
   |- home.yaml
   |- layout1.yaml
   |- overview.yaml
   \ ...
  +-- rules
   |- back_home.yaml
   |- leaving.yaml
   |- scene_bedtime.yaml
   |- python_test.yaml
   \ ...
  +-- sitemaps
   |- default.yaml
   |- example.yaml
   \ ...
  +-- things
   |- hue_bridge1_23.yaml
   |- mqtt_broker_broker1.yaml
   |- mqtt_topic_broker1_sensor1.yaml
   |- network_bridge1_23.yaml
   \ ...
  +-- widgets
   |- heating_thermostat.yaml
   |- multimedia_player.yaml
   |- widget123.yaml
   \ ...

That way it would become possible to open a "file" like openhab://openhabianpi:8080/things/mqtt_topic_broker1_sensor1.yaml. Other UI elements in the extension could take advantage of that, for example a "Open" menu entry in the Things/Item editor. Maybe even add the entire openhab://host:port root directory to a workspace and see the contents in the file explorer, like the MemFS sample here: https://github.com/microsoft/vscode-extension-samples/tree/main/fsprovider-sample

memfs sample

The host:port part could be optional since the extension supports a single server in settings.

Some initial considerations:

Confectrician commented 3 years ago

Nice and well explained idea. :) I would like te evaluate this a bit deeper after the 1.0.0 release.

I think token based auth should be on top of the prio list currently. :)