Skip to content

MQTT: Use default_entity_id instead of object_id#1351

Merged
FrankBakkerNl merged 2 commits intonet-daemon:mainfrom
brechtvhb:features/default-entity-id
Mar 21, 2026
Merged

MQTT: Use default_entity_id instead of object_id#1351
FrankBakkerNl merged 2 commits intonet-daemon:mainfrom
brechtvhb:features/default-entity-id

Conversation

@brechtvhb
Copy link
Contributor

@brechtvhb brechtvhb commented Dec 24, 2025

Breaking change

Proposed change

This pull request updates the MQTT Entity Manager to improve how entity IDs are handled when creating MQTT entities. The main change is the replacement of the ObjectId property with a new DefaultEntityId property, which is now constructed using both the domain and identifier for greater clarity and uniqueness. The old ObjectId will be deprecated in 2026.4.

NetDaemon generated entities generate these warnings in the home assistant logs:

The configuration for entity switch.flexilights_terrace uses the deprecated option `object_id` to set the default entity id. Replace the `"object_id": "flexilights_terrace"` option with `"default_entity_id": "switch.flexilights_terrace"` in your published discovery configuration to fix this issue, or contact the maintainer of the integration that published this config to fix this. This will stop working in Home Assistant Core 2026.4

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • The code compiles without warnings (code quality check)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration are added/changed:

Copilot AI review requested due to automatic review settings December 24, 2025 14:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the MQTT Entity Manager to use default_entity_id instead of the deprecated object_id property when creating MQTT entities in Home Assistant. The main change is that default_entity_id now contains the full entity ID in the format domain.identifier (e.g., "sensor.kitchen_temp") rather than just the identifier portion (e.g., "kitchen_temp").

Key Changes:

  • Replaced ObjectId property with DefaultEntityId in EntityCreationPayload
  • Updated JSON serialization to use default_entity_id instead of object_id
  • Implemented DefaultEntityId() helper method that constructs the full entity ID format

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Extensions/NetDaemon.Extensions.MqttEntityManager/MqttEntityManager.cs Added DefaultEntityId() helper method and updated entity creation to use it instead of passing just the identifier to ObjectId
src/Extensions/NetDaemon.Extensions.MqttEntityManager/Models/EntityCreationPayload.cs Renamed ObjectId property to DefaultEntityId and updated JSON property name from object_id to default_entity_id; minor whitespace cleanup

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82%. Comparing base (51f839f) to head (83f18eb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff          @@
##           main   #1351   +/-   ##
====================================
  Coverage    82%     82%           
====================================
  Files       199     199           
  Lines      3909    3910    +1     
  Branches    443     443           
====================================
+ Hits       3221    3225    +4     
+ Misses      518     515    -3     
  Partials    170     170           
Flag Coverage Δ
unittests 82% <100%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brechtvhb
Copy link
Contributor Author

@helto4real Any plans on merging this? Current implementation wil break in HA 2026.4.

@FrankBakkerNl
Copy link
Contributor

@brechtvhb looks like you did not sign the commit. That is a requirement for this repo

@brechtvhb brechtvhb force-pushed the features/default-entity-id branch from de40c6a to e68ea0d Compare March 21, 2026 06:57
@brechtvhb brechtvhb force-pushed the features/default-entity-id branch from e68ea0d to 83f18eb Compare March 21, 2026 07:06
@brechtvhb
Copy link
Contributor Author

@FrankBakkerNl Thanks for the heads up, commits are signed now. Can you re-run the workflows?

@FrankBakkerNl FrankBakkerNl enabled auto-merge (squash) March 21, 2026 07:36
@FrankBakkerNl FrankBakkerNl merged commit 035ee37 into net-daemon:main Mar 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MQTT warning: deprecated option object_id

3 participants