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 Sunsynk Integration #85893

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

Conversation

jamesridgway
Copy link

@jamesridgway jamesridgway commented Jan 14, 2023

Breaking change

Proposed change

Add Integration for Sunsynk inverters.

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
  • The code has been formatted using Black (black --fast 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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hi jamesridgway

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
Contributor

@Lash-L Lash-L left a comment

Choose a reason for hiding this comment

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

Here is my feedback to try to get the process started for you!

homeassistant/components/sunsynk/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/const.py Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/strings.json Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/translations/en.json Outdated Show resolved Hide resolved
homeassistant/components/sunsynk/strings.json Show resolved Hide resolved
tests/components/sunsynk/test_config_flow.py Outdated Show resolved Hide resolved
@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@gjohansson-ST
Copy link
Member

Several comments from @Lash-L still outstanding.
Setting this as draft until those has been addressed.
Please undraft when ready for review

@gjohansson-ST gjohansson-ST marked this pull request as draft June 20, 2023 21:48
@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added stale and removed stale labels Sep 18, 2023
@joostlek
Copy link
Member

joostlek commented Oct 8, 2023

Also, feel free to close review comments if you think you solved them :)

@joostlek
Copy link
Member

joostlek commented Oct 9, 2023

I also discussed this PR with some other members, and we kinda have the guideline, if it's connecting to a local device, 1 IP = 1 config entry. If it's connecting to a cloud service, 1 account = 1 config entry. If people really don't want a certain inverter in there, you can always disable it

@gjohansson-ST gjohansson-ST marked this pull request as draft October 9, 2023 19:22
@jamesridgway
Copy link
Author

I also discussed this PR with some other members, and we kinda have the guideline, if it's connecting to a local device, 1 IP = 1 config entry. If it's connecting to a cloud service, 1 account = 1 config entry. If people really don't want a certain inverter in there, you can always disable it

No problem, I've updated this to respect this.

@jamesridgway jamesridgway marked this pull request as ready for review December 3, 2023 16:59
Comment on lines 27 to 30
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {
CONF_NAME: username,
SUNSYNK_COORDINATOR: coordinator,
}
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
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {
CONF_NAME: username,
SUNSYNK_COORDINATOR: coordinator,
}
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator

We already have the username from entry.data so not sure why we should attach it here?

Copy link
Author

Choose a reason for hiding this comment

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

Done

homeassistant/components/sunsynk/config_flow.py Outdated Show resolved Hide resolved
Comment on lines 61 to 62
if CONF_USERNAME not in data or CONF_PASSWORD not in data:
raise InvalidAuth
Copy link
Member

Choose a reason for hiding this comment

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

This should not be needed as you control the data that it gets from the schema and also given as little as this validation is you might just put it in the step code instead directly.

Copy link
Author

Choose a reason for hiding this comment

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

Done

)


class SunsynkHub:
Copy link
Member

Choose a reason for hiding this comment

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

I guess this is also constructed from the scaffold script and doesn't seem necessary as you can also put it directly in the step

super().__init__(
hass,
_LOGGER,
# Name of the data. For logging purposes.
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
# Name of the data. For logging purposes.

Remove unnecessary commenting

Copy link
Member

Choose a reason for hiding this comment

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

In many places

Copy link
Author

Choose a reason for hiding this comment

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

Done

data[inverter.sn] = inverter_data
return data
except InvalidCredentialsException as err:
raise ConfigEntryAuthFailed(err) from err
Copy link
Member

Choose a reason for hiding this comment

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

This needs an reauth step in the config flow

SUNSYNK_COORDINATOR
]

inverters = await coordinator.api.get_inverters()
Copy link
Member

Choose a reason for hiding this comment

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

We should already have it in coordinator.data

Copy link
Author

Choose a reason for hiding this comment

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

Done

homeassistant/components/sunsynk/sensor.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft December 3, 2023 20:05

This comment was marked as outdated.

@github-actions github-actions bot added the stale label Feb 1, 2024
@jamesridgway
Copy link
Author

Working on latest feedback comments

Copy link

github-actions bot commented Apr 6, 2024

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label Apr 6, 2024
@jamesridgway
Copy link
Author

Working on latest feedback comments

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.

None yet

4 participants