-
Notifications
You must be signed in to change notification settings - Fork 55
Fix access to config data now that we are using config flow #39
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
Fix access to config data now that we are using config flow #39
Conversation
I don't think the test failure is related to this change but please tell me if that's not true. Just to review the changes I have made since you mentioned that you don't know much about config flows - I have done a couple of things:
|
I've also made the update logic more generic. As long as |
db09652
to
a127a5f
Compare
Alright, I've simplified the update logic so that it supports mixed configs (setting the config entry up through UI but adding apps through |
Thanks for the PR and the updates. I cloned
If I quit and start again, it comes up fine. This happens if the yaml config was changed before starting. If I put a log message at the start of
pyscript:
allow_all_imports: true
apps:
app1:
- val1: 10
- val2: 21
apps_list:
entry1:
- val1: 100
- val2: 200 then {
"allow_all_imports": True,
"apps": {"app1": [{"val1": 10}, {"val2": 21}]},
"apps_list": {"entry1": [{"val1": 100}, {"val2": 200}]},
} but on reload if the yaml config has changed, {
"allow_all_imports": True,
"apps": OrderedDict(
[("app1", [OrderedDict([("val1", 10)]), OrderedDict([("val2", 21)])])]
),
"apps_list": OrderedDict(
[("entry1", [OrderedDict([("val1", 100)]), OrderedDict([("val2", 200)])])]
),
} It would be great if the reload case was the same as the cold start case (eg, regular |
ef99788
to
bbbab4d
Compare
It looks like the two issues are related - the setup only fails after the config entry has been updated with OrderedDicts. When I call |
OK the two weren't related. Fixed the timeout issue, but as far as I can tell, the OrderedDict's thing was always how the config was being pulled in. The difference is that with a config entry, on shutdown HA writes the data to disk and then it becomes a normal dictionary. I can get around this by doing a |
05674e7
to
84e9a8e
Compare
I went ahead and forced it to always use a dictionary. All startup issues should be gone as well. Let me know if you run into anything else |
…ly for user vs import updates
Thanks for converting the OrderedDict on reload. I don't know a better way to do that. Unfortunately I still see the first problem: pyscript fails to initialize if the yaml config was modified. Can you replicate that? |
I was not testing the right scenario to trigger the failure. I found where the call is failing and found that the line is unnecessary. This should be working 100% finally (hopefully) EDIT: Found one more bug where if the entry was set up via UI, and then the apps config was added to EDIT2: Found one more potential issue, but I'm not sure if it's intended or not because it existed before my changes. When calling the reload service, |
Looks good! Thanks for the quick followup and resolution. |
Thanks for the extensive testing! It would be good to add some test coverage for these types of scenarios, I'm just not sure the best way to go about doing it, but if I think of one I will submit a new PR |
Agreed, but I'm not sure how to mock the yaml configuration. I just added Also, I finally figured out how to add pylint to pre-commit and github actions. I just made a couple of very minor pylint fixes to the config flow. |
Awesome! Thanks for the tweak and good catch on the tests |
I just released 0.31, which includes the config flow. I then tested it with a new installation of HASS 0.117.0.dev0, installed HACS, then installed pyscript 0.31. It doesn't start - it doesn't get as far as creating the Can you look at this please asap? |
Oops - I didn't add Just confirming that step is still necessary with config flow? |
While it does now show up under "Configuration", the pyscript card doesn't have a "Configure" button. And it doesn't show up when you search for it. So as far as I can tell, config flow is not working on a clean install. |
@craigbarratt I just tested it and it is working as expected. To be clear, after installation, you still have to go to Config > Integrations, click on the add button in the bottom right, and then select pyscript. From there it should be straight forward to set it up (this is when you don't have Regarding configure: That's only available to a subset of integrations. What we can do in the future is make it so people can add |
Also one thing to note, now that it's a config entry, to remove the integration you have to both delete the config entry from the UI and delete it from your |
On a clean new install of HASS, HACS and pyscript, pyscript is not shown in Configuration -> Integrations -> "+". There is no sign that config flow is working. |
Try hard refreshing the front end and then try to add it. I had this problem in the past when I was developing config flows for other integrations |
Ok, I opened an incognito chrome window, logged in, and it does now show pyscript in Configuration -> Integrations -> "+". However, after checking "allow all imports", I get this error:
Is that because I already set up the yaml configuration? |
Yes. That should show a more friendly error but I made a mistake. Core integrations can use common strings HA provides, but I guess custom integrations can't use them. I'll submit a PR to fix that |
Ok, thanks. I'll try a fresh install and make sure I use a clean browser session. |
I tried a clean install (HASS, HACS, pyscript) with a new incognito browser and I have the same problem. After installing pyscript with HACS, and restart HASS, Configuration -> Integrations -> "+" doesn't show pyscript. Pyscript doesn't initialize. |
Did you have the incognito browser open in the frontend before you installed pyscript with HACS? The frontend does some pretty heavy caching, it's best to do a hard refresh of the page after installing a new integration |
Yes. I just quit the incognito window and started another one. It worked with a new browser session - I can find pyscript, and I do get prompted for "allow all imports". Wow, that's not a great user experience, but this appears to be an issue outside of pyscript. The pyscript card now shows in Configuration -> Integrations. However, it doesn't have an "options" link like HACS does. How do you change the config setting for "allow all imports" after the first time? |
Well, your reload service logic doesn't handle updates to |
The only place you configure the I can add in support to the UI to make this changeable, but that would require changes to the reload service as well. I asked about this in EDIT2 here but since you didn't respond I assumed you wanted to keep it the same #39 (comment) |
Ah good point. At least with the yaml setting you can change it and then re-start HASS. But, yes, adding that to config flow and also reload would be excellent. Sorry, I missed your edit2 earlier. |
no worries! I can work on that next. If I get |
That would be great - no rush. Most |
I'll handle that in my update |
This should resolve the issue we are discussing in #31. Since you said you can reproduce the issue @craigbarratt, can you test this and make sure it works? I would also test updating the config and doing a reload to make sure that the logic I changed works.