MQTT to Home assistant

Begonnen von RobinC, 03 November 2026, 20:58:10

Vorheriges Thema - Nächstes Thema

RobinC

Hi,

I have FHEM running the MAX! radiator valves in my house. I recently set up an Opentherm Gateway to my boiler. I connected it to Home Assistant as it seemed easier. I would now like to connect the valves to Home assistant via MQTT.

I found this on Github: https://github.com/danielrheinbay/fhemMAX2HASS it seems to be exactly what I need.Unfortunately I can't get it running.

This is the client:
defmod mqtt MQTT2_CLIENT <192.168.1.203>:1883
attr mqtt lwt homeassistant/binary_sensor/fhem/availability offline
attr mqtt lwtRetain 1
attr mqtt msgAfterConnect -r homeassistant/binary_sensor/fhem/availability online
attr mqtt msgBeforeDisconnect -r homeassistant/binary_sensor/fhem/availability offline

setstate mqtt disconnected
setstate mqtt 2026-11-03 19:45:08 lastPublish homeassistant/binary_sensor/MAX.Kitchen/0f5c7f-panel/config:{"availability":[{"payload_available":"online","payload_not_available":"offline","topic":"homeassistant/binary_sensor/fhem/availability"},{"payload_available":"alive","payload_not_available":"dead","topic":"homeassistant/MAX.Kitchen/Activity"}],"availability_mode":"all","default_entity_id":"MAX-HeatingThermostatPlus-0f5c7f-panel","device":{"configuration_url":"http://192.168.1.134:8083/fhem?detail=MAX.Kitchen","identifiers":["0f5c7f"],"manufacturer":"eQ-3","model":"MAX! Radiator Thermostat Plus","name":"MAX.Kitchen","suggested_area":"MAX","sw_version":"1.0"},"device_class":"lock","entity_category":"diagnostic","payload_off":"locked","payload_on":"unlocked","state_topic":"homeassistant/MAX.Kitchen/panel","unique_id":"MAX-HeatingThermostatPlus-0f5c7f-panel"}
setstate mqtt 2026-11-03 19:46:07 state disconnected

I have tried to use MQTT explorer but it does not see anything if I point it at the FHEM installation.

I know that the MQTT broker is working on Home Assistant as it is receiving data from the OTGW.

One thing I have not done is to SAVE CONFIG, I revert to the old config with shutdown restart when I give up trying to make it work.

Can anyone help me work out what I have got wrong?

Thanks,

Robin

Beta-User

Zitat von: RobinC am 03 November 2026, 20:58:10Can anyone help me work out what I have got wrong?
There are quite a few options to get this to work. Imo the "cleanest" way ist to use MQTT_GENERIC_BRIDGE (MGB), see especially https://wiki.fhem.de/wiki/MQTT_GENERIC_BRIDGE.

There are some attrTemplate to support the entire process, you may want to start with "base_settings_MQTT_GENERIC_BRIDGE" in the version "ATTRTVERSION_MGB_only".

There may also exist a template to set appropriate Attributes to the thermostats itself.

If needed, I could try to explain more in detail these days. Hope this helps as a starting point.

(btw: I don't use HomeAssistant, so for the yaml part, you might need additional help.)
Server: HP-elitedesk@Debian 13, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: ZigBee2mqtt, MiLight@ESP-GW, BT@OpenMQTTGw | ZWave | SIGNALduino | MapleCUN | RHASSPY
svn: u.a Weekday-&RandomTimer, Twilight,  div. attrTemplate-files, MySensors

RobinC

Thanks for the response. The solution I'm working from uses the client, the generic bridge and some code

Configure a connection to your MQTT broker using the MQTT2_CLIENT module:

define mqtt MQTT2_CLIENT <mymqttbroker.local>:1883
attr mqtt lwt homeassistant/binary_sensor/fhem/availability offline
attr mqtt lwtRetain 1
attr mqtt msgAfterConnect -r homeassistant/binary_sensor/fhem/availability online
attr mqtt msgBeforeDisconnect -r homeassistant/binary_sensor/fhem/availability offline

Note: If you configure more than one MQTT2_CLIENT device, specify which one to use in 99_myUtils.pm#L56.
Configure an MQTT Generic Bridge:

define mqttGenericBridge MQTT_GENERIC_BRIDGE
attr mqttGenericBridge IODev mqtt
attr mqttGenericBridge globalDefaults base="homeassistant" qos=2 retain=1
attr mqttGenericBridge stateFormat dev: device-count in: incoming-count out: outgoing-count

Add a trigger to call MAX2HASSdiscovery using the DOIF module:

define hass.MAXdiscovery DOIF ([":Activity",""]) ({MAX2HASSdiscovery("$DEVICE")})
attr hass.MAXdiscovery do always

Others have got this to work. My problem is I can't even see how to start troubleshhoting. In the Client it seems I have an MQTT message prepared:
homeassistant/binary_sensor/MAX.Kitchen/0f5c7f-panel/config:{"availability":[{"payload_available":"online","payload_not_available":"offline","topic":"homeassistant/binary_sensor/fhem/availability"},{"payload_available":"alive","payload_not_available":"dead","topic":"homeassistant/MAX.Kitchen/Activity"}],"availability_mode":"all","default_entity_id":"MAX-HeatingThermostatPlus-0f5c7f-panel","device":{"configuration_url":"http://192.168.1.134:8083/fhem?detail=MAX.Kitchen","identifiers":["0f5c7f"],"manufacturer":"eQ-3","model":"MAX! Radiator Thermostat Plus","name":"MAX.Kitchen","suggested_area":"MAX","sw_version":"1.0"},"device_class":"lock","entity_category":"diagnostic","payload_off":"locked","payload_on":"unlocked","state_topic":"homeassistant/MAX.Kitchen/panel","unique_id":"MAX-HeatingThermostatPlus-0f5c7f-panel"}

But it is not being received at Home Assistant. I tried to use MQTT explorer to listen to what is going on but I get a message Econn refused when I try to connect to port 1883 on the FHEM address.

Beta-User

Some remarks in advance:

- use Code tags to (re-) format your posts. Makes them much easier to read ;) . The "Copy for Forum" function in fhemweb adds some usefull live data ;) .
- there are tons of different "solutions" out there. I'm not willing to dicuss all the pros and cons... Just follow the process descibed in the already linked wiki, unless you know to do better.

MQTT requires configuration on both ends, this brings endless possibilities to discuss...

Let' first check the IO:
define mqtt MQTT2_CLIENT <mymqttbroker.local>:1883Did you replace <mymqttbroker.local> by the IP or hostname of the Computer Homeassistant ist running?

Then you may just use an arbitrary "publish" command and check if that is visible in the tool you use (like MQTT Explorer).
Server: HP-elitedesk@Debian 13, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: ZigBee2mqtt, MiLight@ESP-GW, BT@OpenMQTTGw | ZWave | SIGNALduino | MapleCUN | RHASSPY
svn: u.a Weekday-&RandomTimer, Twilight,  div. attrTemplate-files, MySensors

RobinC

Thanks, I'll investigate using publish to see if anything is being sent.