Hauptmenü

FHEM MQTT

Begonnen von rajaehsan, 30 November 2018, 11:21:00

Vorheriges Thema - Nächstes Thema

rajaehsan

Hi Everyone,

I am new to FHEM and I need an urgent help. Is there anyway I can execute FHEM command through MQTT publish from other MQTT broker. Or is there any other way to handle this.

Thanks in advance.

Regards,
Rajaehsan

imranm

This module is a MQTT bridge, which simultaneously collects data from several FHEM devices and passes their readings via MQTT or set readings from the incoming MQTT messages or executes them as a 'set' command on the configured FHEM device.
An MQTT device is needed as IODev.

The (minimal) configuration of the bridge itself is basically very simple.

Definition:

In the simplest case, two lines are enough:

defmod mqttGeneric MQTT_GENERIC_BRIDGE [prefix] [devspec,[devspec]
attr mqttGeneric IODev

All parameters in the define are optional.

The first parameter is a prefix for the control attributes on which the devices to be monitored (see above) are configured. Default value is 'mqtt'. If this is e.g. redefined as 'hugo', the control attributes are named hugoPublish etc.

The second parameter ('devspec') allows to minimize the number of devices to be monitored (otherwise all devices will be monitored, which may cost performance). Example for devspec: 'TYPE=dummy' or 'dummy1,dummy2'. With comma separated list no spaces must be used!

Beta-User

Dear Rajaehsan,
welcome to the forum.
I'd recommend to have a look at the MQTT_GENERIC_BRIDGE module, together with either MQTT2_CLIENT or MQTT to do the general interfacing with your external broker.
There's also MQTT_BRIDGE already mentionned to have a look at, but afaik most likely, the combination MQTT_GENERIC_BRIDGE + MQTT2_CLIENT is the best and easier route to follow, despite both modules (and esp. MQTT2_CLIENT and the combination of both) beeing relatively new.
But both maintainers are very eager to get that solidely up and running :) .

Kind regards,
Beta-User
Server: HP-elitedesk@Debian 12, 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

rajaehsan

Hi Beta User,

Thank you for quick response.

I already checked the MQTT_GENERIC_BRIDGE but FHEM is not allowing me to use STOPIC topic to mqttSubscribe.

Acutally problem is that I want to execute FHEM GET AND SET command which will be published from other system using MQTT.

Regards,
Rajaehsan

Beta-User

I have to admitt having too little experience with MQTT_GENERIC_BRIDGE myself to be able to do very deep advising wrt that.

In general, I'd first rename your thread (or open a new one) to make clear you need advise wrt. MQTT_GENERIC_BRIDGE and to move to the MQTT sectioon of the forum.

afaik only readings will be subject of transmission between FHEM and the broker. So no direct commands are transmitted except the ones setting readings (including state) of a "listening device" to a new value (this can also be used to e.g. switch a lamp on or off or assign new temperature values or whatever). So the "get" commands (like CUL: "get <culname> ccconf" most likely need further preparation like having a seperate MQTT2_DEVICE or Dummy to be switched in combination with a notify listening on changes of that device which is finally issuing the corresponding FHEM command. As a result, some readings may be changed and then be transferred to the broker again by using "attr <dev> mqttPublish ..." on the <culname> device.

Hope this makes the picture a little more clear. Imo best start with some forwarding of device readings to the broker first, next do some switching on or off commands in direction to FHEM to get some first impressions on how the pieces work together.

Regards, Beta-User
Server: HP-elitedesk@Debian 12, 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

rajaehsan

thank you for your response.

Before posting here I already configured a specific device and checked how to on and off that specific device using MQTT_BRIDGE. The only thing left now is that i want to automate my application to automatically teach my system to get any new device added in system which required to execute FHEM command of GET and SET.

But thank you for your guidance.

Regards,
Rajaehsan

rudolfkoenig

ZitatI already checked the MQTT_GENERIC_BRIDGE but FHEM is not allowing me to use STOPIC topic to mqttSubscribe.
I do not understand exactly what you mean by this, but I think it is a configuration problem.

MQTT_GENERIC_BRIDGE is not a requirement, it is just one of the many possibilities to handle MQTT in FHEM.

A primitive method is to connect FHEM to the broker with MQTT2_CLIENT, set the rawEvents attribute to generate events, and use "set XX publish topic message" command to send messages.

A more advanced solution is to set the autocreate attribute for the MQTT2_CLIENT, which will create an MQTT2_DEVICE instance.
Events are created automatically and JSON data, if present, is parsed. To send events you have to specify a setList attribute.

You get even more automation by replacing the external MQTT server with the FHEM builtin MQTT2_SERVER and autocreate.

Btw.:
ZitatI am new to FHEM and I need an urgent help.
http://www.catb.org/~esr/faqs/smart-questions.html#urgent