Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions homeassistant/components/modbus/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,14 @@ def validate_entity(
if not validate_modbus(hub, hub_name_inx):
del config[hub_inx]
continue
minimum_scan_interval = 9999
no_entities = True
for component, conf_key in PLATFORMS:
if conf_key not in hub:
continue
no_entities = False
entity_inx = 0
entities = hub[conf_key]
minimum_scan_interval = 9999
while entity_inx < len(entities):
if not validate_entity(
hub[CONF_NAME],
Expand All @@ -388,7 +390,11 @@ def validate_entity(
del entities[entity_inx]
else:
entity_inx += 1

if no_entities:
err = f"Modbus {hub[CONF_NAME]} is instable without entities, please add entities!"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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!"

_LOGGER.warning(err)
# Ensure timeout is not started/handled.
hub[CONF_TIMEOUT] = -1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

@janiversen janiversen Mar 8, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

if hub[CONF_TIMEOUT] >= minimum_scan_interval:
hub[CONF_TIMEOUT] = minimum_scan_interval - 1
_LOGGER.warning(
Expand Down