10000 Add Leneda integration - base functionality by fedus · Pull Request #145972 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Add Leneda integration - base functionality #145972

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

fedus
Copy link
@fedus fedus commented Jun 1, 2025

Proposed change

This change introduces a new integration for the Leneda Luxembourg Energy Platform. The platform allows users to read electricity and gas consumption and production data. This integration allows to connect Home Assistant to the platform.

The user configures an account (Energy-Id + API token), and can then add metering point(s) per account. A metering point is like an electrical or gas meters that can be read out.

Please note that this is a new iteration of an earlier attempt. The previous PR was closed by me: #144774

Major differences since the previous PR:

  • Small iterations: I will not dump the whole integration into this PR, but add functionality step by step. As such, there might however be code in certain parts that will only become relevant later. I've tried to keep this at a minimum
  • Instead of having just config entries for both account management and metering points configuration, I am now using config entries for authentication data only, and config subentries for individual metering points config (relevant code coming up in the next increments)

What's in this PR?

This PR lays the groundwork for the Leneda integration and focuses on scaffolding and very basic core functionality:

  • Basic init
  • Basic coordinator (purely a shell right now)
  • Config flow for the config entries excluding config subentries. In other words: config flow for authentication.
  • Tests for the config flow

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • 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

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

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:



@pytest.fixture(autouse=True)
async def recorder_mock(
Copy link
Author

Choose a reason for hiding this comment

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

Will become relevant later

_LOGGER = logging.getLogger(__name__)


def _create_statistic_id(metering_point: str, obis: str) -> str:
Copy link
Author

Choose a reason for hiding this comment

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

Will become relevant later

Copy link
Contributor
@NoRi2909 NoRi2909 left a comment

Choose a reason for hiding this comment

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

Two small leftovers in the strings.

"title": "Leneda Authentication",
"description": "Set up your Leneda integration by providing your Energy ID and API key.",
"data": {
"api_token": "API Key",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be replaced with the common string "[%key:common::config_flow::data::api_key%]" as you already have on line 63.

"entry_type": "Metering point",
"step": {
"init": {
"title": "Add Metering Point",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be replaced with reference to line 93, also fixing the missing sentence-casing this way.

from .const import CONF_API_TOKEN, CONF_ENERGY_ID
from .coordinator import LenedaCoordinator

PLATFORMS: list[Platform] = [Platform.SENSOR]
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I missing something, it seems the sensor platform is missing (no sensor.py)?

Copy link
Author

Choose a reason for hiding this comment

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

You are right - the sensor platform is coming up.

I am "stacking" PRs as I have the whole thing laid out locally, but will introduce the changes bit by bit. This bit unfortunately slipped through.

So, it's going to be relevant for the next PR. If you wish, I can also completely remove it from the current PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend including the basic sensor platform at least and improving on that after merging. Just in case this takes a while, and not everything is ready for 2025.7.0. At least the integration will do something, otherwise this could cause errors and problems for users.

Copy link
Author
@fedus fedus Jun 2, 2025

Choose a reason for hiding this comment

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

Yeah, this is what made me so torn between having one big (first) PR and several smaller ones. As it stands, the current PR will only allow users to add authentication (config entries), and not even metering points / energy meters (config subentries).
To have something "usable", the metering points stuff will need to be included as well. 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the initial PR should be the MVP, so in this case, no logic around dynamic metering points or anything, just register what is available and create something. But I'll leave that for someone from core.

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

Successfully merging this pull request may close these issues.

3 participants
0