-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
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
base: dev
Are you sure you want to change the base?
Add Bzu Tech integration #132393
Conversation
There was a problem hiding this 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 :)
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
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, | ||
) | ||
), | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
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
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: