I am pretty new to hass
, but I am already fed up with the YAML configuration .
Thanks to node.js, I found a way to use JSON instead on my ubuntu based server.
- Install node.js:
sudo apt install nodejs
- Install the package yamljs:
sudo npm install -g yamljs
- Convert your existing configuration.yaml:
yaml2json .homeassistant/configuration.yaml -p > .homeassistant/configuration.json
- Edit .homeassistant/configuration.json as you like
- Convert it back to yaml
json2yaml .homeassistant/configuration.json > .homeassistant/configuration.yaml
- Restart hass
In addition, I you have hass
running as a service, you can automate step 5 by adding this line to etc/systemd/system/home-assistant@[user].service
:
ExecStartPre=/bin/sh -c "/usr/bin/json2yaml ~/.homeassistant/configuration.json > ~/.homeassistant/configuration.yaml"
Whenever you restart with sudo systemctl restart home-assistant@[user]
, the existing yaml will be overwritten with the converted json before starting hass