feat: prefer unified warning about equipment with repeated names, with context about source of equipment#126
Conversation
bccdfa1 to
45baf41
Compare
…h context about source of equipment Check for duplicate names in the main refresh loop. Describe that they are due to output from the OmniLogic unit itself. This will help clarify the source in downstream usage, like in Home Assistant (HA). I personally saw messages in HA like the following and thought I had incorrectly set up the HA OmniLogic integration: ``` 2026-04-24 20:56:23.095 WARNING (MainThread) [pyomnilogic_local.collections] Equipment collection contains 4 items with the same name 'SolarSensor'. Name-based lookups will return the first match. Consider using system_id-based lookups for reliability or renaming equipment to avoid duplicates. 2026-04-24 20:56:24.636 WARNING (MainThread) [pyomnilogic_local.collections] Equipment collection contains 2 items with the same name 'Gas'. Name-based lookups will return the first match. Consider using system_id-based lookups for reliability or renaming equipment to avoid duplicates. 2026-04-24 20:56:24.637 WARNING (MainThread) [pyomnilogic_local.collections] Equipment collection contains 2 items with the same name 'Solar'. Name-based lookups will return the first match. Consider using system_id-based lookups for reliability or renaming equipment to avoid duplicates. 2026-04-24 20:56:24.638 WARNING (MainThread) [pyomnilogic_local.collections] Equipment collection contains 2 items with the same name 'Filter Pump'. Name-based lookups will return the first match. Consider using system_id-based lookups for reliability or renaming equipment to avoid duplicates. 2026-04-24 20:56:24.639 WARNING (MainThread) [pyomnilogic_local.collections] Equipment collection contains 2 items with the same name 'Chlorinator'. Name-based lookups will return the first match. Consider using system_id-based lookups for reliability or renaming equipment to avoid duplicates. 2026-04-24 20:56:24.641 WARNING (MainThread) [pyomnilogic_local.collections] Equipment collection contains 2 items with the same name 'WaterSensor'. Name-based lookups will return the first match. Consider using system_id-based lookups for reliability or renaming equipment to avoid duplicates. 2026-04-24 20:56:24.641 WARNING (MainThread) [pyomnilogic_local.collections] Equipment collection contains 2 items with the same name 'FlowSensor'. Name-based lookups will return the first match. Consider using system_id-based lookups for reliability or renaming equipment to avoid duplicates. ```
45baf41 to
a714424
Compare
|
Having the check for duplicates in the EquipmentDict.init means that the check for duplicates is only ever considered once, when the EquipmentDict is initially created. Putting it in the OmniLogic._update_equipment method means that it is considered on every loop, necessitating a set comprehension and a conditional branch on every loop iteration. The performance hit is not much, but something to be mindful of. If the concern is that the warning message doesn't make it clear that this is coming from the Omni configuration as opposed to some other cause, it seems like this is a pretty heavy-handed approach to resolving that concern when it could be as simple as just re-wording the warning message. I think the only advantage to moving the logic to the refresh loop is that it makes it easy to put the hostname and port of the Omni in the error message, right? I'm not sure that gives enough of a benefit to justify moving all of the logic to a location that adds a set comprehension and branch to every refresh. I would be open to a change that just re-words the warning message to something that makes it more obvious though, something with some more "people friendly" verbiage. |
… to address SonarQube feedback, and remove stale line
d67c35d to
2c972a9
Compare
|
My thinking is:
I realize now that _update_equipment is called when would be more efficient. Agreed this could also just be a different log message if you want it only to be more "people friendly". |
… more compact line
|



Not sure if you like the check being moved out of EquipmentDict. I think it's cleaner to do this explicitly in the main loop, where the caller can annotate with additional context, and I don't think it reduces safety. Happy to rework or drop if you like. Thank again for great work and amazing recent release!
Check for duplicate names in the main refresh loop. Describe that they are due to output from the OmniLogic unit itself. This will help clarify the source in downstream usage, like in Home Assistant (HA).
I personally saw messages in HA like the following and thought I had incorrectly set up the HA OmniLogic integration: