core icon indicating copy to clipboard operation
core copied to clipboard

Make Nord Pool action config entry optional

Open scop opened this issue 3 weeks ago • 3 comments

Proposed change

Make config entry optional in Nord Pool action calls. If no entry is specified and there is only one configured, take it. This is a pattern in some integrations I've seen around to make services easier to use. I believe the vast majority of Nord Pool setups will have only one entry configured.

While the config entry selector drop-down is nice in the call UI, it does not help when one needs the actual config entry id, and figuring that out is kind of a chore. Not having to specify it would also make sharing things like https://community.home-assistant.io/t/nordpool-ha-integration-with-15min-data-apexcharts-and-more-updated/935651/5 cleaner/easier.

Type of change

  • [ ] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [x] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • [x] I understand the code I am submitting and can explain how it works.
  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [ ] I have followed the development checklist
  • [ ] I have followed the perfect PR recommendations
  • [x] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.
  • [x] Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • [ ] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [ ] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

scop avatar Dec 22 '25 11:12 scop

Hey there @gjohansson-st, mind taking a look at this pull request as it has been labeled with an integration (nordpool) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of nordpool can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign nordpool Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

home-assistant[bot] avatar Dec 22 '25 11:12 home-assistant[bot]

So we had this case with Mealie as well, and we decided against it as while this make it easier to use the service, it will break when you add a second entry, which is bad

joostlek avatar Dec 22 '25 11:12 joostlek

That's true, but there are multiple ways to look into this. In addition to benefits already mentioned here, hardwiring a specific config entry id (because it's required) will break when one removes and re-adds the entry, whereas one making use of this approach would keep working.

But if one of these approaches is the desired one, I suggest making a "rule" for it and making it consistent across all integrations. I know at least netgear_lte and huawei_lte (where I inherited the approach from netgear_lte a long time ago) use the "optional + pick the only one if there is only one" approach. (Both netgear_lte and huawei_lte use something else besides the entry id, partially because of historical reasons I think, but also to make use of something that is visible in the UI to make it easier to figure out the value.)

scop avatar Dec 22 '25 11:12 scop