Make Modbus hub name mandatory#37546
Make Modbus hub name mandatory#37546vzahradnik wants to merge 1 commit intohome-assistant:devfrom Lutemi:bugfix/remove-default-hub
Conversation
Hub name in Modbus entities is optional. If not specified, hub is named 'default'. At the moment, users can omit hub name in entities like sensor, and if the hub has a non-default name like 'hub1', Home Assistant will throw an exception. It's not possible to do cross-validation. To avoid such errors and ambiguity, hub name will be mandatory.
|
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. |
|
Not stale, awaits our review. |
|
Been visiting this PR a couple of times now. I wonder why we should consider this. I get that it might have been a better idea to make the option mandatory from the get-go, but right now, it is optional and provides a default. The only thing this PR will do, is causing a breaking change for existing users that currently DO rely on the default. So, why should we go and break this? |
|
There are three scenarios:
The point of this PR is to enforce better config validation. Ideally, Home Assistant would support something like cross-validation where I could check in the sensors section the definitions of Modbus hubs, and notify users about misconfiguration. It's definitely better than throwing exceptions after validation has "passed". Like you mentioned, this option should be probably mandatory from the start. While working on Modbus, I found several areas, where current configuration needs some improvement to avoid errors during runtime. There are two options:
While discussing in other PRs, I get your policy is to maintain backwards compatibility whenever possible. Anyway, I opened this PR to at least discuss the problem. If you think the current HA behavior is acceptable, you can close this PR. Thanks! |
I'm not against that, however, breaking perfectly working existing configuration without a darn good reason to do so, is not. I think this change would make sense if it was converted from separate platform components into an actual integration (as that would combine the breaking changes). |
|
Ok, in that case I suggest to close this PR. I will also try to get my other PRs merged (as time permits) in a backwards-compatible way. Then, we can start a discussion, how to start a transition into a proper integration. |
home-assistant#37546) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: smarthome-10 <monkey10github@protonmail.com> Co-authored-by: Darren Griffin <darren.griffin@live.co.uk> Co-authored-by: jey burrows <jrb@jeymail.net> Co-authored-by: Manu <4445816+tr4nt0r@users.noreply.github.com> Co-authored-by: Nic Eggert <nic@eggert.io> Co-authored-by: GilDev <gildev@gmail.com> Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: cdnninja <jaydenaphillips@gmail.com> Co-authored-by: Klaas Schoute <klaas_schoute@hotmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com> Co-authored-by: Danny Tsang <567982+dannytsang@users.noreply.github.com> Co-authored-by: Pete Sage <76050312+PeteRager@users.noreply.github.com> Co-authored-by: Jean-Marc Collin <jm.collin.78@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: hanwg <han.wuguang@gmail.com> Co-authored-by: Brett Adams <Bre77@users.noreply.github.com> Co-authored-by: Dan Long <dannylong1988@gmail.com> Co-authored-by: Mitchell van Manen <ma.van.manen@live.nl> Co-authored-by: karwosts <32912880+karwosts@users.noreply.github.com> Co-authored-by: Thomas D <11554546+thomasddn@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Maikel Punie <maikel.punie@gmail.com> Co-authored-by: Petro31 <35082313+Petro31@users.noreply.github.com> Co-authored-by: Michel van de Wetering <michel.van.de.wetering@gmail.com> Co-authored-by: Maciej Bieniek <bieniu@users.noreply.github.com> Co-authored-by: Shay Levy <levyshay1@gmail.com> Co-authored-by: Jérôme OUDOUL <jerome@oudoul.com> Co-authored-by: Kamil Breguła <mik-laj@users.noreply.github.com> Co-authored-by: jkb543 <245537795+jkb543@users.noreply.github.com> Co-authored-by: Josef Zweck <josef@zweck.dev> Co-authored-by: ildar170975 <71872483+ildar170975@users.noreply.github.com> Co-authored-by: Marland Sitt <marland.sitt@gmail.com> Co-authored-by: Nc Hodges <86037210+Hodnc@users.noreply.github.com> Co-authored-by: Steve Easley <steve.easley@gmail.com> Co-authored-by: Ludovic BOUÉ <lboue@users.noreply.github.com> Co-authored-by: MinchinWeb <w_minchin@hotmail.com> Co-authored-by: Anton Dalgren <antondalgren@users.noreply.github.com> Co-authored-by: Duco Sebel <74970928+DCSBL@users.noreply.github.com> Co-authored-by: Andrew Jackson <andrew@codechimp.org> Co-authored-by: Frederic Mariën <FredericMa@users.noreply.github.com> Co-authored-by: Allen Porter <allen.porter@gmail.com> Co-authored-by: Retha Runolfsson <137745329+zerzhang@users.noreply.github.com> Co-authored-by: johanzander <johanzander@gmail.com> Co-authored-by: Paul Tarjan <github@paulisageek.com> Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com> Co-authored-by: Jordan Harvey <jordan@hrvy.uk> Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com> Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Angel <mail2angel17@gmail.com> Co-authored-by: Anthony Garera <gareraanthony@gmail.com> Co-authored-by: starkillerOG <starkiller.og@gmail.com> Co-authored-by: Hedda <rockerc.harley@gmail.com> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Kurt Chrisford <92524101+kclif9@users.noreply.github.com> Co-authored-by: theobld-ww <60600399+theobld-ww@users.noreply.github.com> Co-authored-by: Hans Fehrmann <hans.jfehrmann@gmail.com> Co-authored-by: Matthias Alphart <farmio@alphart.net> Co-authored-by: Niracler <i@niracler.com> Co-authored-by: Siemon Geeroms <siemongeeroms@gmail.com> Co-authored-by: rlippmann <70883373+rlippmann@users.noreply.github.com> Co-authored-by: Lukas <12813107+lmaertin@users.noreply.github.com> Co-authored-by: Ravaka Razafimanantsoa <3774520+SeraphicRav@users.noreply.github.com> Co-authored-by: Guido Schmitz <Shutgun@users.noreply.github.com> Co-authored-by: Bram Kragten <mail@bramkragten.nl> Co-authored-by: Markus Jacobsen <markusjacobsen@hotmail.com> Co-authored-by: wollew <wollew@users.noreply.github.com> Co-authored-by: Marc Hörsken <mback2k@users.noreply.github.com> Co-authored-by: Chris Boyle <chris@boyle.name> Co-authored-by: Marc-Philip <marc-philip.werner@sap.com> Co-authored-by: dvfeinblum <dvfeinblum@gmail.com> Co-authored-by: Aviad Levy <aviadlevy1@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: mettolen <1007649+mettolen@users.noreply.github.com> Co-authored-by: W7RZL <kevmacmills@gmail.com> Co-authored-by: Lukas Gill <lukas.gill@me.com> Co-authored-by: Lukas Gill <gitlab@lukasgill.xyz> Co-authored-by: Galorhallen <12990764+Galorhallen@users.noreply.github.com> Co-authored-by: Ted Pennings <310323+tedpennings@users.noreply.github.com> Co-authored-by: Louis Christ <LouisChrist@users.noreply.github.com> Co-authored-by: Ville Skyttä <ville.skytta@iki.fi> Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com> Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> Co-authored-by: Didgeridrew <19187320+Didgeridrew@users.noreply.github.com> Co-authored-by: doomsniper09 <79980810+doomsniper09@users.noreply.github.com> Co-authored-by: jameson_uk <1040621+jamesonuk@users.noreply.github.com> Co-authored-by: Raphael Hehl <7577984+RaHehl@users.noreply.github.com> Co-authored-by: Trainmaster2 <dphammock@gmail.com> Co-authored-by: Andrzej Dopierała <theundefined@users.noreply.github.com> Co-authored-by: Jan Klausa <jan@klausa.pl> Co-authored-by: MarkGodwin <10632972+MarkGodwin@users.noreply.github.com> Co-authored-by: surfingbytes <94438335+surfingbytes@users.noreply.github.com> Co-authored-by: Matrix <justin@yosmart.com> Co-authored-by: J. Diego Rodríguez Royo <jdrr1998@hotmail.com> Co-authored-by: Glenn de Haan <glenn@dehaan.cloud> Co-authored-by: Willem-Jan van Rootselaar <liudgervr@gmail.com> Co-authored-by: Felipe Santos <felipecassiors@gmail.com> Co-authored-by: Åke Strandberg <ake@strandberg.eu>
This pull request enforces hub name as a mandatory parameter. At the moment it's entirely optional, which introduces ambiguity.
Breaking change
Modbus hub name was optional. With this change, user has to specify a hub name
to avoid ambiguity in the configuration:
nameparameter for each Modbus hubhubparameter for each Modbus entity, telling which hub to useProposed change
Here's an example config:
To better describe my point, let me show you the following several scenarios:
hubparameter from thebinary_sensor, this parameter will be set todefault. Such a hub doesn't exist. Home Assistant throws an exception at some point while trying to access adefaulthub. We could add a code, which will set up an alias for the first hub in a list, but I think it's better to make the parameter mandatory insteadhub1andhub2, we end up with a non-working configuration. Both hubs are calleddefaultbinary_sensordoesn't specify a hub, there should at least one Modbus hub with a default name. Otherwise, the config is invalid).All examples in the documentation already specify a hub name. Users who copy and paste the sample documentation most likely use the name parameter already. However, if they're calling Modbus services
write_coilandwrite_registerfrom the automation, they will need to adapt their automation rules to also specify a hub.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: