Closed tortho closed 10 months ago
Short update. Installed the android grocy app and connected it to home assistant. In the app I can add to the inventory. On the web interface in home assistant it will still not save. Circle just spinning when pressing ok.
I have been having the same issue for a while now and I haven't submitted any reports because I haven't been able to locate the issue, not have I have any useful logs.
In my case, I just have a frozen screen like it's loading and I have to navigate to another page. Third party access to the data such as the grocy Android app seems to still function but only if you can get it to connect.
I just tested Grocy on HA 2023.8.1 /OS 10.4 and have the same issue. My Grocy config looks a little different, but I cannot manage my stock via the web view. The android app works fine. Additionally to the save loop, the web app shows empty fields for best before dates and storage location in the dialog, despite those information being set in the product master data.
I did some digging after running into this today and the solution has actually been sitting here since 2021: https://github.com/hassio-addons/addon-grocy/issues/187#issuecomment-859954376
This seems to just affect the values once they make it into javascript, as the features are disabled in the rendered UI as expected. Inspecting the feature flags in the browser console reveals what has happened:
>> Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING
"0"
In addition to misinterpreting the environment variables, this also seems to happen to the user preferences saved via the UI. For example:
>> Grocy.UserSettings.show_purchased_date_on_purchase
"0"
The ultimate issue appears to be that PHP 8.1 is not actually supported for Grocy 3.x. I found a similar issue closed for that reason upstream: https://github.com/grocy/grocy/issues/2053#issuecomment-1329696487
4.0 just came out and supports 8.1/8.2, so this problem may end up being magically resolved when the addon is updated. It probably wouldn't hurt to change the environment variables to boolean words just for belt-and-suspenders, I don't spend much time in PHP so I'm not entirely familiar with where these are getting converted.
Edit: I see the PHP 8.1 upgrade was more recent via bot, so maybe user prefs worked until then and the environment variables are broken from a different issue?
That is an interesting find. Would that happen to also have similar issues when all feature flags are enabled with that mismatching environment issue?
In my spare time I have been trying to dive into the inner workings of grocy and the addon to see how they apply to home assistant, hoping that perhaps there was a way to patch the issue. I just haven't had a lot of time to read through the code.
I would expect everything to work with all of them enabled if you also enable all of the boolean user settings so that the JS and backend agree on everything being truthy. I haven't had a chance to test that yet.
There's no great way to patch this locally that I can see since the translation to environment variables is baked into the docker image, though you can correct things "live" in the browser through the console. Maybe a greasemonkey script could work around it for now?
I'm not familiar enough with the addon development process to produce a real patch and not sure when I'll have time to learn.
There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!
I am sure a greasemonkey script might work as a work around, however the mobile app for home assistant is still affected by the issue and can't really have userscripts applied to it.
I believe I found what needs to be patched though I am curious if this is an issue in grocy itself or just the addon.
The default blade file is patched by the addon version to fix relative url's but we could include a patch to fix the state of the feature flags in the js code that causes the issue (which is what we would be fixing via a greasemonkey script to begin with as a workaround)
Something seems to go wrong with the json encoding of the flags in PHP when it generated the js code portion of the view.
As we had previously found, for some reason we are encoding a string value of 1 or 0 on certain flags. One work around would be to reset those values based on its string value. I would test this myself and submit a pull request, but I am not familiar with the dev environment setup to test the code myself and also to generate a patch file for the addon.
There maybe another fix to this that doesn't require generating a patch file.
There is a custom_js.html file that grocy looks for that we can implement the JS feature flag patch. We can just run JS code that looks at the object and sets the values correctly if they are string values of "1" or "0" and change the values to boolean values.
There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!
Grocy 0.19.1 in HASOS 2023.7.3, Supervisor 2023.07.1, OS 10.3
Logging in, working with masterdata all works fine. Changing quantity in inventory however ends up in an endless save (circle spinning after pressing OK)
Log level set to Trace but nothing in the addon log whatever I do in the addon.
My Config: