Channels miissing from textual definition

Hi together,

now I started to install a now server from textual definition (before UI based).
I tried to start with a small thing file but it doesn’t work properly.

Bridge mqtt:broker:mqtt-broker "MQTT Mosquitto Local" [ certificatepin=false, clientID="openHAB", host="192.168.0.*", hostnameValidated=true, keepAlive=60,
lwtQos=0, lwtRetain=true, publickeypin=false, qos=1, reconnectTime=60000, secure=true, birthRetain=true, shutdownRetain=true, username="user", password="pass", protocol="TCP", port=8883, mqttVersion="V5", enableDiscovery=true
] {
  Thing topic switch5_thing "Switch5: Deko" @ "Wohnzimmer" [ availabilityTopic="tele/haus/switch5/LWT", payloadAvailable="Online", payloadNotAvailable="Offline" ] {
    Channels:
      State Switch : PowerSwitch "PowerSwitch" [ commandTopic="cmnd/haus/switch5/POWER", off="OFF", on="ON", stateTopic="stat/haus/switch5/POWER" ]
  }
openhab.log:
2025-05-05 11:58:36.921 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'switch-deko.things'
2025-05-05 11:58:37.019 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.0.12' with clientid openHAB
2025-05-05 11:58:37.059 [WARN ] [rnal.handler.GenericMQTTThingHandler] - Channel PowerSwitch has no type
Code from thing in UI:
UID: mqtt:topic:mqtt-broker:switch5_thing
label: "Switch5: Deko"
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/haus/switch5/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:mqtt-broker
location: Wohnzimmer
channels:
  - id: PowerSwitch
    label: PowerSwitch
    configuration:
      commandTopic: cmnd/haus/switch5/POWER
      stateTopic: stat/haus/switch5/POWER
      off: OFF
      on: ON

Problem:
A thing is created but not with the associated channels, regardless of whether there are multiple channels or one. The UI for the created thing doesn’t contain any channels, and a manual link from item to this thing doesn’t work either. See the error in the previous log. I have no idea how to define this channel type. Is it a bug? It ist according the manuals but not ok?

Try replacing “State Switch : PowerSwitch” by “Type Switch : PowerSwitch”.

In case you are using OH 5.0 milestone 2, this code can now be generated for you by using “Copy DSL Definition” feature of Main UI.

it doesn’ work as well, no thing added:

“Try replacing “State Switch : PowerSwitch” by “Type Switch : PowerSwitch”.”

[WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'switch-deko.things' has errors, therefore ignoring it: [36,12]: mismatched input 'Switch' expecting RULE_ID

I am not at all familiar with MQTT binding but looking at other examples, it looks like channel type is not Switch but switch. So try again with

Thing topic switch5_thing "Switch5: Deko" @ "Wohnzimmer" [ availabilityTopic="tele/haus/switch5/LWT", payloadAvailable="Online", payloadNotAvailable="Offline" ] {
    Channels:
      Type switch : PowerSwitch "PowerSwitch" [ commandTopic="cmnd/haus/switch5/POWER", off="OFF", on="ON", stateTopic="stat/haus/switch5/POWER" ]
  }

You can search on forum, you will find many examples.

I think your Equipment is “Tasmota-flashed”. Here a textual Thing from my SetUp.

Thing mqtt:topic:danny:sp11101 "Gosund SP111 01"  (mqtt:broker:danny )     @ "MQTT2" [
         availabilityTopic="tele/gosundsp111_01/LWT",
         payloadNotAvailable="Offline",
         payloadAvailable= "Online"
      ] {
    Channels:
        Type switch : power     "Power "                 [ stateTopic="stat/gosundsp111_01/POWER", commandTopic="cmnd/gosundsp111_01/POWER" ]
        Type number : rssi      "WiFi Signal Strength"   [ stateTopic="tele/gosundsp111_01/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : version   "Firmware Version    "   [ stateTopic="stat/gosundsp111_01/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
        Type switch : reachable "Reachable"              [ stateTopic="tele/gosundsp111_01/LWT", on="Online", off="Offline"]
        Type string : hardware  "Chip Set            "   [ stateTopic="stat/gosundsp111_01/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Hardware"]
        Type string : ipaddress "IP Address          "   [ stateTopic="stat/gosundsp111_01/STATUS5", transformationPattern="JSONPATH:$.StatusNET.IPAddress"]
        Type number : powerload "Power load"             [ stateTopic="tele/gosundsp111_01/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : voltage   "Line voltage"           [ stateTopic="tele/gosundsp111_01/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]
        Type number : current   "Line current"           [ stateTopic="tele/gosundsp111_01/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]
        Type number : total     "Total energy "          [ stateTopic="tele/gosundsp111_01/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]
        Type number : totalday  "Total energy today"     [ stateTopic="tele/gosundsp111_01/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]
        Type number : totalyest "Total energy yesterday" [ stateTopic="tele/gosundsp111_01/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]
        Type string : ssid      "WiFi"                   [ stateTopic="tele/gosundsp111_01/STATE", transformationPattern="JSONPATH:$.Wifi.SSId"]
        Type datetime : time    "Time"                   [ stateTopic="tele/gosundsp111_01/STATE", transformationPattern="JSONPATH:$.Time"]
        Type string : grouptop  "Group Topic"            [ stateTopic="stat/gosundsp111_01/STATUS1", transformationPattern="JSONPATH:$.StatusPRM.GroupTopic"]
    }

The first line looks a bit different than yours, as I use a separate Bridge-file, but the channels are tested and are working.
Hope this can help you.
Cheers - Peter

Thanks a lot, yes it was the “Switch” with capital letter!
But it only works with “Type switch : …” , then I get the channel. :slight_smile: