How to make HA switch follow status of ZigBee/MQTT sensor

I have an office light controlled by a zigbee switch that connects to MQTT through a tasmotized sonoff hub. A sensor card on the dashboard tracks the status as expected with the following in my configuration.yaml file:

mqtt:
  sensor:
    - name: "Office_Light_Status"
      unique_id: "Office Light Status"
      state_topic: "tele/develop/SENSOR"
      value_template: '{{ value_json["ZbReceived"]["0x73C1"]["Power"] }}'

To control the switch I have:

switch:
    - name: "Office_Light"
      command_topic: "cmnd/develop/zbsend"
      qos: 1
      payload_on: '{"Device":"0x73C1","send":{"Power":"1"}}'
      payload_off: '{"Device":"0x73C1","send":{"Power":"0"}}'
      retain: false

The HA switch also works just fine to control the light. However when I change the light status from another home control system while the HA sensor updates as expected the HA switch does not reflect the light’s new status. I have researched this on the net for two days and have not made any progress. It seems like this should be simple to solve but I have run out of ideas. Does anyone have any suggestions? Thank You.

Just wondering why do you split this up into a MQTT sensor and a switch? A switch should be enough:

switch:
    - name: "Office_Light"
      unique_id: "Office Light"
      state_topic: "tele/develop/SENSOR"
      value_template: '{{ value_json["ZbReceived"]["0x73C1"]["Power"] }}'
      command_topic: "cmnd/develop/zbsend"
      payload_on: '{"Device":"0x73C1","send":{"Power":"1"}}'
      payload_off: '{"Device":"0x73C1","send":{"Power":"0"}}'
      retain: false

If you need an additional sensor then create a template sensor based on the switch status.

Thank you for the suggestion.

This causes the switch card to show “Unknown” permanently. Clicking on it causes the switch to turn off (if it was on) and further clicking makes no changes.

It seems not to be obvious what the problem is. I suggest to use MQTT Explorer to see which messages are exchanged and when. Also turn on debug logging for MQTT in HA and check the logs for any errors/issues. Are you using the HA Mosquitto add-on or something else?

Figured out one way to do it. I created an automation that looked for a change in the status message and then called turn on/off on the switch with the appropriate state. Now my icons can stay in sync with switches that may be set outside of HA.