ChristianKuehnel / plantgateway

Bluetooth to mqtt gateway for Xiaomi Mi plant sensors
Apache License 2.0
276 stars 41 forks source link

could not read datawith reason: [Errno 111] Connection refused RPI 3 #36

Closed murmelbahn closed 5 years ago

murmelbahn commented 5 years ago

Hi,

I try to get this working on a raspberry pi 3. When i run plantgateway I get the following error:

could not read data from 11:22:33:44:55:66 (bla) with reason: [Errno 111] Connection refused

At first i was thinking it is a permission error but when i run it as root i got the same error. Im using the correct bluetooth device and the mac adress is also fine. Can you give me a hint?

Edit: Here is the debug log:

Tue, 06 Aug 2019 08:50:12 INFO PlantGateway version 0.6.2 Tue, 06 Aug 2019 08:50:12 INFO loaded config file from /root/.plantgw.yaml Tue, 06 Aug 2019 08:50:12 INFO Getting data from sensor siling Tue, 06 Aug 2019 08:50:12 ERROR could not read data from C4:7C:8D:6A:02:E6 (siling) with reason: [Errno 111] Connection refused Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 263, in process_all self.process_mac(sensor) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 240, in process_mac self.announce_sensor(sensor_config) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 286, in announce_sensor self.start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 183, in start_client self._start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 205, in _start_client self.mqtt_client.connect(self.config.mqtt_server, self.config.mqtt_port, 60) File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused Tue, 06 Aug 2019 08:50:12 INFO try 1 of 6: could not process sensor(s) siling. Waiting 1 sec for next try Tue, 06 Aug 2019 08:50:13 INFO Getting data from sensor siling Tue, 06 Aug 2019 08:50:13 ERROR could not read data from C4:7C:8D:6A:02:E6 (siling) with reason: [Errno 111] Connection refused Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 263, in process_all self.process_mac(sensor) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 240, in process_mac self.announce_sensor(sensor_config) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 286, in announce_sensor self.start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 183, in start_client self._start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 205, in _start_client self.mqtt_client.connect(self.config.mqtt_server, self.config.mqtt_port, 60) File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused Tue, 06 Aug 2019 08:50:13 INFO try 2 of 6: could not process sensor(s) siling. Waiting 2 sec for next try Tue, 06 Aug 2019 08:50:15 INFO Getting data from sensor siling Tue, 06 Aug 2019 08:50:15 ERROR could not read data from C4:7C:8D:6A:02:E6 (siling) with reason: [Errno 111] Connection refused Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 263, in process_all self.process_mac(sensor) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 240, in process_mac self.announce_sensor(sensor_config) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 286, in announce_sensor self.start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 183, in start_client self._start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 205, in _start_client self.mqtt_client.connect(self.config.mqtt_server, self.config.mqtt_port, 60) File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused Tue, 06 Aug 2019 08:50:15 INFO try 3 of 6: could not process sensor(s) siling. Waiting 4 sec for next try Tue, 06 Aug 2019 08:50:19 INFO Getting data from sensor siling Tue, 06 Aug 2019 08:50:19 ERROR could not read data from C4:7C:8D:6A:02:E6 (siling) with reason: [Errno 111] Connection refused Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 263, in process_all self.process_mac(sensor) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 240, in process_mac self.announce_sensor(sensor_config) File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 286, in announce_sensor self.start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 183, in start_client self._start_client() File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 205, in _start_client self.mqtt_client.connect(self.config.mqtt_server, self.config.mqtt_port, 60) File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 839, in connect return self.reconnect() File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 962, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused Tue, 06 Aug 2019 08:50:19 INFO try 4 of 6: could not process sensor(s) siling. Waiting 8 sec for next try

ChristianKuehnel commented 5 years ago

Is some other process using the Bluetooth dongle? Does it work, if you move the Miflora sensor closer to Bluetooth dongle? You can try setting the logging to debug, maybe this will give a hint on what's going on.

Am Di., 6. Aug. 2019 um 08:48 Uhr schrieb murmelbahn < notifications@github.com>:

Hi,

I try to get this working on a raspberry pi 3. When i run plantgateway I get the following error:

could not read data from 11:22:33:44:55:66 (bla) with reason: [Errno 111] Connection refused

At first i was thinking it is a permission error but when i run it as root i got the same error. Im using the correct bluetooth device and the mac adress is also fine. Can you give me a hint?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChristianKuehnel/plantgateway/issues/36?email_source=notifications&email_token=AEYJMCDQHHUWUSCF75JXJZLQDENCXA5CNFSM4IJTBRY2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HDRP7OA, or mute the thread https://github.com/notifications/unsubscribe-auth/AEYJMCG3NRZ7I4BS3VGZWTLQDENCXANCNFSM4IJTBRYQ .

murmelbahn commented 5 years ago

Hi Christian,

I‘ve attached a debug log. I‘ve commented out the debug entry hopefully it is now a debug log.

I don‘t think another process is using the bluetooth device, I can run a scan without issues. The Pi is a fresh install, the only things I installed are the one from the readme.

ChristianKuehnel commented 5 years ago

The error is coming from the MQTT library, not from the Bluetooth library. So can you check, if the address/username/password for the MQTT server are correct?

Am Di., 6. Aug. 2019 um 10:20 Uhr schrieb murmelbahn < notifications@github.com>:

Hi Christian,

I‘ve attached a debug log. I‘ve commented out the debug entry hopefully it is now a debug log.

I don‘t think another process is using the bluetooth device, I can run a scan without issues. The Pi is a fresh install, the only things I installed are the one from the readme.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChristianKuehnel/plantgateway/issues/36?email_source=notifications&email_token=AEYJMCCZGF6FMWZJBJGNIDDQDEX6BA5CNFSM4IJTBRY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3UKROA#issuecomment-518564024, or mute the thread https://github.com/notifications/unsubscribe-auth/AEYJMCCHA47BMMVEHL32MLTQDEX6BANCNFSM4IJTBRYQ .

murmelbahn commented 5 years ago

You was right. I have to change the port to 1883 instead of 8883. Hass.io was using this port. Thanks for your help.