core: HA is not subscribing to newly discovered MQTT topics

The problem

I’m using zwave-js-ui and recently updated my configuration so that I’m now exposing specific device configuration variables over MQTT by default, and this is reflected in the devices discovery payload as well.

I have tried to restart my zwave-js-ui instance and reloaded the MQTT integration in Home Assistant, but I was not able to make HA to subscribe to the new topics.

I was only able to get the newly exposed device config parameters to appear in HA by removing my whole MQTT integration and re-adding it. After this, HA correctly subscirbed to all neccessary topics.

How could I make HA to subscribe to new topics without needing to remove the MQTT integration then re-add it?

What version of Home Assistant Core has the issue?

2024.8.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

mqtt

Link to integration documentation on our website

https://www.home-assistant.io/integrations/mqtt/

Diagnostics information

No response

Example YAML snippet


Anything in the logs that might be useful for us?


Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

The only changed option is that enabled_by_default is set to True (new payload).

When an entity is discovered with enabled_by_default set to False, the entity will be created in the entity registry. As the entity is disabled, it will not listen to discovery updates as it is disabled. Even when HA is restarted, it will still be disabled, as it is already in the entity registry in a disabled state. Setting enabled_by_default to True only effects new entities.

The user should enable the entity, and after that it will update the discovery as well. This is all by design, and not a bug.

It is possible to remove an entity by publishing an empty payload to the the discovery topic. This will completely remove the entity from the entity registry. After that a new discovery payload with enabled_by_default set to True will set up an enabled entity. But for users that already enabled the entity this might break their customization, automation’s and scripts.

old:

{
    "value_template": "{{ value_json.value }}",
    "command_topic": "room317/dh_104_317_fancoil/112/0/52/set",
    "enabled_by_default": false,
    "entity_category": "config",
    "min": 0,
    "max": 6,
    "state_topic": "room317/dh_104_317_fancoil/112/0/52",
    "availability": [
        {
            "payload_available": "true",
            "payload_not_available": "false",
            "topic": "room317/dh_104_317_fancoil/status",
            "value_template": "{{'true' if value_json.value else 'false'}}"
        },
        {
            "topic": "room317/_CLIENTS/ZWAVE_GATEWAY-room317/status",
            "value_template": "{{'online' if value_json.value else 'offline'}}"
        },
        {
            "payload_available": "true",
            "payload_not_available": "false",
            "topic": "room317/driver/status"
        }
    ],
    "availability_mode": "all",
    "device": {
        "identifiers": [
            "zwavejs2mqtt_0xca8eff36_node24"
        ],
        "manufacturer": "McoHome Technology Co., Ltd.",
        "model": "0xf523 (Unknown product 0x7101)",
        "name": "dh_104_317_fancoil",
        "sw_version": "3.2.8"
    },
    "name": "_config_number_52",
    "unique_id": "zwavejs2mqtt_0xca8eff36_24-112-0-52"
}

new:

{
    "value_template": "{{ value_json.value }}",
    "command_topic": "room317/dh_104_317_fancoil/112/0/52/set",
    "enabled_by_default": true,
    "entity_category": "config",
    "min": 0,
    "max": 6,
    "state_topic": "room317/dh_104_317_fancoil/112/0/52",
    "availability": [
        {
            "payload_available": "true",
            "payload_not_available": "false",
            "topic": "room317/dh_104_317_fancoil/status",
            "value_template": "{{'true' if value_json.value else 'false'}}"
        },
        {
            "topic": "room317/_CLIENTS/ZWAVE_GATEWAY-room317/status",
            "value_template": "{{'online' if value_json.value else 'offline'}}"
        },
        {
            "payload_available": "true",
            "payload_not_available": "false",
            "topic": "room317/driver/status"
        }
    ],
    "availability_mode": "all",
    "device": {
        "identifiers": [
            "zwavejs2mqtt_0xca8eff36_node24"
        ],
        "manufacturer": "McoHome Technology Co., Ltd.",
        "model": "0xf523 (Unknown product 0x7101)",
        "name": "dh_104_317_fancoil",
        "sw_version": "3.2.8"
    },
    "name": "_config_number_52",
    "unique_id": "zwavejs2mqtt_0xca8eff36_24-112-0-52"
}