Skip to content
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

Add ConfigFlow and DeviceInfo #174

Merged
merged 19 commits into from
Jan 17, 2025
Merged

Conversation

dala318
Copy link

@dala318 dala318 commented Jan 16, 2025

Fixing #173 and #172

@@ -113,6 +114,8 @@ async def RunDocker(hass: HomeAssistant, entry: ConfigType) -> None:
try:
hass.data[DOMAIN][entry[CONF_NAME]][API] = DockerAPI(hass, entry)
await hass.data[DOMAIN][entry[CONF_NAME]][API].init(startCount)
await hass.data[DOMAIN][entry[CONF_NAME]][API].run()
await hass.data[DOMAIN][entry[CONF_NAME]][API].load()
Copy link
Author

@dala318 dala318 Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "load_entities"?

The split is done so that:

  • init: creates the connection to docker host and retrieves the data, once (only want the list of containers to select from during set-up)
  • run: start the continuous monitoring (don't want this during configuration)
  • load: setups the entities (config_entry have to create entities a slightly different way)

@dala318 dala318 changed the title Add Config flow Add ConfigFlow and DeviceInfo Jan 16, 2025
@ualex73
Copy link
Owner

ualex73 commented Jan 16, 2025

I just created a new branch config_flow, can you create a pull request against this one?

I like to keep the master without config_flow, and test config_flow a bit more - before releasing it to the public.

DOCKER_SCHEMA = vol.Schema(
{
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PREFIX, default=""): cv.string,
vol.Optional(CONF_URL, default=None): vol.Any(cv.string, None),
vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL): cv.time_period,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timedelta is not natively serializable and can only store serialized data in config_entry.
could create a a de-serializer on reading entry but is still used as int in API

@dala318 dala318 changed the base branch from master to config_flow January 17, 2025 06:27
@dala318
Copy link
Author

dala318 commented Jan 17, 2025

I just created a new branch config_flow, can you create a pull request against this one?

I like to keep the master without config_flow, and test config_flow a bit more - before releasing it to the public.

Could be a good idea, I swapped target-branch in this PR.

# @property
# def entity_id(self) -> str:
# """Return the entity id of the sensor."""
# return self._entity_id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With removal of this and the change to set _attr_unique_id instead of _entity_id I would fear that the config-parameter rename_entity becomes obsolete, but was necessary since the device_registry seem to need controll over the entity naming. Could be solved by setting self_entity_id (instead of self._entity_id) and hence making it a public read/write property.

@dala318
Copy link
Author

dala318 commented Jan 17, 2025

At current state it is ready enough to start trying it.
Are still a bit of clean-up and tweaking left to do but would be great if you could test it a bit and give some feedback on how it behaves and how to make the set-up process most intuitive.

@dala318 dala318 marked this pull request as ready for review January 17, 2025 12:18
@ualex73 ualex73 merged commit 2f645a2 into ualex73:config_flow Jan 17, 2025
2 checks passed
@ualex73
Copy link
Owner

ualex73 commented Jan 17, 2025

Ok, i have merged it into the new branch. I will also do some testing in the weekend :-) thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants