MQTT: UID segment xxxxx contains invalid characters

Good afternoon (o;

As I moved away from HA I reflashed my esphome devices to use mqtt, which work fine most of the time…

Oddly now when I reflashed a device to get rid of some unused sensors openHAB refuses to add the discovered MQTT device with:

UID segment 'ESPsensorco#ESPsensorco#sensor' contains invalid characters

though this sensor is marked in the esphome device as “internal”:

text_sensor:
  - platform: mqtt_subscribe
    id: co2
    internal: true

Any clues what is going on here?

Also from time to time MQTT esphome devices get offline…though they are still connected to mosquitto…

thanks in advance
richard

Try without #.

If this is auto-discovered, then it is a bug, as @splatch already said: the # is not a valid character in an UID and reserved for special use (channel groups).

I don’t see anything to try without # as I just click on the discovered MQTT device to add as a thing…

This is the whole log when adding this device:

2023-04-09 11:40:13.863 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPsensorntc_5Ftemperature#sensor', because channel type 'mqtt:ESPsensorntc_5Ftemperature_sensor' could not be found.

2023-04-09 11:40:13.865 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPsensorsonoff_5Fnspanel_5F_2D_5Fntc_5Fresistance#sensor', because channel type 'mqtt:ESPsensorsonoff_5Fnspanel_5F_2D_5Fntc_5Fresistance_sensor' could not be found.

2023-04-09 11:40:13.866 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPswitchsonoff_5Fnspanel_5F_2D_5Fbuzzer#switch', because channel type 'mqtt:ESPswitchsonoff_5Fnspanel_5F_2D_5Fbuzzer_switch' could not be found.

2023-04-09 11:40:13.867 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'c049effa6c24_2Dwifisignal#sensor', because channel type 'mqtt:c049effa6c24_2Dwifisignal_sensor' could not be found.

2023-04-09 11:40:13.868 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F1#sensor', because channel type 'mqtt:ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F1_sensor' could not be found.

2023-04-09 11:40:13.869 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPswitchstufe_5F1#switch', because channel type 'mqtt:ESPswitchstufe_5F1_switch' could not be found.

2023-04-09 11:40:13.870 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F2#sensor', because channel type 'mqtt:ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F2_sensor' could not be found.

2023-04-09 11:40:13.871 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPswitchstufe_5F2#switch', because channel type 'mqtt:ESPswitchstufe_5F2_switch' could not be found.

2023-04-09 11:40:13.872 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPsensorwerkstatt_5Fco2#sensor', because channel type 'mqtt:ESPsensorwerkstatt_5Fco2_sensor' could not be found.

2023-04-09 11:40:13.874 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'c049effa6c24_2Dwifiinfo_2Dbssid#sensor', because channel type 'mqtt:c049effa6c24_2Dwifiinfo_2Dbssid_sensor' could not be found.

2023-04-09 11:40:13.875 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPsensorco2#sensor', because channel type 'mqtt:ESPsensorco2_sensor' could not be found.

2023-04-09 11:40:13.876 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPswitchsonoff_5Fnspanel_5F_2D_5Frelay_5F1#switch', because channel type 'mqtt:ESPswitchsonoff_5Fnspanel_5F_2D_5Frelay_5F1_switch' could not be found.

2023-04-09 11:40:13.877 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPbinary_5Fsensorsonoff_5Fnspanel_5Fswitch_5F2#sensor', because channel type 'mqtt:ESPbinary_5Fsensorsonoff_5Fnspanel_5Fswitch_5F2_sensor' could not be found.

2023-04-09 11:40:13.879 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'c049effa6c24_2Dwifiinfo_2Dip#sensor', because channel type 'mqtt:c049effa6c24_2Dwifiinfo_2Dip_sensor' could not be found.

2023-04-09 11:40:13.880 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPbinary_5Fsensorsonoff_5Fnspanel_5Fswitch_5F1#sensor', because channel type 'mqtt:ESPbinary_5Fsensorsonoff_5Fnspanel_5Fswitch_5F1_sensor' could not be found.

2023-04-09 11:40:13.881 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPswitchsonoff_5Fnspanel_5F_2D_5Frelay_5F2#switch', because channel type 'mqtt:ESPswitchsonoff_5Fnspanel_5F_2D_5Frelay_5F2_switch' could not be found.

2023-04-09 11:40:13.882 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPswitchbuzzer#switch', because channel type 'mqtt:ESPswitchbuzzer_switch' could not be found.

2023-04-09 11:40:13.884 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPsensorwerkstatt_5Fco#sensor', because channel type 'mqtt:ESPsensorwerkstatt_5Fco_sensor' could not be found.

2023-04-09 11:40:13.885 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'c049effa6c24_2Dversion#sensor', because channel type 'mqtt:c049effa6c24_2Dversion_sensor' could not be found.

2023-04-09 11:40:13.886 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPsensorntc_5Fresistance#sensor', because channel type 'mqtt:ESPsensorntc_5Fresistance_sensor' could not be found.

2023-04-09 11:40:13.888 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'c049effa6c24_2Dwifiinfo_2Dssid#sensor', because channel type 'mqtt:c049effa6c24_2Dwifiinfo_2Dssid_sensor' could not be found.

2023-04-09 11:40:13.889 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPswitchsonoff_5Fnspanel_5F_2D_5Fdisplay#switch', because channel type 'mqtt:ESPswitchsonoff_5Fnspanel_5F_2D_5Fdisplay_switch' could not be found.

2023-04-09 11:40:13.890 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channel 'ESPsensorsonoff_5Fnspanel_5F_2D_5Fntc_5Ftemperature#sensor', because channel type 'mqtt:ESPsensorsonoff_5Fnspanel_5F_2D_5Fntc_5Ftemperature_sensor' could not be found.

2023-04-09 11:40:13.891 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPsensorntc_5Ftemperature' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPsensorntc_5Ftemperature' could not be found.

2023-04-09 11:40:13.891 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPsensorsonoff_5Fnspanel_5F_2D_5Fntc_5Fresistance' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPsensorsonoff_5Fnspanel_5F_2D_5Fntc_5Fresistance' could not be found.

2023-04-09 11:40:13.892 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPswitchsonoff_5Fnspanel_5F_2D_5Fbuzzer' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPswitchsonoff_5Fnspanel_5F_2D_5Fbuzzer' could not be found.

2023-04-09 11:40:13.893 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'c049effa6c24_2Dwifisignal' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:c049effa6c24_2Dwifisignal' could not be found.

2023-04-09 11:40:13.893 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F1' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F1' could not be found.

2023-04-09 11:40:13.894 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPswitchstufe_5F1' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPswitchstufe_5F1' could not be found.

2023-04-09 11:40:13.895 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F2' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPbinary_5Fsensorlueftung_5Fkeller_5Fswitch_5F2' could not be found.

2023-04-09 11:40:13.895 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPswitchstufe_5F2' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPswitchstufe_5F2' could not be found.

2023-04-09 11:40:13.896 [WARN ] [re.thing.internal.ThingFactoryHelper] - Could not create channels for channel group 'ESPsensorwerkstatt_5Fco2' for thing type 'mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24', because channel group type 'mqtt:ESPsensorwerkstatt_5Fco2' could not be found.

2023-04-09 11:40:13.897 [ERROR] [ore.internal.discovery.InboxResource] - Thing mqtt:homeassistant_c049effa6c24:ce6fa68254:c049effa6c24 unable to be approved: UID segment 'ESPsensorco#ESPsensorco#sensor' contains invalid characters. The last segment of the channel UID must match the pattern '[\w-]*|[\w-]*#[\w-]*'.

Somehow openHAB or mosquitto keep track of previous used sensors for this device which don’t exist anymore…

Some early bindings in 2.x line attempted to use channel UID instead of channel type to determine what kind of channel it is. I’ve made this mistake while implementing first version of bacnet v2 binding, could it be that mqtt binding is same? AFAIR it was introduced in OH 2.4-2.5 which didn’t have some of restrictions in place?