-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strategy for config methods #143
Comments
Throwing in another reason why the configuration.yaml approach is preferred by a set of users: clean backups (when not running in hass.io). With all of my configuration managed in yaml files and living on github. I can bootstrap a replacement home assistant instance by just cloning the repo down. With config entries managed by the UI, that approach no longer works. I need to keep the storage directory also backed up somewhere and need both of those to bootstrap a replacement instance. I would vote for a hybrid approach for that reason. Allowing users to use either approach if they have a preference but still allowing for easy backups. |
Configuration entries are still text files. They can still be edited by hand, and they can still be checked in to source control. The biggest difference is that breaking changes can be automatically migrated between versions without user intervention. |
Something I think would be a good approach is using In effect, this would mean that:
Another advantage to this strategy is that as we transition to more UI based configuration tools, the need for a |
(Sorry this got a bit long and rambly) I am a new user who is starting to contribute more and wondered if my "journey" through the stages of HA was in any way helpful/interesting?
I kind of feel like i've had every viewpoint on this in my HA journey so far! And this ticket has made me realise i'm still quite conflicted about what I even want myself. I'm never going to want to check config entries into my Git CD, especially where they have secrets. And I don't like the idea of an approach where some of my yaml is in Git and some isn't. On the whole based on my experience to date I think i'm currently a (2). If (1) was chosen, i'd want YAML configuration to enhance and enrich my existing configentries - i don't ever want to have to try and pair a homekit device by hand because i need to turn on a single advanced option for one device (luckily there are no such options right now). |
I'm all for (1) and guess that's what @carlos-sarmiento described, which I fully agree upon |
I came here from the link in the Reddit thread. You're going to get a lot of selection bias on these comments - the people who already use HA, and who are likely to comment on a Github issue are much more likely to be power users who are comfortable editing a yaml file. I have my HA config yaml in git, and use ansible to deploy HA and the config to a docker container. I don't currently do anything to back up HA's "running state" from its .storage directory. At the moment, the only state which I would lose if my docker host vanished would be the authentication tokens used to talk to my Tradfri lights. Of the three presented options, my preferred outcome would be (1) as it means I can keep my current workflow. It wouldn't be the end of the world if (2) happened and I had to abandon my yaml, configure everything in the UI and take backups of it. I would really miss the ability to have version control, but I could probably find a backup strategy which works. However, option (3) would lead to a mess. You'd have some modules which can only be configured in yaml and others which are only done through the UI, depending on the developer's preferences. |
This thread was pointed out to me by a friend and I've been asked to chime in. I'm also in favor of hybrid solution outlined in Option 1 by @bachya. It will provide good middle of the road option by implementing essentially a tiered config model where anything from config files overwrites similarly named entries. It shouldn't be too hard to implement it by reading whatever is in .storage (and configured by gui) then overlaying configuration parameters from .yaml on top. Sometimes I want components to work the exact way that suits my case and other times I want components start working with a click of a button and both ways have their merit in respective situations. |
One thing I didn't see anyone mention which seems fundamental is that if you can't start the UI, you also won't have tools to access/edit/troubleshoot it. That's why I like @carlos-sarmiento approach. It extends the typical concept of HA supporting personal choices and providing options. |
I think it is abundantly clear from that reddit thread, and many other moans across reddit and the forums, that the general consensus of the homeassistant user base is that they do not want to see things move to a gui setup unless that gui setup is complimentary to an easy to access, and easy to share, text based configuration. When the automation ui came out, it output the things you put in to it in to a yaml file that you can access, edit and share. Everything now puts things in .storage where you can't (or you're certainly not supposed to, and you definitely can't easily share it). As @rpitera says, if I cock something up in the ui and my system won't start, I won't have a clue what to look for in storage to fix it. We're all here because we're tinkerers, let us tinker! |
I am the author of the original comment on Reddit. TLDR: I would love to see a pattern where the config directory is readonly YAML, and anything that is configured in the UI writes to Over the past several years, cloud adoption has shifted the mindset to treating servers like cattle rather than pets. Basically, this means that you shouldn't be worried if a machine dies or you need to destroy it, as you should always be able to create one exactly like it very quickly. I see two (i'm sure there are more) general patterns that have become prevalent: Configuration/infrastructure as code Reducing the amount of state that needs to be managed In reality, homeassistant is used by a much broader set of users than those who want to manage stateless systems through configuration as code, and I benefit from the growing userbase as it accelerates development. However, I think you can have your cake and eat it too. Everything I have seen written to This way, users who want to can manage their configuration in source control as YAML files, but it is their responsibility to convert the things that homeassistant writes to edit: Also, let me worry about the compatibility of my YAML configuration with new versions. |
A couple of notes from my side:
|
I might someday use HASS as a solution for a business in home automation. The idea i have is being able to generate automatically the configuration via some tools and only having to start home-assistant for it to work. I know some device entity_id would be known only once they are discovered, but i could then ask the API for the list and generate the final configuration files. Also, for now( as said before) you can share YAML files way more easily than having to write a full tutorial saying where to click to have the same result... |
|
I don't understand how advanced settings in configuration.yaml would work with config entries that support more than one entry. Yes you have your configuration.yaml, but it is still dependent on config entries that live under a different paradigm. Better to expand on config entries. Wouldn't it be possible to separate sensitive keys in a config entry into a config entry secrets file? If backup to GitHub is the main goal for config entries. |
Returning to this after today's Reddit post re: the 108 release sparked another comment-storm on the topic. I've been doing some thinking on how to keep option flows "in sync" with I quickly run into the problem that (I think) @Kane610 is describing above: how can you retroactively marry data from config entries back to their original counterparts in An example of mine is SimpliSafe, which accepts a simplisafe:
accounts:
- username: ...
password: ...
code: 1234
- username: ...
password: ...
code: 9876 Today, if someone were to launch HASS with that configuration, those two accounts would get imported into two config entries. From there on out, no real configuration can be done via I could potentially solve the problem of marrying a config entry to its corresponding "spot" in The second problem – determining who "wins" – is harder. Whose Will think on it more. |
@balloob While I agree that everyone should be grateful for any open source contributions to home assistant and other projects, regardless of whether it's UI for config, or YAML support, but this is still a project that has certain guidelines. Just like you'd reject a contribution that relies on scraping web data, no matter how much effort went into developing it. And there's absolutely nothing wrong with having certain rules on what's acceptable in home assistant ecosystem. Why can there not be a simple policy of "Every integration is to have a config [...] configurable via the UI, overridable via YAML"? Because it seems like with the last release for the UniFi component there was actually work involved in removing the YAML support which was working, because the UI now supports all the features possible via YAML. I understand not adding new features to YAML considering that the developer might not have time or resources to support yaml and UI config, but removing existing features from YAML config does feel like the wrong way to go. It would really be helpful for a lot of people to know what the official stance and goal on this topic is, because I do not think that your comment with "UI support, overridable via YAML" still applies, or is at the very best a personal wish from you but the project is going in a different direction. |
My concern with maintaining both config methods is that it potentially adds a lot of complexity, both from a development perspective and also towards the end user. For example, it's now possible to change options during runtime for some Integrations from the UI (gear in top-right). If these same options are exposed via YAML, which should take precedence? Perhaps the user creates a config via YAML but then decides to change it via the UI. Should it revert back to the YAML setting after restart? If they've changed it via the UI but then want to override it via YAML, which should win? Having two possible sources of truth is usually a Bad Thing. |
So, the config handling has been my pet peeve for long, and I think I have written my proposal in some other issue I cannot locate right now. This following comment is how I would like to see it done on the conceptual level, so I'll try to keep implementation details at minimum. But the gist is something following:
The pros of this:
Some tricky parts that I can think of:
What do you think? This way, in my opinion, it would be possible to keep both types of users (those who want UIs and those who want manual configs) happy while removing lot of cumbersome code duplication. |
I'm a bit surprised that more of the commenters from the reddit Like many other people in this thread, i'm in the systems design/admin trade and put an extremely high value on the ability to modify a file and reload the process to see the configuration change take effect. Git repos are the new pets, servers are the new cattle as it were. I won't go as far as to say that i refuse to adopt a new release because the configuration of some critical component can't be managed by my existing git/file based flow, but I am concerned that each release will bring more things that can no longer be managed via some automation techniques borrowed from my professional duties. I do understand that my needs are not going to align with the bulk of people that HA is (increasingly) aimed at, but I'd like to echo the calls for a more formalized and, possibly core integrated, way to configure things. A HA version of Py-Cerberus perhaps? @rytilahti and others have done a very good job of expressing most of my thoughts far more concisely than i could have; API First, backed by user-accessible file(s) on disk. However, i'd like to make a few additional points that I feel are not being discussed or serve as further support:
TL;DR: a formalization for configuration metadata/schema will be non-trivial, but has many benefits that will make HA a more robust platform that's easier to support and develop for in the future. A patchwork of components all with their own preferred configuration options and a collection of tightly-coupled json files does not do anybody any long-term favors. |
Another approach that is popular in many tools that combine a user-friendly UI with a batch- or scriptable interface is to define configuration in terms of a configuration "scripting" language, combined with a transaction system. Ubiquii's EdgeOS is a good example of this (as is Cisco IOS etc). Another example is if you dump a SQL database into a series of CREATE DATABASE and INSERT statements etc. In these systems, configuration can be driven from a CLI, and saving the currently active configruation produces a CLI script that will recreate it. A configuration script would do something like
Nothing actually happens until the save (or commit) step. Instead of Any change done through the UI can be expressed by such a configuration snippet, and allows for having just a single entry point for configuration changes, a replayable log, and more. This would obviously be a very significant change and maybe not feasible, but I wanted to include it in the discussion. |
The previous 2 comments have both made me think of systems like Kubernetes or Terraform or CloudFormation where configuration can be expressed as a manifest in e.g yaml and applied via the CLI. The are idempotent and could have a dry run mode. This is probably more achievable than a scripting approach. You can then check in your manifest in git, share it on reddit, whatever. But it means that the actual CRUD is against the HA api, not by manipulating the state on disk. Changes made this way wouldn’t need a HA restart. Such a tool could be written for anything that already is UI only, and HA has a command line tool this could live in. |
If we riffed off Kubernetes a bit it might look something like this: kind: Integration
version: v1
domain: esphome
selector:
ip: 1.2.3.4
password: apple-and-pear
---
kind: Scene
version: v1
name: movies
entities:
light.tv_back_light:
state: on
brightness: 125
light.ceiling: off
media_player.sony_bravia_tv:
state: on
source: HDMI 1
state: on
---
kind: Automation
version: v1
name: turn-on-lines
trigger:
platform: state
entity_id: device_tracker.sweetheart
from: "not_home"
to: "home"
action:
service: scene.turn_on
entity_id: scene.romantic Some thoughts:
|
I like these two last comments! We could move the source of truth from the yaml files to |
The strategy has been set out in ADR-0010: #366 |
Seems incredibly unfortunate to close this issue, considering the community response to it. Perhaps it would be better to have a healthy discussion regarding the possible solutions proposed here? I personally like what @Jc2k has proposed. |
I'm with @Jc2k and @TechnicallyJoe on this. It seems like a solution was picked without further discussion with the community, which has proposed some very good solutions to this issue that should work for both power users and newcomers. I've seen talks on the forums and on reddit about forking Home Assistant, which would be unfortunate, but understandable given the unwillingness to listen to the users in here. I would hate to see the community split up, as fragmentation helps no one. |
As i've been tagged twice - full disclosure - i support ADR-0010 and I am not someone who manages my config via yaml (any more). As much as possible i use the new UI features exclusively. And in addition my proposal isn't "the core team should build a CLI for applying manifests for us". My proposal is "we can build this tool using the API's that are already there". So I don't think what i proposed isn't blocked by ADR-0010 at all. It might be that API's might need improving but again, ADR-0010 does not forbid that either if the change is worthwhile in its own right. We only rub up against ADR-0010 when we have some yaml config using the new approach and some using the old approach. If my suggestions are that successful then maybe there will be a conversation to have here, but it will take quite a lot of work to build something that is mature enough AND get the adoption so it is premature to issue an edict about it, I think. I have started toying with a prototype. When its a bit further along i'll throw it up to get PR's. |
I think while the low barrier to entry with configuration via the UI is a noble goal, but it's flawed. If someone wants a simple one size fits all you just use Google, Amazon, or something that does it all for you. I don't care how passionate the developers here are, they will NEVER keep up with a paid army of developers, graphic designers, tech writers, project managers, etc working 40 hours a week on only a product. Nor should they. (Unless the end goal for developers here is to make a platform as a service and have paid developers to do this. While totally valid and very likely profitable, they need to be honest about that.) If this is not the goal I think it should stick with a geek-friendly way of doing things, that is pretty and easy to tweak. I use OSS because I want to have the opportunity to control every aspect of the system. When it works great, but when things go south (read not my opinion of how it should work), I want to be able to dig into it and fix it (read make it my way of doing things). If I didn't care I would just pay for Google or Amazon since my time amounts to the same thing. I do understand and respect where @frenck and @balloob are coming from, and in OSS, those who write the code make the rules. I more agree with @rytilahti's opinion and think the decision not to articulate the configuration flows in YAML, or even just dump/restore YAML is a mistake. Just my 2 cents as someone who codes for fun, reads source code recreationally, and really likes the platform he has found. |
With the 0.87.0 release, the top comment on the Reddit post says:
Subsequent replies to that comment:
1. Promote a Hybrid Model for All Integrations
In this scenario, all integrations would support configuration in both a UI config entry and via
configuration.yaml
– they cannot cherry-pick the one they prefer. Config entries would focus on the "quickest possible route" (i.e., the lowest number of configuration options to get the integration up and running) andconfiguration.yaml
would focus on exposing/tweaking all options.2. Promote UI Config Entries as "The Future"
In this scenario, all integrations would be slowly migrated away from
configuration.yaml
and interacted with via UI config entry only. Over time, the config UI would be expanded to allow more configuration options for each integration.3. To Each Their Own
In this scenario, each integration developer is left to their own devices. If they desire one method or the other (or both), implementation is up to their discretion.
The text was updated successfully, but these errors were encountered: