Settings

Theme

Show HN: Makejinja: Automatically generate complex Home Assistant configurations

github.com

14 points by mlenz 3 years ago · 13 comments · 1 min read

Reader

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.

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
    • kkfx 3 years ago

      Thanks for citing AppDaemon, I'll try it.

      I know Node Red but I consider all visual tools as a nice way to complicate things not to simplify so I never used it. Actually my HA is in an org-mode file tangled in the right place, but just the recent template syntax change was a painful waste of time to update especially since after some update my Victron/MQTT integration have change sensors names for unknown reasons ad I have to craft a monster just have proper p.v. production logs in the energy dashboard... Oh, sure I can even ignore HA but that's is, a giant crapload of YAML...

  • mlenzOP 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.

    • kkfx 3 years ago

      Personally I use org-mode with noweb, it simplify A LITTLE BIT, but not much more than a little and the push toward "integration" vs "in config" setup in HA, plus various syntax changes (last heavy the template syntax) is a nightmare to keep up...

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.

    • shmoogy 3 years ago

      It's not quite there yet, but with all in one devices they are creating - they're trying to make it a little easier. It's significantly better than when I first tried it like 6 years ago, and got a SmartThings hub because I needed something more stable for wife approval.

      I've run into, twice in the past year, some kind of update or config change (that says valid) that made the UI inaccessible and had to quickly spin up a new VM and restore my backup.

      E: many people will be better served by Alexa/Google/Apple hubs with matter integration that support everything with a polished Ui. Those with super techy inclinations - or propensities towards tinkering will want something like HA

    • MattDemers 3 years ago

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

      I wouldn't have assumed that; I was more thinking the "got some Hue bulbs for Christmas and someone pointed them to HA" kind of thing. Thanks for pointing it out.

  • 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.

  • mlenzOP 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.

    • Semaphor 3 years ago

      Most? I guess it depends, I almost exclusively use YAML because I find it easier (mainly because I can copy & paste), but almost every time I could also use the UI.

      • mlenzOP 3 years ago

        UI support has vastly improved in recent versions and you are now able to get a pretty good setup without using yaml at all. Some quite interesting integrations however do still require it (e.g., trend, bayesian), so yaml is needed if you want to utilize home assistant to the max.

        The things I mentioned are niches however, so I assume for the „regular“ user almost everything can now be setup via the UI.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection