Just to keep others informed, ntending to migrate from FHEM to Home Assistant: I foung a solution without touching any code.
Probably “around one more corner” than neccessary, but very smple and working.
I struggled hard with dozens of posts in the FHEM forum setting up a MQTT connection. And it is not just the connection. “Publish”, “retain”, “attributes”… a lot of reading and n the end, just by chance I found the easy way. Only wth Home Assistant integrations, no HA add ons required, no coding required on any side… . So it can run with FHEM on the same raspberry (or whatever hardware you are using).
Short explanation: FHEM === Homebridge === Home Assistant
And… f you want use Apple Homekit, run the Homekit integration in HA.
I had a Homebridge installation on my raspberry (running also with FHEM and Home Assistant at the same time). Homebridge s very easy to install and… it has a FEHM plugin with a simple click configuration!
Homebridge: Homebridge installation
To use the GUI of homebridge, you will have to install the GUI extra:
Homebridge UI-X GUI installation
In the Hoembridge GUI go to “Plugins” and search for FHEM and choose the FHEM plugin.
Name “FHEM”, server “localhost” (if on the same machine), FHEM port 8083, Filter: suggested by the plugin is “siriName=.+”, then only devces with a sri name are imported; leave this feld empty and ALL FHEM devices will be imported in one go! If you have a special user and password for the FHEM web interface, then enter this (I had nothing). Press “Save” and restart Homebridge servce at the on/off button in the upper right corner. Click at “Devices” and you should see all yout FHEM devices coming up on the GUI. Click on “Homebridge” upper left corner and you will see a barcode. Note that code xxx-xx-xxx. You will need in Home Assistant. Now you are done with Homebridge.
In Home Assistant goto “Settings” lower left corner. Choose "devices and “services”, click “Integrations” at the top and choose “HomeKit”. Add your HomeBridge data here (IP, code…), You will be asked, which devices shall be shown: excludes nothing. In the last windows enable both switches to activate new found devices. This should find ALL Homebridge devices, resp. all FHEM devices.
n the end, I had in Home Assistant one integraton with “Home Bridge” and two entries with one service each and one “Homekit Devce” with multiple devces (alle FHEM devices). In "messages at the lower left corner, you’ll find a bar code which you can use to publish ALL devices in Home Assistant to your Apple “Home” app (“add device” and scan the code). You’re done.
This might not be the "cleanest way of bringing your FHEM devices to Home Assistant, but it needed nothing on the FHEM side, no coding in HomeAssistant and in Homebridge you will have to copy and paste a pieces to a config.json file and you are done.
What is being imported and how does t work?
Alle FHEM devices are now in HomeAssistant with their full funcionality, also dimmers, switches, thermostats (I use MAX) as I could see up now. Everything can be operated no matter, ig in FHEM, Homebridge, Home Assistant or in Apple Home - it works.
One issue wth FS20 devices (whch has nothing to do this “dirty way of integraton”):
Very often, I use one button toggle switches with FS20, which means, that with a 4-button switch, I can control 4 seperate lamps, including on/off/dimming up/dimming down. This works wth the “toggle” command in FS20. As FS20 is a one-directional system and not bi-directional, nor the switch or the (blind) remote operator knows, what state the device has. Toggling changes from on to off without feedback. “Lost” commands lead to a wrong indication in FHEM, Homebridge, Home Assistant anmd Apple Home. So these devices should not be used remotely, but only when you are present. In FHEM, you can use the “set” command to definitely put the device in a definite conditon instead of toggling it. f would change this in the device in FHEM, t would work all other platforms correctly, but I would loose the dimming capablty then.