Development Environment Ideas

Dear community,

coming from a software development background, I decided to set up a proper CI/CD (continous integration / continous delivery) pipeline based on two environments: one docker based HA installation for development/testing and one for production (running on a different machine).

Getting a pipeline set up should not be an issue and I found several topics in this forum to get me started. What I am missing however is the concept of having two separate environments: yes, I can set up a development environment where I can test out changes to configuration.yaml and yaml based lovelace dashboards. These changes I can commit and using my pipeline, get them checked and deployed into my production environments.

The main challenge for me is changes to my production environment through configuration in the web UI. Since there do not end up in my yaml, my develoment environment does not reflect my real configuration. What approach are you using? Some kind of back-up / restore mechanism to first pull in the current changes from production into development? Or could I solve it through git by tracking addional files? Ideally in this case I would never make changes to production directly but work in development and then push those changes to production.

What works best for you? Is having a development environment a practical approach in the first place?

Alternatively, I am thinking of using only one environment tracked by git so that I could at least do some config validation through my pipeline and get versioning in case something went wrong.

Curious to learn about what’s working for you :slight_smile:

The config for stuff configured in the UI is stored in the hidden directory .storage in json format. But it also contains api tokens, password and other sensitive information, so pushing it to a public git repo is not the best idea :slight_smile:

I’m not a dev, so no CI/CD here.
I have two VMs for Home Assistant one for production and one for “development”, which is actually just a copy of prod and used to test new things or updates and not actually developing something for HA. Once I’m happy with the tests I push the changes to prod through git, for stuff configured through the UI I just do it manually again on prod.

Thanks @Burningstone for sharing your setup. I am using a private git repo, but it still would not be a great idea to push it into the cloud.

I am thinking however, if one-way syncing .storage from prod to dev could work (e.g. using Syncthing). If the directory only changes if I am actively modifying things, then I have it under control.

That being said, I am not sure whether I am gaining much this way. Ideally, all changes happen in the Dev environment and then allow me to safely transfer them into the prod system.

Are you by any chance from Switzerland (just a wild guess from your name xD)?

That’s the problem, .storagealso stores some information like rhe state of some entities to restore them after a restarts, it’s a bit of a mess in the sense that it stores config data and other data.

You guessed right :wink:

That’s the problem, .storage also stores some information like rhe state of some entities to restore them after a restarts, it’s a bit of a mess in the sense that it stores config data and other data.

So I better look for an alternative…

Good day to all

A separate test environment isolated from the production env. but using the same sensors etc is what I am looking for quite some time after more than two times crashing my config.yaml
Has anybody a good concept/config advice?

My production env runs on a raspberry pi 4 with ssh storage
I would like to run my test env on my macbook
What software is usefull for syncing after completion of my work on the test env?

Thanks in advance! Regards from Holland

Hi @HenriV22

mocking/simulating sensors would be a great development feature which to my knowledge does not exist. One way around is to use NodeRed which lets you feed any type of input into your flows and see how the system behaves. Alternatively, you could use the automation testing (templates) and tracing features described on this page: Troubleshooting Automations - Home Assistant

To move things from dev to prod, you might get away with creating and restoring back-ups: Backup - Home Assistant

Hello davosian, thanks for your reply!
Will try next week and share (hopefully) results

Any other ideas would be welcome.

@HenriV22 I was looking for a similar situation. My HA prod runs on a RPi4 and i have a proxmox environenment on a nuc i5 where i run test VM’s with HA. But i am looking for a way to use my sensors and devices in my prod system, to be able to test things (like automations and dashboards) before putting things in prod.
I use a backup from prod and restore that in the VM; and changed some parameters; hostname IP@ etc.

But i do not jet have a solution to use my entities etc from the prod system in test.
How did you go with your test setup? Kind regards, Bert

Hi Bert,
Unfortunately I do not have any experience with a HA test setup that uses my entities.
Yesterday I again ruined my “production” system on Rpi4 after changing some items in my config.yaml
Has anybody a solution for this?

Hi @HenriV22 That is bad ‘luck’. I make daily backups of my prod system and the are stored in de ssd of my RPi4 and also stored on a share on my NAS.
Resently, I was changing my Configuration.yaml in order to use as mush !includes to place as much files in directories in order to get an as clean as possible config file.
Then it happened to me some times. And a restore (sometimes if necessary from the command-line) solves this problem.