Skip to content

Add Bzu Tech integration #132393

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 6 commits into
base: dev
Choose a base branch
from
Draft

Conversation

enioo22
Copy link

@enioo22 enioo22 commented Dec 5, 2024

Proposed change

Add integration compatible with Bzu Tech devices and services. That includes multiple kinds of proprietary sensors.
This is a remake of an older pull request: #107749

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:

Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

New integrations are required to include a quality_scale.yaml file and reach at least bronze. If you add that and make sure the code meets those requirements we can start the review. Thanks for the patience so far :)

@home-assistant home-assistant bot marked this pull request as draft January 16, 2025 11:48
@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.

@enioo22 enioo22 marked this pull request as ready for review February 17, 2025 19:13
@home-assistant home-assistant bot requested a review from joostlek February 17, 2025 19:13
Comment on lines 55 to 128
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
if user_input is not None:
self.api = get_api(user_input)
if not await self.api.start():
return self.async_abort(reason="Invalid Authentication")
self.email = user_input[CONF_EMAIL]
self.password = user_input[CONF_PASSWORD]
return await self.async_step_deviceselect(user_input=user_input)
return self.async_show_form(
step_id="user",
data_schema=STEP_USER_LOGIN_SCHEMA,
errors=errors,
last_step=False,
)

async def async_step_deviceselect(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Set up the selection of the device from a list ."""
if self.selecteddevice != 0 and user_input is not None:
self.selecteddevice = user_input[CONF_CHIPID]
return await self.async_step_portselect(user_input=user_input)
self.selecteddevice = 1
return self.async_show_form(
step_id="deviceselect",
data_schema=vol.Schema(
{
vol.Required(CONF_CHIPID): SelectSelector(
SelectSelectorConfig(
options=[
SelectOptionDict(value=key, label=key)
for key in self.api.get_device_names()
],
mode=SelectSelectorMode.DROPDOWN,
)
),
}
),
)

async def async_step_portselect(self, user_input) -> ConfigFlowResult:
"""Set up the device port selection."""
if self.selectedport != 0:
user_input = {
CONF_ENDPOINT: user_input[CONF_SENSORPORT].split(" ")[2],
CONF_SENSORPORT: user_input[CONF_SENSORPORT][5],
CONF_PASSWORD: self.password,
CONF_EMAIL: self.email,
CONF_CHIPID: self.selecteddevice,
}
return self.async_create_entry(
title=f"BZUGW-{self.selecteddevice}-{user_input[CONF_SENSORPORT]}",
data=user_input,
)

self.selectedport = 1
return self.async_show_form(
step_id="portselect",
data_schema=vol.Schema(
{
vol.Required(CONF_SENSORPORT): SelectSelector(
SelectSelectorConfig(
options=[
SelectOptionDict(value=k, label=k)
for k in get_ports(self.api, user_input[CONF_CHIPID])
],
mode=SelectSelectorMode.LIST,
)
),
}
Copy link
Member

Choose a reason for hiding this comment

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

So why do we only create 1 entry for every device -> port and why don't we create 1 entry for the whole account and add everything?

Copy link
Author

Choose a reason for hiding this comment

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

So why do we only create 1 entry for every device -> port and why don't we create 1 entry for the whole account and add everything?

An account can have many devices, and each device can have up to 76 sensors. So by creating one entry per device and port, it keeps things more concise and easier to manage

Copy link
Member

Choose a reason for hiding this comment

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

But why would someone not add all their devices? If I add a philips hue bridge I expect all my lights to be added, so why won't we add all devices here?

"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/bzutech",
"iot_class": "cloud_push",
"requirements": ["bzutech==2.3.2"]
Copy link
Member

Choose a reason for hiding this comment

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

Where is the library's source?

Copy link
Member

Choose a reason for hiding this comment

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

This is not answered yet

Copy link
Author

Choose a reason for hiding this comment

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

sorry, did not understand what you meant by that, can you link me some documentation on what to change?

@home-assistant home-assistant bot marked this pull request as draft April 8, 2025 10:24
@enioo22 enioo22 marked this pull request as ready for review April 11, 2025 16:19
@home-assistant home-assistant bot requested a review from joostlek April 11, 2025 16:19
@joostlek joostlek marked this pull request as draft May 14, 2025 11:40
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