Closed m4dm4rtig4n closed 4 years ago
It seems like that your enocean interface is running well but the connection to the MQTT broker is not established. On successful connection you will get a log entry like this, which is not present in your log:
2018-10-30 23:55:35,113 INFO: Succesfully connected to MQTT broker.
I suggest testing the mqtt connection first, e.g. using the mosquitto
command line tool:
mosquitto_pub -h uri.domain.com -p 1883 -u xxxx -P xxxx -t 'enocean/temp_hum_cuisine/TMP' -m 20
Is this working?
Hi @romor ,
It's working.
I have install mosquitto client on docker :
# docker run --rm -it --device=/dev/ttyUSB0 -v /opt/docker/data/enocean:/config --entrypoint sh flopon/enocean-mqtt:latest
> apk --no-cache add mosquitto mosquitto-client
> mosquitto_pub -h URI.DOMAIN.FR -p 1883 -u XXXX -P XXXX -t 'enocean/temp_hum_cuisine/TMP' -m 20
For information I override entrypoint :
python /usr/local/bin/enoceanmqtt /config/enoceanmqtt.conf --debug
Ansible deployment configuration :
- docker_container:
name: "enocean"
image: flopon/enocean-mqtt:latest
state: started
restart: yes
restart_policy: unless-stopped
volumes:
- /opt/docker/data/enocean:/config
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
entrypoint:
- python
- /usr/local/bin/enoceanmqtt
- /config/enoceanmqtt.conf
- --debug
From your debug it looks like SSL is enabled. Try commenting out the line:
mqtt_ssl = false
in your configuration. The way the test is coded right now, if that option is present (irrespective of what the value is set to) then the client will try to connect via SSL, which does not appear to be desired in your case.
Same :/
2020-04-27 12:41:22,001 INFO: Authenticating: mqtt
2020-04-27 12:41:22,017 INFO: SerialCommunicator started
2020-04-27 12:41:22,017 WARNING: Replacing Packet.optional with default value.
2020-04-27 12:41:22,118 INFO: Sending packet
2020-04-27 12:41:22,118 DEBUG: 0x05 ['0x8'] [] OrderedDict()
2020-04-27 12:41:22,218 DEBUG: 0x02 ['0x0', '0xff', '0x8f', '0xdf', '0x80'] ['0xa'] OrderedDict()
2020-04-27 12:41:22,218 INFO: got response packet: OK
2020-04-27 12:41:42,965 DEBUG: 01:A4:97:51->FF:FF:FF:FF (-64 dBm): 0x01 ['0xa5', '0x0', '0x61', '0x8b', '0xa', '0x1', '0xa4', '0x97', '0x51', '0x0'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x40', '0x0'] OrderedDict()
2020-04-27 12:41:42,965 INFO: received: 01:A4:97:51->FF:FF:FF:FF (-64 dBm): 0x01 ['0xa5', '0x0', '0x61', '0x8b', '0xa', '0x1', '0xa4', '0x97', '0x51', '0x0'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x40', '0x0'] OrderedDict()
2020-04-27 12:41:42,966 DEBUG: enocean/temp_hum_cuisine: HUM (Rel. Humidity (linear))=38.800000000000004 %
2020-04-27 12:41:42,966 DEBUG: enocean/temp_hum_cuisine: TMP (Temperature (linear))=22.240000000000002 °C
2020-04-27 12:41:42,966 DEBUG: enocean/temp_hum_cuisine: TSN (Availability of the Temperature Sensor)=available
I have try with :
I never have :'(
INFO: Succesfully connected to MQTT broker.
Do you have the MQTT password surrounded by quotes? Try removing the quotes. I believe ConfigParser returns the value after the =
verbatim, including any quotes, which the client then tries to use as a password. You shouldn't need to use quotes even if the password has spaces in it, although I am not sure it will work if the password starts and/or ends with spaces.
I have try :
And it still doesn't work :(
I have zwave2mqtt config with the same configuration and it's work perfectly :(
It's strange that you also don't get the warning message that is printed if the MQTT server disconnects due to either bad protocol or bad password:
Unexpectedly disconnected from MQTT
The lack of that message would normally imply that the MQTT server is not responding to the connection requests due to a firewall and/or a network routing issue.
In order to get more insight into the problem, you could try enabling the Paho MQTT client level debugging. That might give you more clues as to why you MQTT client is not connecting. To enable client logging, add the following line to the installed copy of communicator.py
, immediately before line 56:
self.mqtt.enable_logger()
On my systems running Python 3.7 this file is installed at: /usr/local/lib/enoceanmqtt/lib/python3.7/site-packages/enoceanmqtt-0.1.0-py3.7.egg/enoceanmqtt/communicator.py
. I'm not familiar with the docker image you're using as I run it in a venv on my system.
Alternatively you could analyse a packet capture either at the client or the server end.
I have add line to /enoceanmqtt/communicator.py in docker and now i have :
2020-04-27 14:32:18,777 DEBUG: Connection failed, retrying
2020-04-27 14:32:22,781 DEBUG: Connection failed, retrying
2020-04-27 14:32:30,783 DEBUG: Connection failed, retrying
I can increase verbosity?
That's as much verbosity as you will get from the MQTT client. Either it could not resolve the broker name, or could not establish the TCP connection to the broker because the broker rejected the connection (there are only 4 and 8 seconds between connection attempts.) I think it gives you the unexpected disconnect message mentioned above rather than the retry message if you are trying to connect to the broker via SSL, but it is not configured for SSL (and vice versa).
Make sure that you have commented out the mqtt_ssl
line as you don't seem to be using SSL with zwave2mqtt, and that Enabling SSL doesn't appear in the logs.
Also check that MQTT and firewall ACLs are allowing connections.
You could also add another line just before the connect_async() line to dump the connection hostname and port to verify that the config is being read correctly:
logging.debug("Connecting to host " + self.conf['mqtt_host'] + ", port " + str(mqtt_port) + ", keepalive " + str(mqtt_keepalive))
Beyond that I can only suggest exec into the container and double checking that you can resolve the broker name via ping uri.domain.com
and that you can manually connect to the MQTT broker port via nc -vv uri.domain.com 1883
. Though, as you've already tested using the mosquitto client from within this container, this doesn't seem to be the problem. As a last resort, tcpdump -i eth0 host uri.domain.com and tcp port 1883
(assuming a relatively default docker setup and with relevant dependent packages installed) from within the container should show you at least whether any packets are leaving the container and heading towards the MQTT broker, and whether the broker (or firewall) is rejecting your connections.
Interesting, I noticed that setting the keepalive to 0, the value in enoceanmqtt.conf.sample
, doesn't work (anymore?). Can you try changing it to the Paho MQTT client default of 60?
Interesting, I noticed that setting the keepalive to 0, the value in
enoceanmqtt.conf.sample
, doesn't work (anymore?). Can you try changing it to the Paho MQTT client default of 60?
Umh, when i have set to keepalive at 60 => Succesfully connected to MQTT broker.
Thx for your helping ;)
It's work but now i'm regularly disconnect :/
2020-04-28 07:31:26,092 WARNING: Unexpectedly disconnected from MQTT broker: 1
2020-04-28 07:31:27,096 INFO: Succesfully connected to MQTT broker.
2020-04-28 07:31:42,103 WARNING: Unexpectedly disconnected from MQTT broker: 1
2020-04-28 07:31:43,106 INFO: Succesfully connected to MQTT broker.
2020-04-28 07:31:58,113 WARNING: Unexpectedly disconnected from MQTT broker: 1
2020-04-28 07:31:59,123 INFO: Succesfully connected to MQTT broker.
2020-04-28 07:32:14,130 WARNING: Unexpectedly disconnected from MQTT broker: 1
2020-04-28 07:32:15,133 INFO: Succesfully connected to MQTT broker.
Normal ?
No, not normal.
It disconnects after 15 seconds. Is this the keepalive
timeout you set?
I set keepalive to 60 and mosquitto have default conf (just add passwd file)
I'd suggest re-enabling MQTT client debugging and see what MQTT packets are being sent and received, now that you have established a TCP connection to the broker. (I intend to create a PR to enable this through either a command line switch or a config file option.)
BTW the keepalive=0 issue has been reported upstream at eclipse/paho.mqtt.python#473.
I have found, i have 2 client with same id :) And it is impossible to have 2 clients with the same id at the same time :)
Thx for your help :)
Hi,
I don't receive ny message in mqtt while I have a lot of data going back from my sensors.
Any idea why ?
Thx
Debug log :
My config :