Fan Dimmer and Fan Switch control

I have a strange situation.
I have a fan switch with dimmer where the fan can be turned on/ off using switch and dimmer.

The dimmer gives like below mqtt state when the fan is ON using dimmer
DIMMER= {“POWER2”:“ON”,“Dimmer”:100}
And similarly the switch gives below mqtt state when the fan is ON using switch
POWER2= ON

But the problem is, if I turn on using the dimmer, the switch state still remains OFF, i.e.
POWER2= OFF.
Similarly, if I turn on fan using switch, the dimmer state still remains OFF, i.e.
DIMMER= {“POWER2”:“OFF”,“Dimmer”:0}

So, this two kind of events are not synchronizing. Also, the mqtt state output from the dimmer is multiple output (one is POWER2 and one is Dimmer). That’s why I cannot simply create a rule and say DIMMER state= POWER2 state or vice versa.

I would be grateful if anyone can help me. I am very new in openhab3 and only have primary knowledge.

Below is the code of the channels

UID: mqtt:topic:ba88762650:e55b6400d5
label: Study room
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/STUDYROOM/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:ba88762650
channels:
  - id: Fandimmer
    channelTypeUID: mqtt:dimmer
    label: FanDimmer
    description: ""
    configuration:
      commandTopic: cmnd/STUDYROOM/DIMMER
      stateTopic: stat/STUDYROOM/DIMMER
      transformationPattern: JSONPATH:$.Dimmer
  - id: Fan1
    channelTypeUID: mqtt:switch
    label: Fan1
    description: ""
    configuration:
      commandTopic: cmnd/STUDYROOM/POWER2
      stateTopic: stat/STUDYROOM/POWER2
      off: Off
      on: On

Maybe use only the dimmer channel and link the switch item also to the dimmer channel instead to the separate power channel.

1 Like

You could also put a rule in tasmota to report state

How do I do it please?

Thanks. Could you please give an example or guidance?

You can link multiple items to the same channel:

Go to your thing, select the dimmer channel, link a new item, select switch as item type

Thanks. I can now put two items under one channel.

But in my case the MQTT topic for the dimmer and the switch are different.
For Dimmer the state and command are stat/FANCONTROL/DIMMER and cmnd/FANCONTROL/DIMMER
and for Switch the state and command are stat/FANCONTROL/POWER2 and cmnd/FANCONTROL/POWER2

So is it possible to control two different items of MQTT command under one channel? Or can I send multiple MQTT from one channel?

Forget the power topic and only work with the dimmer topic.

If a switch item in oh is linked to a dimmer channel (representing the dimmer mqtt topic), than oh should automatically convert the on/off commands of the switch to 0/100% dimming