Its actually not that complicated particularly if you have lots of switches / sensors.
If all you want is the switches, put mqtt discovery on the HA you want the switches on.
Where the actually switches are, put statestream on and these automations. It will populate all the switches. (you can amend for lights) . The first automation makes the config topic in mqtt so mqtt discovery and auto create them. The second automation will actually control the switches by looking the set topic and actuating the switch.
automation mqtt_config_entity_creator_switch:
alias: mqtt_config_entity_creator_switch
trigger:
- platform: mqtt
topic: 'homeassistant/switch/#'
condition:
condition: template
value_template: "{{ trigger.topic.split('/')[3] == 'state' }}"
action:
- service: mqtt.publish
data_template:
topic: "homeassistant/switch/{{ trigger.topic.split('/')[2] }}/config"
payload: "{\"name\": \"{{ trigger.topic.split('/')[2]| replace('_', ' ') | title }}\", \"device_class\": \"{{ trigger.payload }}\", \"pl_off\":\"off\", \"pl_on\":\"on\", \"command_topic\": \"homeassistant/switch/{{ trigger.topic.split('/')[2] }}/set\" }"
retain: true
automation mqtt_command_switch:
alias: mqtt_command_switch
trigger:
- platform: mqtt
topic: 'homeassistant/switch/#'
condition:
condition: template
value_template: "{{ trigger.topic.split('/')[3] == 'set' }}"
action:
- service_template: 'switch.turn_{{trigger.payload | lower }}'
data_template:
entity_id: switch.{{ trigger.topic.split('/')[2] }}