Fixes HA WARNING message during startup. Defines default_entity_id based on platform and object_id. Removes deprecated object_id
Describe what the PR does:
Fixes HA WARNING message during startup. Renames object_id with default_entity_id
Does this fix a specific issue?
Fixes https://github.com/bachya/ecowitt2mqtt/issues/1324
No new functionality added!
Checklist:
- [x] Confirm that one or more new tests are written for the new functionality.
- [x] Run tests and ensure everything passes (with 100% test coverage).
- [x] Update
README.mdwith any new documentation.
According to the log the default_entity_id should include the platform before the prefix. I don't think just renaming the key is enough.
"default_entity_id": "sensor.E2m_soilad7"
Hi,
Thanks for reviewing the PR.
I wanted to clarify a point regarding your comment that “the default_entity_id should include the platform before the prefix, and that simply renaming the key is not enough.” In this context, my understanding of “platform” matches what Home Assistant refers to as the domain (sensor, binary_sensor, etc.).
The Home Assistant warning explicitly states that the new value should be the full entity_id, including the domain, for example:
"default_entity_id": "sensor.E2m_soilad7"
In other words, it expects exactly the old object_id prefixed with the domain. This aligns with the standard MQTT discovery format, where the entity ID is constructed as <platform>.<object_id>.
Of course, if in the future you plan to redesign how identifiers are generated or restructure the discovery payloads more broadly, that would be great — but this minimal change already resolves the incompatibility and allows the integration to move forward without warnings.
Thanks again for your work on the project.
Hi, firstly I'm not the owner of this project, just the person that raised the issue you linked to.
You are right, Platform is an internal name within HA for what are base domains so sensor/switch etc.
I don't think your code change adds the sensor part, I did look at this and there are a couple different domains we'd have to pass through to this function to do the prefix.
Hi, firstly I'm not the owner of this project, just the person that raised the issue you linked to.
You are right, Platform is an internal name within HA for what are base domains so sensor/switch etc.
I don't think your code change adds the sensor part, I did look at this and there are a couple different domains we'd have to pass through to this function to do the prefix.
Digging a little bit into the MQTT server I think you are right, I'm going to change the PR