I would also recommend using MAIN UI to configure.
you can set up the retain per channel of a thing.
After you do a couple of channels using this form look at the code tab and you can copy paste similar items. However you can’t change the channel channelTypeUID:
just delete the wrong one and create a new one.
So this is the way you can do it in a thing file OH2 or OH3
Bridge mqtt:broker:myMQTTBroker [ host ="192.168.1.148", secure =false, clientID ="myMQTTClient" ]
{
Thing topic Kettle "Kettle in Kitchen" @ "Kitchen" [ availabilityTopic ="tele/kettle/LWT", payloadAvailable ="Online", payloadNotAvailable ="Offline"] {
Channels:
Type switch : PowerSwitch [ stateTopic ="stat/kettle/POWER", commandTopic ="cmnd/kettle/POWER", on="ON", off="OFF"]
Type string : WarmMode [ commandTopic ="cmnd/kettle/TuyaSend4"]
Type number : temperature "Temperature [%.0f °C]" [ stateTopic ="tele/kettle/TUYARECEIVED", transformationPattern ="REGEX:(.*DpId\":5.*)∩JSONPATH:$.TuyaReceived.DpIdData∩JS:HEXtoDEC.js" ]
}
}
Note the transformationPattern above is different in example because I doing it a different way below and no warm mode.
This is from the Code tab section of OH3 Geriatric Thing
UID: mqtt:topic:myMQTTBroker:Kettle
label: Kettle
thingTypeUID: mqtt:topic
configuration:
payloadNotAvailable: Offline
availabilityTopic: tele/Kettle/LWT
payloadAvailable: Online
bridgeUID: mqtt:broker:myMQTTBroker
location: Kitchen
channels:
- id: Switch
channelTypeUID: mqtt:switch
label: Boil the Kettle
description: ""
configuration:
commandTopic: cmnd/Kettle/POWER
stateTopic: stat/Kettle/POWER
off: OFF
on: ON
- id: Temperature
channelTypeUID: mqtt:number
label: Kettle Temperature
description: ""
configuration:
stateTopic: stat/Kettle/TEMPERATURE
unit: °C
This happens when you get something wrong.
Sorry @Confectrician you awesome VSCode Extention is not being used as much by me to do things and items anymore (just test things and items) However rules and transformations still 100% VSC
Now after setting up the model with all the locations of your house you can create equipment from thing. This will create all the Items you want. Use the weather binding to do it and it even has an advanced mode.
It checks to make sure the item name is unique however this is one way once its created you can’t edit it like this.
So my recommendation is to Try it with another instance of openHAB you can use the same MQTT Broker and control it exactly the same. Then what I am doing is moving it a section at a time.
Don’t forget do a backup of your current system.