# HomeAssistant MQTT Discovery losing channels

**URL:** <https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872>\
**Category:** Off-Topic\
**Created:** [July 22, 2026, 6:49am UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872 "2026-07-22T06:49:26Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [August 10, 2026, 3:12pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/21 "2026-08-10T15:12:19Z")

</div>

> [@Homer-Sim](#):
>
> In which log would be a kind of message like  
> added channel xy to thing yx ?

Maybe in the debug or trace level logs from the Home Asssitant binding.

> [@Homer-Sim](#):
>
> In the logs I found this

Going forward please use code fences for logs. It makes them much easier to read.

````
```
code goes here
```

````

Unfortunately, you need to correlate the entries in openhab.log with those entries from events.log to understand _why_ the Thing went offline and came back online.

---

<div class="post-metadata">

**Author:** ![Homer-Sim](https://community.openhab.org/user_avatar/community.openhab.org/homer-sim/32/18374_2.png) [@Homer-Sim](https://community.openhab.org/u/Homer-Sim)\
**Post date:** [August 11, 2026, 12:50pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/22 "2026-08-11T12:50:29Z")

</div>

The problem occurred again today. At some point, the channels were “forgotten” again. When I disabled the Thing and then enabled it again at around 14:20 today, the channels were back.

I have included the `events.log` and `openhab.log` for that time period here.

However, I can’t see anything unusual or obvious in the logs.

Can you make anything of this?

Thanks!

[log.log](https://community.openhab.org/uploads/short-url/iXds3SqzcOP85g0Y5RfDlMYJqFC.log) (35.2 KB)

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [August 11, 2026, 1:43pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/23 "2026-08-11T13:43:40Z")

</div>

I don’t read German so I can only really understand the entries from events.log.

---

<div class="post-metadata">

**Author:** ![apella12](https://community.openhab.org/user_avatar/community.openhab.org/apella12/32/117154_2.png) [@apella12](https://community.openhab.org/u/apella12)\
**Post date:** [August 11, 2026, 8:08pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/24 "2026-08-11T20:08:37Z")

</div>

I think this was mentioned earlier, but you can avoid the HA thing(s) from going offline by linking your items to the topics in the top section of the MQTT explorer using a generic MQTT thing(s). I haven’t read all this post, but the HA thing includes an availability that triggers the offline. One possible thought is the hm2mqtt app marks a device unavailable if it hasn’t heard from it in a while (could be no activity-fully discharged and no solar, or could have a communication drop, or something else). It seems from the post that the published topic by hm2mqtt does not change so with a generic MQTT availability won’t come into play. Obviously, the item value could be stale, but that might be okay. You could also add the availability topic to the generic as a switch to track, but it won’t cause the generic thing to go offline. Just a suggestion, but is what I would do.

FWIW I only use generic MQTT but did try HA things in the beginning. It is a little more advanced to set up using generic, so is not for everyone. My main reason for generic things could be described as “neatness”. I only create the channels that I use, the HA things have too much clutter (IMO).

---

<div class="post-metadata">

**Author:** ![jimtng](https://community.openhab.org/user_avatar/community.openhab.org/jimtng/32/98543_2.png) [@jimtng](https://community.openhab.org/u/jimtng)\
**Post date:** [August 12, 2026, 3:09am UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/25 "2026-08-12T03:09:52Z")

</div>

> [@apella12](#):
>
> generic MQTT availability won’t come into play. Obviously, the item value could be stale, but that might be okay. You could also add the availability topic to the generic as a switch to track, but it won’t cause the generic thing to go offline

how about this: [Thing Configuration](https://www.openhab.org/addons/bindings/mqtt/#thing-configuration)

---

<div class="post-metadata">

**Author:** ![Homer-Sim](https://community.openhab.org/user_avatar/community.openhab.org/homer-sim/32/18374_2.png) [@Homer-Sim](https://community.openhab.org/u/Homer-Sim)\
**Post date:** [August 12, 2026, 11:48am UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/26 "2026-08-12T11:48:19Z")

</div>

> [@apella12](#):
>
> . It seems from the post that the published topic by hm2mqtt does not change so with a generic MQTT availability won’t come into play. Obviously, the item value could be stale, but that might be okay. You could also add the availability topic to the generic as a switch to track, but it won’t cause the generic thing to go offline. Just a suggestion, but is what I would do.

I guess this will be the way I will go (generic MQTT)

Is there a easy way to format the existing yaml code from the HA discovered thing to a generic mqtt code?

---

<div class="post-metadata">

**Author:** ![apella12](https://community.openhab.org/user_avatar/community.openhab.org/apella12/32/117154_2.png) [@apella12](https://community.openhab.org/u/apella12)\
**Post date:** [August 12, 2026, 12:37pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/27 "2026-08-12T12:37:30Z")

</div>

> [@Homer-Sim](#):
>
> I guess this will be the way I will go (generic MQTT)

At least give it a try maybe on one device and see if you like it better. You can always go back to HA.

> [@Homer-Sim](#):
>
> Is there an easy way to format the existing yaml code

The topic is easy. It is the highlighted one in your post 7. The trickier part is the Transformation. I may have used AI in my similar situation with a shelly device. However, once you get one working you can just copy/paste in the code tab. Not an expert, but this is a working example with a JSON

 ![haconvert 2026-08-12 082814](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/2/6/26b5493c94ecddc0c4528e8b410d5b5f0add81eb.png)

The transformation to extract the temperature (100, 104 are separate thermocouples). On the code tab

```auto
      Furnace_Return_Air:
        type: number
        label: Furnace Return Air Temperature
        config:
          stateTopic: shellyplusuni-8c4f00a6cbec/events/rpc
          transformationPattern:
            - "JSONPATH:$.params['temperature:100'].tF" //This drills down to what you want. In my case it is the tF in the above picture
          formatBeforePublish: '%s'
          retained: false
          postCommand: false
          step: 1
          unit: °F
      Furnace_Main_Floor_Vent:
        type: number
        label: Furnace Main Floor Outlet Temperature
        config:
          stateTopic: shellyplusuni-8c4f00a6cbec/events/rpc
          transformationPattern:
            - "JSONPATH:$.params['temperature:104'].tF"
          formatBeforePublish: '%s'
          retained: false
          postCommand: false
          step: 1
          unit: °F

```

---

<div class="post-metadata">

**Author:** ![Homer-Sim](https://community.openhab.org/user_avatar/community.openhab.org/homer-sim/32/18374_2.png) [@Homer-Sim](https://community.openhab.org/u/Homer-Sim)\
**Post date:** [August 12, 2026, 2:16pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/28 "2026-08-12T14:16:27Z")

</div>

> [@apella12](#):
>
> ```auto
> 
> ```

I managed to create all retrieving channels but I am struggling hard with the command ones .

This is the HA automatic discovered part

````auto
```
channels:
  adaptive_mode:
    type: switch
    label: Adaptive Mode
    config:
      component: switch
      nodeid: HMJ-2_009b08a56a51
      objectid:
        - adaptive_mode
      config:
        - "{\"name\":\"Adaptive Mode\",\"icon\":\"mdi:auto-fix\",\"state_topic\":\"hm2mqtt/HMJ-2/device/009b08a56a51/data\",\"value_template\":\"{{ value_json.adaptiveMode }}\",\"command_topic\":\"hm2mqtt/HMJ-2/control/009b08a56a51/adaptive-mode\",\"payload_on\":\"true\",\"payload_off\":\"false\",\"state_on\":true,\"state_off\":false,\"availability\":[{\"topic\":\"hm2mqtt/availability\",\"payload_available\":\"online\",\"payload_not_available\":\"offline\"},{\"topic\":\"hm2mqtt/HMJ-2/availability/009b08a56a51\",\"payload_available\":\"online\",\"payload_not_available\":\"offline\"}],\"unique_id\":\"009b08a56a51_adaptive_mode\",\"device\":{\"ids\":[\"hame_energy_009b08a56a51\"],\"name\":\"HAME Energy HMJ-2 009b08a56a51\",\"model_id\":\"HMJ-2\",\"manufacturer\":\"HAME Energy\",\"sw_version\":\"116.6\",\"connections\":[[\"bluetooth\",\"00:9B:08:A5:6A:51\"]]},\"origin\":{\"name\":\"hm2mqtt\",\"url\":\"https://github.com/tomquist/hm2mqtt\"}}"

```

````

I tried as commandTopic: hm2mqtt/HMJ-2/control/009b08a56a51/adaptive-mode

But a look into mqtt explorer does not show a topic like this  
If i hit the switch the value in mqtt explorer is not changing and it a new topic control is appearing?  
KI is not a big help in this case, I tried

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [August 12, 2026, 2:45pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/29 "2026-08-12T14:45:22Z")

</div>

> [@Homer-Sim](#):
>
> If i hit the switch the value in mqtt explorer is not changing and it a new topic control is appearing?

What do you see in the openhab.log? If that topic doesn’t appear in MQTT Explorer it means the message wasn’t publishes which is likely caused by an error on the OH side.

Also, what is being sent as the message? It’s almost certainly not going to accept just “ON” and “OFF” as the message.

Until the topic has a message in it, MQTT Explorer will not show that the topic exists.

---

<div class="post-metadata">

**Author:** ![Larsen](https://community.openhab.org/user_avatar/community.openhab.org/larsen/32/95475_2.png) [@Larsen](https://community.openhab.org/u/Larsen)\
**Post date:** [August 12, 2026, 4:40pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/30 "2026-08-12T16:40:34Z")

</div>

> [@Homer-Sim](#):
>
> I managed to create all retrieving channels but I am struggling hard with the command ones .

Here an example with the command part:

```auto
things:
  mqtt:topic:Pool:
    bridge: mqtt:broker:MosquittoMqttBroker
    label: Pool Sicherung
    channels:
      state:
        type: switch
        label: State
        config:
          stateTopic: zigbee2mqtt/Hoch1/state
          commandTopic: zigbee2mqtt/Hoch1/set
          formatBeforePublish: '%s'
          retained: false
          postCommand: false
          "on": "ON"
          "off": "OFF"

```

or with format before publish

```auto
config:
          commandTopic: zigbee2mqtt/LichtWohn/set
          formatBeforePublish: "{\"scene_recall\": %s}"
          retained: false
          postCommand: false
          step: 1

```

---

<div class="post-metadata">

**Author:** ![apella12](https://community.openhab.org/user_avatar/community.openhab.org/apella12/32/117154_2.png) [@apella12](https://community.openhab.org/u/apella12)\
**Post date:** [August 12, 2026, 5:33pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/31 "2026-08-12T17:33:29Z")

</div>

I didn’t see that parameter in your data either. Do you have a way to trigger that from the hm2.Mqtt application and see if something is published in Explorer? It may not be retained, so will only appear for a second or two. You really need to see that in Explorer, otherwise you are just guessing

As to to the message, the other responses are right. From the HA config it look like a true or false, and as noted command usually have the trailing “set”.

EDIT: My Shelly doesn’t have control channels, but here is another switch example (with true/false)

```auto
      Shop_Area_Lights_n:
        type: switch
        label: Shop Area Lights
        config:
          stateTopic: zwave2/Shop_Lights/switch_binary/endpoint_0/currentValue
          commandTopic: zwave2/Shop_Lights/switch_binary/endpoint_0/targetValue/set
          transformationPattern:
            - JSONPATH:$.value
          "on": "true"
          "off": "false"

```

but I have explorer data for reference

 ![haconvert2 2026-08-12 135139](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/6/a64ceb2aefe474d061937724436c5f0a854032e1.png)

---

<div class="post-metadata">

**Author:** ![Homer-Sim](https://community.openhab.org/user_avatar/community.openhab.org/homer-sim/32/18374_2.png) [@Homer-Sim](https://community.openhab.org/u/Homer-Sim)\
**Post date:** [August 13, 2026, 1:45pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/32 "2026-08-13T13:45:19Z")

</div>

I found out that the normally not existing topic path is the right one for posting commands.

hm2mqtt is listening for such entries.  
The switches are now ok.  
But I have one where I can not find a way to work.  
This is the original channel config:  
```

```yaml
- "{\\"name\\":\\"Charging Mode\\",\\"state_topic\\":\\"hm2mqtt/HMJ-2/device/009b08a56a51/data\\",\\"value_template\\":\\"{% set mapping = {\\\\\\"chargeDischargeSimultaneously\\\\\\":\\\\\\"Simultaneous Charging/Discharging\\\\\\",\\\\\\"chargeThenDischarge\\\\\\":\\\\\\"Fully Charge Then Discharge\\\\\\"} %}{% set stringifiedValue = value_json.chargingMode | string %}{% if stringifiedValue in mapping %}{{ mapping\[stringifiedValue\] }}{% else %}{{ stringifiedValue }}{% endif %}\\",\\"command_template\\":\\"{% set mapping = {\\\\\\"Simultaneous Charging/Discharging\\\\\\":\\\\\\"chargeDischargeSimultaneously\\\\\\",\\\\\\"Fully Charge Then Discharge\\\\\\":\\\\\\"chargeThenDischarge\\\\\\"} %}{% set stringifiedValue = value | string %}{% if stringifiedValue in mapping %}{{ mapping\[stringifiedValue\] }}{% else %}{{ stringifiedValue }}{% endif %}\\",\\"command_topic\\":\\"hm2mqtt/HMJ-2/control/009b08a56a51/charging-mode\\",\\"options\\":\[\\"Simultaneous Charging/Discharging\\",\\"Fully Charge Then Discharge\\"\],\\"availability\\":\[{\\"topic\\":\\"hm2mqtt/availability\\",\\"payload_available\\":\\"online\\",\\"payload_not_available\\":\\"offline\\"},{\\"topic\\":\\"hm2mqtt/HMJ-2/availability/009b08a56a51\\",\\"payload_available\\":\\"online\\",\\"payload_not_available\\":\\"offline\\"}\],\\"unique_id\\":\\"009b08a56a51_charging_mode\\",\\"device\\":{\\"ids\\":\[\\"hame_energy_009b08a56a51\\"\],\\"name\\":\\"HAME Energy HMJ-2 009b08a56a51\\",\\"model_id\\":\\"HMJ-2\\",\\"manufacturer\\":\\"HAME Energy\\",\\"sw_version\\":\\"116.6\\",\\"connections\\":\[\[\\"bluetooth\\",\\"00:9B:08:A5:6A:51\\"\]\]},\\"origin\\":{\\"name\\":\\"hm2mqtt\\",\\"url\\":\\"https://github.com/tomquist/hm2mqtt\\"}}"

```

```  
And this is what I tried in channel config  
```

```yaml
MARSTEK_Speicher_C_MQTT_HMJ2_009b08a56a51_Charging_Mode: type: string label: MARSTEK Speicher C HMJ2 009b08a56a51 Charging Mode description: "" config: stateTopic: hm2mqtt/HMJ-2/device/009b08a56a51/data commandTopic: hm2mqtt/HMJ-2/control/009b08a56a51/charging-mode transformationPattern: - JSONPATH:$.chargingMode retained: false postCommand: false commandTransformation: - "SCRIPT:javascript:|- var value = input; if (value == 'Simultaneous Charging/Discharging') { value = 'chargeDischargeSimultaneously'; } else if (value == 'Fully Charge Then Discharge') { value = 'chargeThenDischarge'; } value;"

```

```

Any Idea for this one?

I already adaptet the item:

```

```yaml
metadata:
stateDescription:
value: ""
config:
options: "chargeDischargeSimultaneously=Simultaneous Charging/Discharging,chargeThenDischarge=Fully Charge Then Discharge"

```

```

Edit:  
I struggle hard with this code editing text …

---

<div class="post-metadata">

**Author:** ![apella12](https://community.openhab.org/user_avatar/community.openhab.org/apella12/32/117154_2.png) [@apella12](https://community.openhab.org/u/apella12)\
**Post date:** [August 13, 2026, 5:21pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/33 "2026-08-13T17:21:21Z")

</div>

I had AI reverse engineer your config, maybe this will help.

```json
{
  "name": "Charging Mode",
  "state_topic": "hm2mqtt/HMJ-2/device/009b08a56a51/data",
  "value_template": "{% set mapping = {\"chargeDischargeSimultaneously\":\"Simultaneous Charging/Discharging\",\"chargeThenDischarge\":\"Fully Charge Then Discharge\"} %}{% set stringifiedValue = value_json.chargingMode | string %}{% if stringifiedValue in mapping %}{{ mapping[stringifiedValue] }}{% else %}{{ stringifiedValue }}{% endif %}",
  "command_template": "{% set mapping = {\"Simultaneous Charging/Discharging\":\"chargeDischargeSimultaneously\",\"Fully Charge Then Discharge\":\"chargeThenDischarge\"} %}{% set stringifiedValue = value | string %}{% if stringifiedValue in mapping %}{{ mapping[stringifiedValue] }}{% else %}{{ stringifiedValue }}{% endif %}",
  "command_topic": "hm2mqtt/HMJ-2/control/009b08a56a51/charging-mode",
  "options": [
    "Simultaneous Charging/Discharging",
    "Fully Charge Then Discharge"
  ],
  "availability": [
    {
      "topic": "hm2mqtt/availability",
      "payload_available": "online",
      "payload_not_available": "offline"
    },
    {
      "topic": "hm2mqtt/HMJ-2/availability/009b08a56a51",
      "payload_available": "online",
      "payload_not_available": "offline"
    }
  ],
  "unique_id": "009b08a56a51_charging_mode",
  "device": {
    "ids": ["hame_energy_009b08a56a51"],
    "name": "HAME Energy HMJ-2 009b08a56a51",
    "model_id": "HMJ-2",
    "manufacturer": "HAME Energy",
    "sw_version": "116.6",
    "connections": [
      ["bluetooth", "00:9B:08:A5:6A:51"]
    ]
  },
  "origin": {
    "name": "hm2mqtt",
    "url": "https://github.com/tomquist/hm2mqtt"
  }
}

```

> [@Homer-Sim](#):
>
> I struggle hard with this code editing text …

I did caution that generic MQTT is a little more complex. 😉

---

<div class="post-metadata">

**Author:** ![Homer-Sim](https://community.openhab.org/user_avatar/community.openhab.org/homer-sim/32/18374_2.png) [@Homer-Sim](https://community.openhab.org/u/Homer-Sim)\
**Post date:** [August 17, 2026, 1:19pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/34 "2026-08-17T13:19:40Z")

</div>

I had success even if the reverse example did not work.

Fun fact: after changing one thing to the mqtt generic thing all others seem to work too.

No issues since some days.

Interessting is this:  
All items with informations from the relevant thing are working fine but the gui shows this

![grafik](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/2/b/2bea3fc23316c1c49477f798943c685e632357ed.png)

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [August 17, 2026, 2:10pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/35 "2026-08-17T14:10:52Z")

</div>

You have to configure the Generic MQTT thing’s availability settings.

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/1/a1ede5e0edab640257b984e4d6d0463aef88a15c.png)

---

<div class="post-metadata">

**Author:** ![Homer-Sim](https://community.openhab.org/user_avatar/community.openhab.org/homer-sim/32/18374_2.png) [@Homer-Sim](https://community.openhab.org/u/Homer-Sim)\
**Post date:** [August 17, 2026, 7:18pm UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/36 "2026-08-17T19:18:53Z")

</div>

Thanks, that’s it

---

<div class="post-metadata">

**Author:** ![system](https://community-openhab-org.s3-eu-central-1.amazonaws.com/original/2X/6/6a52f2ac5d00e4c7b50471a354b3a9221188be90.png) [@system](https://community.openhab.org/u/system)\
**Post date:** [September 28, 2026, 11:19am UTC](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872/37 "2026-09-28T11:19:19Z")

</div>

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.

[Previous page](https://community.openhab.org/t/homeassistant-mqtt-discovery-losing-channels/169872.md?page=1)
