HASS.Agent
HASS.Agent copied to clipboard
Bug: Default config storage locations not ideal
The default storage location for the config files, both for the satelite service and the agent, isn't correct according to windows application specs.
Expected behavior
The satelite service and agent should realy both be installed under %ProgramFiles(x86)%\LAB02 Research\
. The agent is getting installed in %AppData%
. This isn't ideal because it is potentially subject to folder redirection and/or roaming profiles in a domain environment. This also stops the installer from working correctly if run as a regular user.
The config data files for the satelite service really should live in %ProgramData%\LAB02 Research\HASS.Agent Satellite Service\
, as %ProgramFiles% is not supposed to be writable.
The data files for the user agent should really be in %LocalAppData%rather than
%AppData%because
%AppData%` is supposed to roam with the user between computers on a domain, while local isn't. The local one is the right place since it's computer local config, otherwise things like the hostname for MQTT will stay the same on different machines, which isn't I suspect the goal.
Misc info (please complete the following information):
- HASS.Agent version: 2022.12.0
Please check what's applicable (multiple answers possible):
- [x] Installed via installer
- [x] Installed manually
- [x] Problem occurs in HASS.Agent
- [x] Problem occurs in Satellite Service
Additional context
I'm happy to code this up and PR it if you would like. I understand this might break existing installs, maybe set it up so it doesn't change anything for existing installs. I suspect the best approach would be to search first in %ProgramData%
and %LocalAppData%
, and then fall-back to the previous install location (eg: wherever the program runs from) if not found.
Part of the PR would be to update the default install location for the agent in the installer too.
This is kinda related to: https://lab02research.youtrack.cloud/issue/hassagent-23
It would also fix: https://lab02research.youtrack.cloud/issue/hassagent-79
Hey @Swamp-Ig,
I agree that it's not ideal currently, and I don't have a problem with it moving to programdata. If you have the time to write a PR that'd be great of course! Shouldn't be too much work. Most code would probably be moving the current config to the new location before loading it - I try to keep everything as easy to use as possible. Maybe there should also be some cleanup code so users don't accidentally visit the old location for logs etc. Both functions could be added to this form; it gets launched elevated after an update, and it restarts HASS.Agent afterwards.
I'd suggest a %username% subfolder for hass.agent's config files. Logging would need to move as well, also to a %username% subfolder.
You can use this project for testing/your PR: https://github.com/LAB02-Research/HASS.Agent.Staging Some info: https://hassagent.readthedocs.io/en/latest/development/introduction/
Coolies %LocalAppData%
is per user anyhow, so it doesn't need to be subdivided out.
There would even be an argument for having the config in %programfiles%
override config in %programdata%
and %localappdata%
, That way potentially the admin can set up machine-wide overrrides. This has all sorts of uses if you're coding up a bespoke parental or management monitoring and control application.
Ideally also the user agent should publish under something like HASSAGENT_<machine-name>_<user-name>
, but that would be outside the scope of this PR.
%LocalAppData% is per user anyhow, so it doesn't need to be subdivided out.
Yep, ok. Had in mind that the current folder structure would be moved to programdata, but keeping the user based stuff in their own localappdata makes more sense of course. I'll add a few buttons in the config panel to easily open all different folders.
There would even be an argument for having the config in %programfiles% override config in %programdata% and %localappdata%, That way potentially the admin can set up machine-wide overrrides.
That's a nice idea, agreed.
Ideally also the user agent should publish under something like HASSAGENT_
_ , but that would be outside the scope of this PR.
Also a good idea.
OK cool. I have a few things on at the moment but should be able to sort this out in the next few weeks.
Ok working on this gradually.
I figure the service should move its own stuff around when it's started up, rather than during the update process. Does that make sense to you? Can move it to the PostUpdate form though if you like.
Sorry for the late reply, but yea having the service handle its own stuff is fine
Hi @Swamp-Ig,
Just checking up on this. There's been a new release with a bunch of code changes, but I don't think it should be in your way too much, you should be able to fetch the new code without problems.
Is there anything I can help with? If you don't have time for this, no worries, you can always just send me your progress so far and I'll pick it up from there.
Oh sorry, have been busy with other things. I did look into it briefly but then got side-tracked. Might have some time in the next few weeks.
Hey, just so you know, started doing a bit of work on this today as I'm off work with COVID. Haven't got very far though because I'm exhausted!
Awesome @Swamp-Ig, but really take your time! I could hardly write two lines of code when I had it 😞 Hope you get well soon