hi,
I want to start FHEM-MQTT to be able to catch all message in nodered
i did this in FHEM
fhem> define MQfhem MQTT 192.168.0.6:1884
fhem> set MQfhem connect
When i list my MQfhem object it is always "Disconnected"
fhem> list MQfhem
Internals:
CFGFN
DEF 192.168.0.6:1884
DeviceName 192.168.0.6:1884
FUUID 5d0a2bd4-f33f-0be6-ab16-d0268acf8528ce0a
NAME MQfhem
NEXT_OPEN 1560948152
NOTIFYDEV global
NR 88
NTFY_ORDER 50-MQfhem
PARTIAL
STATE disconnected
TYPE MQTT
msgid 1
timeout 60
READINGS:
2019-06-19 14:41:32 state disconnected
messages:
Attributes:
Do you know why?
Thanks in advance
Sure about the port nr? e.g. mosquitto defaults to 1883.
If you are just about to start with MQTT and do not use much stuff yet, you may consider using MQTT2_SERVER. This way you'll not need any additional software like mosquitto nor additional Perl modules to get it up and running.
Also autocreate may help you to add new devices, and attrTemplate can be used to configure MQTT2_DEVICEs just in a few seconds (if it's a commonly used hardware with more or less default settings).
i used port 1884 because i have already domoticz-mqtt speaking on 1883
so you have 2 server instances of mosquitto running?
If there's just one server (fomer:broker), all of the clients have to use the same port.
i have already domoticz-mqtt on 1883
when i enter in FHEM : define MQTT MQTT2_Server localhost:1883
i catch port already in use
OK, that's a different story.
MQTT2_SERVER implements a Broker instance (similar to mosquittto), so you also have to use a different port for it (and the syntax is different also, se commandref!) .
Note: you'll _not need_ any MQTT device (TYPE=MQTT), MQTT2_SERVER acts as IO module itself.
If your data should be handled by mosquitto, try MQTT2_CLIENT as IO and have a look to the corresponding cref (should "listen" to the port mosquitto uses, most likely 1883).
Zitat von: Beta-User am 19 Juni 2019, 15:40:44
If your data should be handled by mosquitto, try MQTT2_CLIENT as IO and have a look to the corresponding cref (should "listen" to the port mosquitto uses, most likely 1883).
If your (non-FHEM-) system is configured as described here https://www.domoticz.com/wiki/MQTT, I'd recommend to do the following:
- define a MQTT2_CLIENT
define MQfhem MQTT2_CLIENT 192.168.0.6:1883
- switch autocreate (@MQfhem) on, set it to "simple"
- a new MQTT2_DEVICE will be created (could take some time), if a TYPE=autocreate device ist active (sth. like MQTT2_MQfhem).
- apply A_00_MQTT2_CLIENT_general_bridge to it:
set MQTT2_MQfhem attrTemplate A_00_MQTT2_CLIENT_general_bridge
Then post RAW definitions of all your mqtt2-devices that will be have been created after some minutes waiting periode or mosquitto restart (and especially the readingList of MQTT2_MQfhem), if you need further help.
hi
i followed your instructions but i not sure to have the good result
here with your configuration it seems that i received in fhem all messages coming from domoticz.
my goals is to have FHEM to send to nodered all informations regarding some FHEM changes
In fact, i want domoticz to send to nodered (it is working with port 1883)
now i want fhem to send to nodered too (same port with another topic)
like this i will be able to aggregate domoticz and fhem in one node red application
please advise
best regards
i did a little test
i did
FHEM> define MQTT2 MQTT2_SERVER 1884 192.168.0.6
now i can do a notification
FHEM> set MQTT2 publish fhem/fhem toto
i receive the msg in nodered
But how to inform all my sensors to send to MQTT2 ?
Thx
Either create a notify like
define f2m notify .* set MQTT2 publish $NAME $EVENT
or use the MQTT_GENERIC_BRIDGE module.
many thanks !!!!!
It is working now
Very good !!!!!
just one last question:
Now, if i want to do the reverse ?
sending a command from nodered to FHEM like : set Prise on
i receive in FHEM something like :
MQTT2_SERVER MQTT2 publish fhem/fhem MQTT2_mqtt_d8bf1a3b.fd4288 _: set Prise on
MQTT2_DEVICE MQTT2_mqtt_d8bf1a3b.fd4288 _: set Prise on
but the sensor do not activate and deactivate ?
best regards
You can set the rawEvents attribute in MQTT2_SERVER, and create matching notifies forsetting the desired device, the Event-Monitor is your friend here.
Or use MQTT_GENERIC_BRIDGE, which was created exactly for this purpose.
sorry again, it is not easy stuff
now i create :
defmod mqttGeneric MQTT_GENERIC_BRIDGE
it looks like this
fhem> list mqttGeneric
Internals:
CFGFN
FUUID 5d0b7f88-f33f-0be6-6c2b-efb7b66eed73a43d
IODev MQTT2
NAME mqttGeneric
NR 216
NTFY_ORDER 50-mqttGeneric
STATE ? ? ?
TYPE MQTT_GENERIC_BRIDGE
devspec .*
prefix mqtt
READINGS:
2019-06-20 15:03:39 device-count 1
2019-06-20 14:43:52 incoming-count 0
2019-06-20 14:43:52 outgoing-count 0
2019-06-20 15:03:39 transmission-state IO device initialized (mqtt2)
2019-06-20 14:43:52 updated-reading-count 0
2019-06-20 14:43:52 updated-set-count 0
devices:
TCM_ESP3_1:
:subscribe:
globalDeviceExcludes:
globalReadingExcludes:
globalTypeExcludes:
pub:
FHEMWEB *
Global *
MQTT transmission-state
MQTT_BRIDGE transmission-state
MQTT_DEVICE transmission-state
MQTT_GENERIC_BRIDGE *
telnet *
sub:
FHEMWEB *
Global *
MQTT transmission-state
MQTT_BRIDGE transmission-state
MQTT_DEVICE transmission-state
MQTT_GENERIC_BRIDGE *
telnet *
Attributes:
and now ?
So it was not your last question after all :)
I am not the MQTT_GENERIC_BRIDGE maintainer, nor am I using it.
A first look at the documentation (https://fhem.de/commandref_modular.html#MQTT_GENERIC_BRIDGE) reveals a lot of examples, which I suppose you did nor read yet.
If you still have questions after reading it, open a new forum-entry with MQTT_GENERIC_BRIDGE in the subject
(sorry, don't want to get involved in MQTT_GENERIC_BRIDGE discussion, as I'm also not familiar with that; just some remarks on topics prior to the use of it):
- Imo, you'd better use just one MQTT server deamon in your setup, not both MQTT2_SERVER _and_ mosquitto. So use MQTT2_CLIENT listening to port 1883 as IO for the communication between FHEM and mosquitto (as all other clients like nodered, domoticz-mqtt and whatever other devices (like ESP8266 with tasmota) you use)
But leave autocreate turned off, if you are just planing to "mqtt-ize" FHEM-devices!
- When using MQTT_GENERIC_BRIDGE, in general this MQTT_GENERIC_BRIDGE device just enables all other type of devices to "talk in mqtt", so better avoid additionally using other type of event handlers like notify to do the same (this ist possible and no general issue, but imo sticking with MQTT_GENERIC_BRIDGE will help you to understand how the MQTT_GENERIC_BRIDGE mechanism works).
Besinde the above, MQTT_GENERIC_BRIDGE just keeps some central settings like topic structures and so on.
All other configuration work regarding other FHEM devices is done in the new attributes at each of the FHEM devices you already defined prior to the MQTT_GENERIC_BRIDGE (or will define in the future).
(Please: in case of questions wrt. that, ask in the other thread you already opened)
Additionally: Please use code tagging for the future (the "#"-button above the smileys)