Can I add to/edit that information in the CODE section of the openHAB UI so that it includes the required dimmer information for MQTT submission for Home Assistant?
If so will it be wiped out when I ADD CHANNELS to the THING in the openHAB UI?
You will need to create a separate Channel for the Dimmer topics.
Note: using the same topic for command and state almost always leads to infinite loops, especially when coupled with postCommand enabled. When you send a command to the Item, it publishes a message to the commandTopic. It receives that message on the stateTopic, commands the Item which causes it to publish again ad infinitum. -
OH doesnât ever publish to the stateTopic. It only subscribes to the stateTopic. The stateTopic is how something else (HA) sends information to openHAB.
When OH receives a message on the stateTopic, it updates (or commands if postCommand is true) the Item with that new state.
When an OH Item receives a command, it will publish that to the commandTopic. The commandTopic is how OH sends information to something else (HA).
Who âownsâ the topics? Presumably itâs HA. Whatâs a command and whatâs a state depends on who âownsâ the topics. If you want to command HA to do something, you use the cmd topic. When HA has done something, it will post the new state to the state topic.
Therefore OH needs to publish (i.e. commandTopic) to the cmd topic and needs to subscribe (i.e. stateTopic) to the state topic.
What matter is what dictates that oh3/dimmer/my_dimmer/cmd_bright is the command topic? If itâs OH, then yes OH owns the topic. An in that case, OH needs to subscribe to the cmd topic and publish to the state topic. The cmd topic is where messages coming from outside OH come and the state topic is where OH publishes changes to the Item.
However, keep in mind that the binding will only publish commands so you might need a rule to translate changes to commands.
I have multiple 4 relays boards running Tasmota configured to connect to my local MQTT broker. My HomeAssistant instance uses Tasmota Integration to manage (ON/OFF) these relays.
On my OH3.3/3.4 instance have created 4 Channels shown in the attached Yaml file. Iâm able to manage these relays from both OH and HA.
UID: mqtt:topic:nacBroker:nacRC01
label: nacRC01 - Generic MQTT Thing
thingTypeUID: mqtt:topic
configuration:
payloadNotAvailable: offline
payloadAvailable: online
bridgeUID: mqtt:broker:nacBroker
location: System
channels:
- id: Relay1
channelTypeUID: mqtt:switch
label: Relay1
description: ""
configuration:
commandTopic: cmnd/nacRC01/Relay1/POWER1
stateTopic: stat/nacRC01/POWER1
off: OFF
on: ON
- id: Relay2
channelTypeUID: mqtt:switch
label: Relay2
description: ""
configuration:
commandTopic: cmnd/nacRC01/Relay2/POWER2
stateTopic: stat/nacRC01/POWER2
off: OFF
on: ON
- id: Relay3
channelTypeUID: mqtt:switch
label: Relay3
description: ""
configuration:
commandTopic: cmnd/nacRC01/Relay3/POWER3
stateTopic: stat/nacRC01/POWER3
off: OFF
on: ON
- id: Relay4
channelTypeUID: mqtt:switch
label: Relay4
description: ""
configuration:
commandTopic: cmnd/nacRC01/Relay4/POWER4
stateTopic: stat/nacRC01/POWER4
off: OFF
on: ON
Regarding the Dimmer Channel - id: my_dimmer commandTopic is there a way publish ON if the dimmer value is greater than zero and OFF if the dimmer value is zero rather than a number?
HA is looking for ON / OFF as well as the brightness level.
Viewed the device in OH and HA they had the correct values but changing the dimmer levels in their UI(s) did not change the values of state or state_bright within mosquitto or each others UI.
Chart out each and every data flow. That becomes your recipie for how to configure everything. Once you have all the messages and data flows mapped out itâs just a matter of configuring HA and OH to publish/subscribe each data flow. You can address them one by one until you have them all.