Hi all,
I have played a little bit with Eclipse Theia today and ended up having it working on my PINE A64 alongside my OH instance. Theia is very similar to VS Code and can run VS Code extensions (including the openHAB extension!). I see potential in this to provide a preconfigured, ready-to-go, predictable environment, and perhaps even advanced editing features like extensions to provide e.g. ways to edit JSON DB-based entities on the local instance. Because all settings and preferences and workspaces reside on your server, you can access the IDE from any device and resume editing.
Also, the âopen consoleâ command works out of the box - since the terminal runs on localhost no need to allow SSH access for other hosts.
Maybe Docker images could be uploaded to Docker Hub in the future for different architectures, but for now youâll have to build it yourself. I have successfully built it on my PINE A64 where my production instance is, and on my AMD64 workstation.
Instructions with screenshots below (copied from GitHub - ghys/openhab-ide: A pre-configured Eclipse Theia (https://theia-ide.org) tailored for openHAB development & configuration, to install on your appliance.). Let me know if it works for you if you try it!
Prerequisites
-
Docker 19.03+
-
4 GB+ of free disk space for the image
-
2 GB+ RAM preferred (might work with 1 GB but no guarantees)
Itâs also possible to run outside Docker. Check the Theia prerequisites (node, yarn, build toolsâŠ): Theia - Cloud and Desktop IDE Platform and adapt the commands from those in the Dockerfile.
Build the image
(TODO: docker-compose file)
1. Clone the repository
git clone https://github.com/ghys/openhab-ide
cd openhab-ide
2. Build the image
docker build -t openhab-ide .
The build process can take a while (~30 minutes on a PINE A64 with 2 GB RAM), be patient.
It should end with:
Successfully built 72a1c4ec78cd
Successfully tagged openhab-ide:latest
3. Run
Start a container with the newly built image (define $OPENHAB_CONF or replace it below with the location of your openHAB configuration folder e.g. /etc/openhab
or /opt/openhab/conf
):
docker run --rm -v $OPENHAB_CONF:/srv/openhab --net=host --name openhab-ide openhab-ide:latest /srv/openhab
(--net=host
ensures your local openHAB instance on localhost:8080
(by default) will be accessible.)
4. Retrieve the token to access the IDE
Run:
docker logs openhab-ide
and look in the logs for:
...
access url: https://0.0.0.0:10443?token=9b2a11b5da6ff262b7a73d9676f63bc5
token: 9b2a11b5da6ff262b7a73d9676f63bc5
...
Copy the token.
NOTE: The token is generated randomly by default and will change every time you run the container. You can add e.g. -e token=mysecrettoken
in the docker run
command above to define it yourself.
5. Open the IDE in a browser
You will get a HTTPS error (âyour connection isnât privateâ or similar) because the TLS certificate is self-signed and invalid. Ignore it the warning for now - click Advanced then Continue (or similar).
Open https://<host>:10443
and paste the token in the login page.
(You can also open directly https://<host>:10443?token=<token>
and/or bookmark the address with the token once youâre in).
Verify that your configuration appears in the file explorer on the left, and that the list of items from your local openHAB instance appear.
There will be an error for the list of things, however, because you have to configure the authorization to the API by setting an API token.
Follow openHAB API tokens | openHAB to generate one, then in the IDE, open the File > Settings > Open Preferences menu, and in the openHAB section, click Edit in settings.json below Username and specify the token there.
The settings should resemble the following:
{
"openhab.host": "localhost",
"openhab.username": "oh.ide.CFWsJZ799oi3GcLSLd1C..."
}
Save the settings.json file, and go to the openHAB panel and click the Refresh buttons in the Things pane header. The list of Things should now appear.
TODO: improve this - allow setting the API token from Docker.
Roadmap
- Activate Python support
- Reactivate Git plugin
- Allow editing managed objects (using the JSON DB) in YAML with a virtual filesystem?