#Config subentries
1 messages · Page 1 of 1 (latest)
I converted the PurpleAir integration to use sub-entries (I really wanted private sensor support), awaiting reviewer to become available. How would I add the coordinates of the sensor to the sub-entry only, and not each of the sensors (temp, hum, aqi, etc.) exposed by the sub-entry, i.e. each sensor shows up on the map? Or, is it just the map that makes it look like each sensor has a map location, i.e. the device entry extended attrs only applies to the device?
🙋🏼 Here, I have a question. Renaming the subentries (title), is that planned?
Im working on adjusting my Satel Integra PR (where I add Config Flow). I previously made it so sensors and alarm panels can be created using an options flow, but was requested to use sub config entries for this.
So far I have the alarm panel working, I'm just wondering how I can allow the user to update some values for the subconfig (like options flow)?
I believe you can reconfigure them
oh right, there's a reconfigure step, that makes sense, I'll attempt that one, thanks!
Hi. I'm working on a new integration with subentries. Currently I'm reloading the integration, when there is a change in the config entry, to get noticed about new subentries
https://github.com/home-assistant/core/pull/145237#discussion_r2134122374
But this leads also to reloading the integration on an access token change. What's the suggested way to add entities, when a subentry is added?
In the config flow?
Yes
You also see this with option flows in oauth integrations
YouTube for example
Instead of using the listener we do it in the flow
i cant find anything helpful there. I also checked netatmo, which also has a option flow and is oauth based
Well, you can see that before async create entry we do a reload
I believe
Instead of letting the update listeners reload it
As it would cause more reloads because of new tokens
yes, it's the better way i think, too.
but I dont't know, how to do. the only think I can find is return self.async_update_reload_and_abort(self._get_reauth_entry(), data=data) But it's in the async_oauth_create_entryfunction and not in the options flow
this is working:
https://github.com/home-assistant/core/pull/145237/commits/d235d2ce9de7e6994c6bb9716c0fd414980e0b26
But it feels a little bit complicated....
I think you can call sync create entry
Store it in a variable
Reload
And return the variable
no, thats not working, if i create entry n, than no entities are added. if i create entry n+1, than entities to entry n are added, but n+1 is still without entities
With +1 you mean sub entries?
yes
so more plastic: when i create a subentry for new york, the entry is created, but without entities. then i create a subentry for berlin, then new york gets the entitites, but berlin stays without
had the same issue in the ntfy integration, The solution was to add a listener to reload when the config entry is updated. Have a look at the init.py of the ntfy integration
Yes but that doesn't work here as the config entry is updated when you get a new token
There I copied it from😅
Subentries unique ids
are they unique per integration
or unique per integration per entry?
unique per entry
Linking some SubEntry discussion here. A few issues I have found developing the Bayesian helper with SubEntries
#1266094015674191944 message
- Completing the Config Flow for helpers doesn't take you to the integration page where one can add subentries
- Navigating to the integration page for helpers is very much hidden
- GENERAL: Adding subentries is hidden in a dropdown menu that the user is not directed to, but has to know to look there
I must admit I am still quite confused about the whole setup of subentries. I have an integration with a limited amount of calls/month so in order to make most of the calls and still be able to have multiple "sensors"/entities i agree with joostlek it would be nice to have it as subentries. But I feel as a developer the dev docs on config entries are quite slim.
well, it is a quite new feature. You can have a look at the kitchen sink and the ntfy integration. I think there is also another integration using subentries.
Have a look at the implementation in the ntf integration and in my PR for Bayesian https://github.com/home-assistant/core/pull/122552
MQTT uses it but their implementation is about 3000 lines
yeah, not a good example ^^
I have pulled up the PR for the Bayesian and I make myself believe i have tested quite a few things from there. Right now I started over and try to break it down completely testing my way through it. I might just not have gotten the arch quite right into my head yet
You may or may not know from your config flow (depending on which arch you used) that the function names are important and must be in the format async_step_{step_id}. Each function is called at least twice, once when the steps starts and then each time the step is sumbitted, hence why each func usually has if user_input is None: in the flow
I have looked at this dev page. but even the subentry unique_ID linkt to the config flow unique id, which most describes two functions not available in the ConfigSubEntryFlow class.
I think i have figured the double calls to async_step_user out. but i'll keep on grinding a bit later. for now i have to meet up with the secretary of domestic affairs(read girlfriend)
Yeah, I haven't needed to implement unique IDs for subentries yet, I'm not sure they have a purpose in my use-case, HA seems to uniquely identify them in the backend anyway.
I've created a PR to the dev docs to improve the code examples https://github.com/home-assistant/developers.home-assistant/pull/2708
What was your integration?
Is it the Danish public transport one?
@subtle tiger Yes it is the public transport journey planner based on a specialized version of HAFAS
Well I am almost there with setting up all the subentry flow, but one thing i cannot get to work is the menu item text/title. When i press the three dots menu i see a plus sign but no text. I have pushed the latest progress to my repo: https://github.com/Jawar19/HA-core/commit/2233f09daf345f39f6a07d6ef6b56312a6f154f0
Can anyone help me on this. I feel like i have tried everything.
you are missing some translation strings
add the following: "stop": { "initiate_flow": { "user": "Add stop" }, "entry_type": "Stop",
@inland hound Still no cigar
I have added the strings to strings.json and i still get no text in the menu.
I have force refreshed with ctrl + shift + R.
the string for entry_type is showing though
Did you generate translations
When running the pre-commit task i get this error from hassfest
Integration rejseplanen:
- [ERROR] [TRANSLATIONS] Invalid strings.json: extra keys not allowed @ data['config_subentries']['stop']['initate_flow']. Got {'user': 'Add stop'}
I have moved the initiate_flow to the root of config_subentries this did not work either.
@subtle tiger I use the default run task from Home Assistant which build the translations afaik
EDIT: see third paragraph
Right, this at least explains that you did something wrong
So this is a good validation 🙂
Euh, I'm not behind my pc but can you check what other integrations do?
I have tried to look into both ntfy and bayesian but they use menus for adding subentries.
That shouldn't be needed here tho
@subtle tiger I found out that programming and HA-Core is pretty pedantic about spelling :p sorry to have wasted your time on me spelling initiate_flow as initate_flow
Would you know if i can have different scan intervals on my coordinator and on my sensors?
basically the coordinator calling the backend should only update once every 5 minutes, but the sensor should update the native_state every minute as it is counting down to the scheduled departure
Oh
Ideally we set those timing things to a timestamp sensor
And have the state be the moment that you would have something happen
This way it's always up to date
I have the timestamps in the extra attributes, so it would not be a problem to promote those to be the native value, but wouldnt the default card action be to just show the timestamp then?
Sorry i might go a bit off track for this topic
Well the thing is that we can't just migrate this
So you either would need to trigger update every minute
But wait, the integration didn't work before now right
Maybe that gives you some room
The old API was deprecated and it haven't worked for some months so everybody needs to update and get an API KEY i guess breaking changes have been done before.
Right now it works as previous. give or take
Is there a way to request other reviewers for PR's vs just codeowner? My subentry PR has been waiting months while the codeowner is still unavailable.
It's in the queue
It's also on my list of things to look at
A feature request I got was to add some of the configuration details into the subentry title as it's confusing to know the difference between the different types right now.
I can simply add the information to the title, I'm just wondering if there are better ideas out there, I don't think I've seen a description or something that we can set? I'm asking because the title can be changed by the user, but this information wouldn't need to be changed
you could add a more descriptive name for the subentry type. This is shown bellow the name of the subentry
Is that something to specifically configure then, because for me nothing shows below the subentry:
I guess if the subentry creates a device, that would be true, but in this case, the integration would create 1 device (not yet, planning to do that later), the subentries wouldn't create new devices, just ad entities to the main device
Oh wait, I see, so I'm missing translations texts for the subentry type, that's an easy fix. It still doesn't fully solve the problems though, as there may be up to 256 (depending on the alarm system used) entries for a single subentry type, another sort of identifier would help there
should look like this
Fixed the missing trnaslation string now, at least some improvement, still having x amount of zones will be hard to identify other than the title (which can be changed)
I asked Erik why this isn't required