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 Firmata Integration (attempt 2) #35591
Conversation
Update fork
I have fixed the Pymata dependency issue (the async issue in the Pypy version has been fixed). I have updated the checklist. I have started working on docs. |
I have opened a pull for docs and updated the above checklist. |
OK, I have been running the integration on my HA setup for a while now and I can successfully report zero issues! |
OK, I ran I am also not sure what I am testing here. There is no |
If you have an example of what the tests and |
We want to test that each entry point and exit point in the config flow behaves as expected and generates the correct result. In our case here that should be one test for successful entry creation and one test for unsuccessful connection with abort as result. Patch the library to avoid I/O in the tests. Follow the example code generated by the scaffold script. Search for other config flow tests that test the import step. It's basically the same as testing the user step, just a different step name so the source will be different. |
OK, so it also seems maybe I should be using the {
"config": {
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"step": {
"import": {}
}
}
} But I am confused how then to raise the error. Here is one example that confuses me: async def async_step_import(self, user_input=None):
"""Handle the import."""
errors = {}
if user_input is not None:
if self._host_port_alias_already_configured(user_input):
return self.async_abort(reason="already_configured")
_, errors = await self._async_validate_or_error(user_input)
if not errors:
title = _format_host_port_alias(user_input)
return self.async_create_entry(title=title, data=user_input)
return self.async_show_form(
step_id="user", data_schema=_base_schema({}), errors=errors
) The error is raised using |
Additionally, how can I stop the integration from appearing in the UI? Currently it is listed and clicking it show a white box that simply says "Aborted." |
Our config flow should abort on error. Don't set config flow to true in manifest.json to avoid the integration showing in the integration list in the GUI. |
Wow the GitHub Actions CI starts up and completes much faster than the Azure Pipelines did. Very smooth! 👏 |
OK, I added two more tests for those two exceptions to maintain coverage. Please let me know if there are any other changes I need to make, and thank you for walking me through this process thus far! |
OK, let me know if there is anything else that needs to be fixed! |
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.
Looks good!
🎉 🎊 Yay! This was a great learning process for me, thank you! Can't believe it has been so long since I started #24014. 😄 🏠 |
Proposed change
This pull adds a new Firmata integration.
This is an updated continuation of an older pull (#24014).
Type of change
Example entry for
configuration.yaml
:Additional information
The usage of a Git repo for a requirement is temporary but should allow for at least a code review. I am awaiting a release on the Pymata side to fix some issues with event loop handling in the library (it required an empty loop and closes the loop on failure)—my pull was accepted and the developer is doing some testing.Checklist
(see additional info about Git requirement)black --fast homeassistant tests
)(this is a hardware integration without config flows, there are no tests)Tests have been added for the config flowIf 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
.(see additional info about Git requirement)requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.(see additional info about Git requirement).coveragerc
.The integration reached or maintains the following Integration Quality Scale: