Skip to content

Add Victron Venus integration #130505

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

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

JohansLab
Copy link

@JohansLab JohansLab commented Nov 13, 2024

Proposed change

This is a new integration for Victron Venus OS based devices.

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:

Documentation PR: home-assistant/home-assistant.io#35739

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:

home-assistant[bot]

This comment was marked as outdated.

@home-assistant home-assistant bot marked this pull request as draft November 13, 2024 09:13
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @JohansLab

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

those things (details of device communication) need to be extracted to a public repository and published to pypi

Copy link
Author

Choose a reason for hiding this comment

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

I started a library -- but it essentially just had to duplicate all the code, because this integration really only maps messages. If I create a library I would need to map to a proprietary format, and then map again to home assistant format.

Copy link
Member

Choose a reason for hiding this comment

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

tbh this is never really needed, if it is you might need to restructure

@JohansLab JohansLab marked this pull request as ready for review November 15, 2024 10:48
@home-assistant home-assistant bot dismissed stale reviews from themself November 15, 2024 10:48

Stale

@zweckj
Copy link
Member

zweckj commented Nov 15, 2024

please fix the cla errors and remove the mentioned code before you set this back to "ready for review"

@JohansLab JohansLab marked this pull request as draft November 16, 2024 11:04
@JohansLab
Copy link
Author

please fix the cla errors and remove the mentioned code before you set this back to "ready for review"

How do I remove the cla-error? I did sign my CLA and the label cla-signed was attached, but the cla-error label wasn't removed. Am I missing something?

@JohansLab JohansLab marked this pull request as ready for review November 16, 2024 11:28
@JohansLab
Copy link
Author

Based on comments on discord server the cla-error is sometimes not removed after the error was corrected. The cla-bot does indicate that everything is ok.

@JohansLab JohansLab requested a review from zweckj November 16, 2024 11:29
Copy link
Member

@zweckj zweckj left a comment

Choose a reason for hiding this comment

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

apologies, didn't see that commit. I'd still suggest you get rid of any victronvenus_ files and the _ files, as those are library files which are not allowed in core.

@zweckj zweckj marked this pull request as draft December 13, 2024 08:32
@JohansLab
Copy link
Author

Refactors the code and have it depend on new PyPi library. Also updated to comply with new quality standard guidelines.

@JohansLab JohansLab marked this pull request as ready for review January 23, 2025 09:41
@home-assistant home-assistant bot requested a review from zweckj January 23, 2025 09:41
Comment on lines +157 to +158
vol.Optional(CONF_USERNAME): str,
vol.Optional(CONF_PASSWORD): str,
Copy link
Member

Choose a reason for hiding this comment

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

can we detect if we need to auth and only show this (in a second step) if we need it?

Copy link
Member

Choose a reason for hiding this comment

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

still open

@home-assistant home-assistant bot marked this pull request as draft February 16, 2025 19:26
@MartinHjelmare MartinHjelmare changed the title Initial Victron Venus implementation. Add Victron Venus integration Feb 22, 2025
@JohansLab
Copy link
Author

All review comments addressed.

@JohansLab JohansLab marked this pull request as ready for review March 4, 2025 15:27
@home-assistant home-assistant bot requested a review from zweckj March 4, 2025 15:27
Comment on lines +157 to +158
vol.Optional(CONF_USERNAME): str,
vol.Optional(CONF_PASSWORD): str,
Copy link
Member

Choose a reason for hiding this comment

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

still open

errors["base"] = "cannot_connect"
except InvalidAuthError:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except # noqa: BLE001
Copy link
Member

Choose a reason for hiding this comment

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

log the exception here as exception to get rid of the noqa

Comment on lines +101 to +102
data[CONF_INSTALLATION_ID] = installation_id
unique_id = installation_id
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data[CONF_INSTALLATION_ID] = installation_id
unique_id = installation_id
data[CONF_INSTALLATION_ID] = unique_id = installation_id

Comment on lines +78 to +79
self.friendlyName: str | None = None
self.modelName: str | None = None
Copy link
Member

Choose a reason for hiding this comment

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

snake case

Suggested change
self.friendlyName: str | None = None
self.modelName: str | None = None
self.friendly_name: str | None = None
self.model_name: str | None = None

Comment on lines +74 to +79
"""Initialize."""
self.hostname: str | None = None
self.serial: str | None = None
self.installation_id: str | None = None
self.friendlyName: str | None = None
self.modelName: str | None = None
Copy link
Member

Choose a reason for hiding this comment

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

move them all out of the init and type them only

Comment on lines +50 to +54
assert result["data"][CONF_HOST] == "1.1.1.1"
assert result["data"][CONF_PORT] == 1883
assert result["data"][CONF_USERNAME] == "test-username"
assert result["data"][CONF_PASSWORD] == "test-password"
assert result["data"][CONF_SSL] == False # noqa: E712
Copy link
Member

Choose a reason for hiding this comment

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

instead of checking each dict item independently rather check the entire dict for readability

Comment on lines +90 to +92
with patch(
"homeassistant.components.victronvenus.config_flow.validate_input",
return_value="INSTALLID",
Copy link
Member

Choose a reason for hiding this comment

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

those two tests can be parametrized

Copy link
Member

Choose a reason for hiding this comment

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

missing a test for checking abort when unique id configure


type VictronVenusConfigEntry = ConfigEntry[VictronVenusHub]

__all__ = ["DOMAIN"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
__all__ = ["DOMAIN"]

shouldn't be necessary

Comment on lines +73 to +74
if hub is not None:
if isinstance(hub, VictronVenusHub):
Copy link
Member

Choose a reason for hiding this comment

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

the hub should always be typed VictronVenusHub, so those two lines should be unnecessary

@home-assistant home-assistant bot marked this pull request as draft March 17, 2025 12:12
Comment on lines +13 to +17
"host": "Hostname or IP address of Victron Device, usually mDNS name like 'venus.local'",
"port": "The MQTT port on the host. Normally it is 1883.",
"username": "Username for the Victron Device, default is empty. This is not your VRM username.",
"password": "Password for the Victron Device, default is empty. This is not your VRM password.",
"ssl": "Indicates whether to use SSL to connect to the Victron Device. Normally it is disabled."
Copy link
Contributor

Choose a reason for hiding this comment

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

All occurrences of "Victron Device" should be "Victron device" as "device" is not part of the product name and will be translated in all languages.

Besides that, all strings look OK to me, can't wait to see this integration going live being a Victron owner myself. As mine is a mostly DC system having a sensor for DC loads would be great, too. 😄

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.

4 participants