How-To use the IDE add-on for Home Assistant

Home Assistant has a few ways to access and edit the configuration files, but there is one particular way that makes it a lot easier and even convenient. Today, we are going to be looking at the IDE add-on for Home Assistant. This add-on is a packaged version of the Cloud9 IDE which is an online integrated development environment that has been tuned for use with Home Assistant. You’d be able to manage your Home Assistant configuration files directly from a web browser. It also includes a terminal so you can check your configuration and restart Home Assistant.

 

How to set it up

Open Home Assistant, and go to Hass.io, Add-on Store, select IDE and click on Install. Once installed, scroll down to Config and set up a new username and a password. If you set up a DuckDNS URL for your Home Assistant, change the SSL from false to true so like that the connection to the IDE is encrypted.

{
  "log_level": "info",
  "username": "Your_Username",
  "password": "Your_Password",
  "ssl": true,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "packages": [],
  "init_commands": []
}

When finished, click on Save, and before you start the add-on, you need to create a port forwarding rule on your router so when you try to access the IDE, it direct traffic through the add-on port which is 8321.

 

All routers are different so I wouldn’t be able to tell you how to set it up on your router. For you to have an idea, I’m going to show you how to do it on an Asus router. There is a website called portforward.com that has step by step instructions on how to set up port forwarding rules on different types of routers. You can check that website for more assistance with the particular router that you have.

 

Set up a port forwarding rule

When you access the port forwarding settings on your router, name the new rule, Hass.io Cloud9 IDE then set the Port range to 8321, the Local IP set it to your Raspberry Pi’s IP address, for the Local Port, set it to 8321 as well and set the Protocol to TCP.

IDE Port forwarding rule

 

Click on Add then Apply and reboot your router to apply the changes. After the router is back online, go back to Home Assistant and start the add-on. Give it like a minute for the IDE to start and then click on Open Web UI. When the IDE opens, you can see the Home Assistant file tree on the left side. In the middle, the code editor, and on the bottom, the terminal.

IDE window

 

Split code editor view

Everything comes separated into tabs which you can move around and set it to the way you want it. For example, if you open 2 files, and you want to have them open side by side or one on top of the other, you can just grab one of the tabs and drag it to the right side or to the bottom, and it would split the editor into columns or rows. You can also resize the terminal window so when you are editing you can get the terminal out of the way and gain more screen real estate and resize it again when need it. Having access to the terminal directly from the IDE is very convenient. You can simply run the command to check your configuration after you edit something and also restart Home Assistant without leave the editor.

IDE split editor

 

You can also resize the file tree and the top menu bar to gain more screen real estate. These options are very convenient when working from a laptop for example. To Minimized the file tree, click on Workspace and for the top menu bar, click on the triangle on the left.

 

Set up a dark theme

The IDE also has themes available, so if you would like to change it to a dark theme, for example, you can go to View, Themes, UI Themes and select the theme that you would like. You can also change the theme for just the editor window and not the whole UI. To do that, go back to View, Themes and the themes for the editor would be right below the UI Themes drop-down. The Terminal can also be customized, but you would have to go into Preferences and then click on Terminal.

IDE dark theme

 

Embed the IDE in Home Assistant

Embedding the IDE in Home Assistant would add an option on the sidebar to open it directly in the Home Assistant frontend. To set it up, open the configuration.yaml file and enter the following:

panel_iframe:
  ide:
    title: IDE
    icon: mdi:code-braces
    url: https://your_domain.duckdns.org:8321

Then, click on File and then Save. After that, use the terminal to restart Home Assistant using the command, hassio ha restart. After home Assistant restarts, you would now have the IDE option on the sidebar. When you click on it, it would open the IDE directly from the Home Assistant frontend.

IDE embedded to HA

 

WANT TO SUPPORT JUANMTECH?

You can do so now on Patreon and Buy Me A Coffee

Leave a Reply