MQTT object_id vs default_entity_id warning

I have manual created MQTT sensors and now get e.g.

The configuration for entity sensor.rasenmaher_modus_raw uses the deprecated option object_id to set the default entity id. Replace the "object_id": "rasenmaher_modus_raw" option with "default_entity_id": "sensor.rasenmaher_modus_raw" 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

They were created long time ago via:

      topic: homeassistant/sensor/rasenmaher_modus_raw/config
      retain: true
      payload: |
        {
          "state_topic": "automower/mower/mode",
          "name": "Rasenmäher Modus Raw",
          "unique_id": "unique_id_rasenmaher_modus_raw",
          "object_id": "rasenmaher_modus_raw",
          "icon": "mdi:state-machine",
          "device": {
              "identifiers": ["330x"],
              "name": "Husqvarna Automower 330x",
              "model": "330x",
              "manufacturer": "Husqvarna",
              "sw_version": "7.04.00"
          }
        }
    action: mqtt.publish

But this script is not running. First, I though it is a spook-kind warning about the content of this script ans I changed it, but warning remain.

Then I searched in my configs and entity registry but can’t find, where I can or have to adjust here.

I found only one related issue, but this was related to a real integration, which have been fixed.

Any hints/ideas?

Getting the same error, but specifically with my MQTT update entities. I’m currently researching a solution.

My error log entry:

Replace the "object_id": "bed_spot_2" option with "default_entity_id": "update.bed_spot_2" in your published discovery configuration to fix this issue

UPDATE

I run Z2M and MQTT in separate Docker containers on my NAS. Updating to the latest image solved my issues!

same problem with a marstek battery connected via MQTT.
I don’t even know where to start.

I love home assistant, but do they change for the sake of changing?

Depending on how this MQTT entity has been created.
If you did that manually, adjust the yaml configuration.
If it’s created by the device/software you are using, this software needs to be updated to support the new key (default_entity_id). Otherwise, even if you replace the old key manually in MQTT, it might be overwritten again.

You still have 6 months left. So no panic.

The same error in the logs here after a reboot.
I see that almost all unique MQTT ID’s seem to change.
e.g. object_id: “eastron.L2L3_Voltage” changes to L2L3_Voltage"

Is there a way to keep the old object_id as unique identifier that is used in the dashboards?

Manually changing the ID of each one of 200 MQTT entities and renaming the same entity in every dashboard and statistics is no fun. It is like starting again complete from the beginning.

it should be enough to replace object_id with default_entity_id. I did that in one step with use of VSC.

However (unless I hallucinate - no, I’m not AI), while for mqtt entities the name alone assigned to default_entity_id is enough, for some reason templates require name prefixed by a domain,
for example


     - name: Bobik Last Use Time
       unique_id: bobik_last_use_time
       default_entity_id: sensor.bobik_last_use_time

do you really have a dot in the entity identifier? Are you surrounding it with double quotas?

I have opened an ESPHome issue for this problem as it is caused by the config topic automatically populated by the ESPhome MQTT component. https://github.com/esphome/esphome/issues/12353

1 Like

Maybe some more background:

  • I manually crafted the mqtt.yaml file after researching home assistant forums to find a way to bring entities from Node-RED to Home assistant.

I created it like this:

  sensor:
    - name: "Woonkamer - Temperature"
      object_id: "climate.T02livingtemp"
      icon: mdi:thermometer
      unit_of_measurement: "°C"
      device_class: temperature
      state_topic: "/LOGO100/woonkamer/temperature"

    - name: "OVK01-K.04-ID.04"
      object_id: "K04-ID04.Energyuse"
      icon: mdi:flash-triangle-outline
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing
      state_topic: "/K04-ID04/energyKWH "
      value_template: >
        {% set payload_json = value_json[0] %}      
        {{ payload_json.energyKWH }}

I tried search and replace object_id with default_entity_id but lost (invalidated) all MQTT objects in home assistant after saving and checking the configs.

I am looking for a easy way, with my hundeds of sensors and calculated sensors

Hello maxym,

Back again after doing some tests to see what works.

Yes, there are dots and double quotes, I see now adding the dots wasn’t the best choice.

As said using “default_entity_id” was a problem. What I didn’t saw in your example was the domain part “sensor.” before the entityname. After adding this sensor part to some test entities. With good results: the entity is not removed or changed and even the history stays intact. I think this could be a good and easy to implement solution.

  - name: "Kitchen temperature"
    default_entity_id: "sensor.TempG.kitchen"
    unique_id: e3d75321-9999-0000-1111-2222222222222
    icon: mdi:thermometer
    suggested_display_precision: 1
    unit_of_measurement: "°C"
    device_class: temperature
    expire_after: 600
    payload_not_available: "offline"
    state_topic: "domoticz/out/Thermometer kitchen(G)"
    value_template: >
      {% set payload_json = value_json %}
      {{ payload_json.svalue1 | default }}

I added “unique_id” too so I can now edit the testsensor in the GUI (the shown UUID is not the real one).

Further testing is needed to find out if automations, templates and such will work too.