Add config flow for selecting precision of DS18B20 devices#64315
Add config flow for selecting precision of DS18B20 devices#64315balloob merged 9 commits intohome-assistant:devfrom
Conversation
|
Hey there @garbled1, @epenet, mind taking a look at this pull request as it has been labeled with an integration ( |
|
@droberg please note that using this integration with a direct IO connection on a Raspberry PI is deprecated from next release, it will only be allowed to be used via owserver. |
|
I think the device registry would be best to get the device name. |
|
I see that @emontnemery is working on #64350. That might make this PR redundant... |
|
I looks like the work from emontnemery doesn't solve the issue here, so we'll still need the option flow. |
|
Ok, I haven't had time to read up on #64350 but according to the title it looked exactly like the thing we wanted. I will change the implementation to use friendly names as soon as I have time. I'm still putting in more time learning the structure than actually implementing code so no harm done if this becomes redundant at this point. I was also thinking that I'd rather have the configuration as drop down selectors or using enums etc but this was the best I could do after this level of digging around in the code. |
|
I have now read up on #64350 and as I read it it adds storage of options in the entity structures, with the comment that there is no solution of how to expose this to the frontend yet. When/if this is exposed to the frontend it should cover the "type" option in the same manner as other options as I understand it. Or am I missing something? |
|
I opened this architecture discussion to see what would be possible: home-assistant/architecture#713 I believe that since virtual entities are forbidden (for now) then the OptionsFlow as you are implementing here is the best way to provide a UI. Regarding the storage of the options, I would also keep storing it in the config entry options - it should be a small enough tweak if the policy changes down the line. |
|
The next logical step after #64366 is to allow customizing precision in terms of number of digits. |
|
@emontnemery this PR would serve as a base for other types of sensors:
|
|
Oh, OK. |
|
It now uses the names from the device-registry together with the device id's. This felt like the only way of getting it to work nicely with the config flow multi-select, but it also felt like a good idea to have both the user assigned name and the actual id in the description. |
00275ac to
8742148
Compare
|
Rebased |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
Not sure if the added test actually tests something new |
You need to adjust the mock config entry to add the options for the new sensor |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
3beac32 to
20e7d69
Compare
|
Rebased |
|
@epenet : I'm having some troubles with my environment here. It seems that pyownet and pi1wire is no longer available in the dev-container. I will install them manually but is this because direct access is being deprecated ? |
It's fine on my side - I'm not having any issues. |
|
Oups, messed up when trying a git amend |
|
Thanks! |
88a8729 to
28273f2
Compare
epenet
left a comment
There was a problem hiding this comment.
LGTM, but I'd like a second pair of eyes
balloob
left a comment
There was a problem hiding this comment.
Looks ok if last comment addressed.
|
Cat on keyboard |
|
Sorry for the delay. Will get on with this as soon as possible. |
a62280b to
8bb3066
Compare
|
FIxed review comment, rebased, tested locally etc. |
|
Thanks @droberg 👍 As a follow-up I suggest that you add one for the Thermocouple type (family 30)... |
MartinHjelmare
left a comment
There was a problem hiding this comment.
Please address the comments in a new PR. Thanks!
| @@ -0,0 +1,237 @@ | |||
| """Tests for 1-Wire config flow.""" | |||
There was a problem hiding this comment.
These tests should move to the test_config_flow.py module.
There was a problem hiding this comment.
The reason they are separate is that they needed different mock-setups. This may perhaps sort itself later, when the device-registry comment is handled. (But I can't say for sure )
|
|
||
| # Verify that first config step comes back with a selection list of all the 28-family devices | ||
| with patch( | ||
| "homeassistant.helpers.device_registry.DeviceRegistry.async_get_device", |
There was a problem hiding this comment.
We shouldn't patch the device registry. Create a device in the device registry before starting the test instead.
| config_entry: ConfigEntry, | ||
| ): | ||
| """Test that SysBus options flow aborts on init.""" | ||
| hass.data[DOMAIN] = {config_entry.entry_id: FakeOWHubSysBus()} |
There was a problem hiding this comment.
Don't interact with integration details in the tests. Set up the integration instead with a MockConfigEntry, while patching appropriately to avoid I/O.
Breaking change
Proposed change
Add config flow for selecting temperature precision of Maxim DS18B20 1-wire temperature sensor.
Note that there are still things that needs fixing:
Type of change
Additional information
Checklist
black --fast 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..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: