#Config subentries

1 messages · Page 1 of 1 (latest)

subtle tiger
#

Since config sub entries are new and not widely adopted, we might come accross places where we have questions. So let's have this chat as a place to have those until it has become widely adopted.

#

@weary hazel @kind solar

candid hawk
#

-# where is the first message gif

weary hazel
#

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?

inland hound
#

🙋🏼 Here, I have a question. Renaming the subentries (title), is that planned?

torn thunder
#

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)?

subtle tiger
#

I believe you can reconfigure them

torn thunder
#

oh right, there's a reconfigure step, that makes sense, I'll attempt that one, thanks!

static citrus
#

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?

subtle tiger
#

Add the reloading do the create sub entry logic

#

Instead of using a listener

static citrus
#

In the config flow?

subtle tiger
#

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

static citrus
#

i cant find anything helpful there. I also checked netatmo, which also has a option flow and is oauth based

subtle tiger
#

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

static citrus
#

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

static citrus
subtle tiger
#

I think you can call sync create entry

#

Store it in a variable

#

Reload

#

And return the variable

static citrus
#

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

subtle tiger
#

With +1 you mean sub entries?

static citrus
#

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

inland hound
#

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

subtle tiger
subtle tiger
#

Subentries unique ids

#

are they unique per integration

#

or unique per integration per entry?

inland hound
#

unique per entry

remote vessel
#

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
tall condor
#

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.

inland hound
#

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.

remote vessel
remote vessel
inland hound
#

yeah, not a good example ^^

tall condor
remote vessel
tall condor
#

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)

remote vessel
# tall condor I have looked at this dev page. but even the subentry unique_ID linkt to the con...

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

https://deploy-preview-2708--developers-home-assistant.netlify.app/docs/config_entries_config_flow_handler/?_highlight=subentry#subentry-flows

subtle tiger
#

Is it the Danish public transport one?

tall condor
#

@subtle tiger Yes it is the public transport journey planner based on a specialized version of HAFAS

tall condor
inland hound
#

you are missing some translation strings

#

add the following: "stop": { "initiate_flow": { "user": "Add stop" }, "entry_type": "Stop",

tall condor
#

@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.

inland hound
#

the string for entry_type is showing though

subtle tiger
tall condor
#

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

subtle tiger
#

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?

tall condor
subtle tiger
#

That shouldn't be needed here tho

tall condor
#

@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

subtle tiger
#

Oh good catch

#

Don't worry, this is also stuff I learn from

tall condor
#

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

subtle tiger
#

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

tall condor
#

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

subtle tiger
#

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

tall condor
#

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

weary hazel
#

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.

GitHub

Breaking change

Proposed change

Background:
This PR is a rework of a previous PR that I abandoned.
As requested (@bachya @joostlek) I converted the config to now use Config Sub Entries for each i...

subtle tiger
#

It's also on my list of things to look at

torn thunder
#

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

inland hound
torn thunder
#

Is that something to specifically configure then, because for me nothing shows below the subentry:

torn thunder
#

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

inland hound
#

should look like this

torn thunder
#

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)

subtle tiger