FHEM Forum

FHEM => English Corner => Thema gestartet von: andreafno am 12 Mai 2019, 10:23:50

Titel: New MQTT module
Beitrag von: andreafno am 12 Mai 2019, 10:23:50
Hi,
could somebody help me with MQTT module? In the past it worked correctly using this simple configuration:

#set zehnder device
define ZL ComfoAir /dev/ttyUSB1@9600 30
attr ZL event-min-interval .*:60
#set mqtt
define mq MQTT server:port user password
define mq_ZL MQTT_BRIDGE ZL
attr mq_ZL publishReading_Temp_EWT /user/ext_temperature


How can I make this work with the new MQTT2 module?

Thank you!
Andrea
Titel: Antw:New MQTT module
Beitrag von: rudolfkoenig am 12 Mai 2019, 10:43:22
There are some alternatives:
- use MQTT_GENERIC_BRIDGE, this is compatible with MQTT2 (MQTT_BRIDGE is not).
- use a notify, which will call "set mqtt2_client publish XX YY" or "set mqtt2_server publish XX YY"
- define an additional MQTT2_DEVICE with a setList, and set this device via notify.

In each of these cases you need an MQTT2_CLIENT or an MQTT2_SERVER
Titel: Antw:New MQTT module
Beitrag von: andreafno am 12 Mai 2019, 11:06:14
Hi rudolfkoenig,
thank you! Where can I find documentation in english to understand how to rewrite the cfg in the correct way? In fhem commandref I can see MQTT_GENERIC_BRIDGE under "Device modules" but clicking it nothing happens.

Thanks again
Titel: Antw:New MQTT module
Beitrag von: rudolfkoenig am 12 Mai 2019, 11:09:42
Both
https://fhem.de/commandref.html#MQTT_GENERIC_BRIDGE
and
https://fhem.de/commandref_modular.html#MQTT_GENERIC_BRIDGE
is working for me.
Titel: Antw:New MQTT module
Beitrag von: andreafno am 12 Mai 2019, 11:32:01
Ok, sorry.. local html commandref only doesn't work for me.
Titel: Antw:New MQTT module
Beitrag von: rudolfkoenig am 12 Mai 2019, 11:36:02
Define one, go to its FHEMWEB details page, and click on "Device specific help" in the bottom right corner.
Titel: Antw:New MQTT module
Beitrag von: andreafno am 12 Mai 2019, 12:06:08
I defined mqtt2, then I set the password with "set" directly in fhemweb

define mq MQTT2_CLIENT mqtt.dioty.co:1883
attr mq username myusername


If I execute in fhemweb the command:
defmod mqttGeneric MQTT_GENERIC_BRIDGE mqtt ZL

I receive "Cannot load module MQTT_GENERIC_BRIDGE"

Should I install something?
Titel: Antw:New MQTT module
Beitrag von: rudolfkoenig am 12 Mai 2019, 12:45:14
Probably. Did you checked the FHEM log?
Note: I am not the maintainer of this module.
Personally I would use notify (as I know _that_ module), but there are at least 120 FHEM installations using MQTT_GENERIC_BRIDGE according to our statistics, so it ought to work.
Titel: Antw:New MQTT module
Beitrag von: andreafno am 12 Mai 2019, 13:36:16
Wow, you know it better than any other  :)

Could you please make me an example using notify to publish a reading of my ZL device, now that I set MQTT2_CLIENT?

#1) set zehnder device
define ZL ComfoAir /dev/ttyUSB1@9600 30
attr ZL event-min-interval .*:60
#2) define mqtt2 client
define mq MQTT2_CLIENT mqtt.dioty.co:1883
attr mq username myusername
#3) automatic publishing ZL reading using "notify" (previously "attr mq_ZL publishReading_Temp_EWT /user/ext_temperature")
???


ps. sorry for my english; in the log file nothing appears after the "Cannot load module MQTT_GENERIC_BRIDGE" message
Titel: Antw:New MQTT module
Beitrag von: rudolfkoenig am 12 Mai 2019, 13:51:47
I would try something like:define ZL_notify notify ZL:Temp_EWT.* set mq publish /user/ext_temperature $EVTPART1Since I dont know the MQTT module, nor MQTT_BRIDGE, my example may be wrong.
I would start the Event Monitor in FHEMWEB, wait for the right event from ZL, mark the line and press "Create/modify device".
Titel: Antw:New MQTT module
Beitrag von: andreafno am 12 Mai 2019, 14:34:28
Thank you! The notify works, I see in the event monitor. I can't see the messages on the broker, but this is a different problem.

Thank so much for your help!

Have a good Sunday