top | item 34645370

Show HN: Makejinja: Automatically generate complex Home Assistant configurations

14 points| mlenz | 3 years ago |github.com

makejinja can be used to automatically generate files from Jinja templates. This allows you to load variables from external files or create repeating patterns via loops. A very interesting use case for this tool is generating config files for Home Assistant: Using the same language that the built-in templates use, you can greatly simplify your configuration. When creating for example dashboards, it allows you to create a view for each room based on a single common template, dramatically reducing the maintenance overhead of complex dashboards. I originally developed this for my smarthome setup, but thought it may be useful for others as well!

A concrete example for Home Assistant can be found in the tests directory: https://github.com/mirkolenz/makejinja/blob/main/tests/data

For more information like detailed features or installation/usage instructions, please visit the GitHub repo.

13 comments

order

kkfx|3 years ago

I always ask myself anytime I have to deal with my HA or k8s stuff why the hell people want to shot themselves in the genitals with YAML crap instead of using a damn programming language for a damn personal config.

japanuspus|3 years ago

My impression is that most people doing heavy automatisation in Home Assistant are using Node Red or AppDaemon [1] almost exclusively.

    [0]: https://community.home-assistant.io/t/home-assistant-community-add-on-node-red/55023
    [1]: https://community.home-assistant.io/t/home-assistant-community-add-on-appdaemon-4/163259

mlenz|3 years ago

I totally agree, yaml is just messy when used for anything near complex. This is also why most automations in my home assistant setup are written in Python using AppDaemon. But I did not find anything good for dashboards, so I tried to reduce duplicate code as much as possible using makejinja.

MattDemers|3 years ago

Happy to see this, mostly because HomeAssistant stuff is nowhere near consumer-ready. I barely have the Docker knowledge to get it working in the first place on my NAS, and even just doing basic automations assumes you know much more coding/process stuff than the typical normie.

chomp|3 years ago

> mostly because HomeAssistant stuff is nowhere near consumer-ready

I don't think that's quite accurate, normal people probably won't be able to set up complex automations, but having used Control4 and HomeAssistant's configuration tools, both are somewhat equivalent in difficulty, with C4 having a slight edge because there's a lot of hardware vendors who deeply integrate with it. A lot of the families I've done home automation for would have been able to consume HomeAssistant without any issues. There was one person who had a high end setup involving whole home video involving matrix switches that I am hesitant to make that claim for.

Important to know that most "normies" that consume home automation have a tech representative who deals with their setup.

wkat4242|3 years ago

I don't think it has to be anyway. When it becomes too consumer-focused, the value-add for us techies is lost. Because mainstreaming invariably comes with reduced power user features. Home Assistant is also heading in this direction with deprecating valuable stuff like raspberry pi gpio support.

I don't use Apple stuff anymore either because it's too restrictive for my usecases. I use FreeBSD and ungoogled Android now.

I don't want HA to go the same way. Of course what they do is up to them but I don't think everything should necessarily be for everyone. If FreeBSD (or Linux)+KDE was for everyone for example, it would no longer be for me.

mlenz|3 years ago

While they try to move basic config to the UI, most stuff still requires yaml in the end. So I also think they still have a long way to go to appeal to regular users. makejinja also assumes that you know some yaml…

If you try it out and face some issues, feel free to open an issue. Maybe I can do a few things to make this tool easier to use for users without a programming background.