Issue warning modbus configuration when modbus configuration is empty#112618
Conversation
|
That's the same PR |
|
it is clearly not my day, I am out of coffee !! It should have said #112619 |
|
@joostlek do you want more changes or explanations? |
| entity_inx += 1 | ||
|
|
||
| if no_entities: | ||
| err = f"Modbus {hub[CONF_NAME]} is instable without entities, please add entities!" |
There was a problem hiding this comment.
| err = f"Modbus {hub[CONF_NAME]} is instable without entities, please add entities!" | |
| err = f"Modbus {hub[CONF_NAME]} is unstable without entities, please add entities!" |
| err = f"Modbus {hub[CONF_NAME]} is instable without entities, please add entities!" | ||
| _LOGGER.warning(err) | ||
| # Ensure timeout is not started/handled. | ||
| hub[CONF_TIMEOUT] = -1 |
There was a problem hiding this comment.
So for whom would this log message be? Because if someone adds this to support a custom integration, the message to "please add entities!" doesn't really make sense, since the custom integration is doing this for them.
In what way will it be unstable?
Maybe sentences like:
"There are no entities defined for {something}. Ignoring timeout."
"There are no entities defined for {something}. This can lead to modbus updating less predictable."
There was a problem hiding this comment.
The text is for the end-user who uses the integration, and even if the custom integration adds entities, we have no idea how (and do not want to know), so we have no way of knowing if the integration continues to be unstable.
The only valid option is to add at least one entity (some custom components are now, finally, starting to recommend that).
I have tried to adjust the text along your suggestion. WDYT ?
Breaking change
Proposed change
The minimum_scan_interval was controlled pr entity type, leading to timeout = -1 when no entities was defined.
this PR calculates the minimum_scan_interval across all entity types and still sets timeout = -1 when no entities is defined.
Seems from HA core POW, it does not makes sense to have modbus defined without any entities and may cause problems (e.g. most devices terminate the connection after a while without communication, but the reconnect logic depend on the entity update method).
This PR issues a warning when modbus is configured without entities. Some custom components use this configuration to add their own configuration (HIGHLY NOT RECOMMENDED) so currently we issue only a warning.
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..coveragerc.To help with the load of incoming pull requests: