mikestir / alarm-server

MQTT bridging server for Texecom Premier alarm systems
32 stars 10 forks source link

Error in MQQT due to newer version? #7

Open Tinbum1 opened 2 years ago

Tinbum1 commented 2 years ago

Looking on the internet it seems I may be getting this rror because of the version of MQQT being newer and I'm not sure how to get round it..

2022-10-17 11:05:52,777 ERROR Failed to open account file 2022-10-17 11:05:52,777 INFO Starting MQTT client for 127.0.0. 1:1883 2022-10-17 11:05:52,779 INFO Starting alarm server on 0.0.0.0: 10500 Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3 591, in _thread_main self.loop_forever(retry_first_connection=True) File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1 756, in loop_forever rc = self._loop(timeout) File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1 164, in _loop rc = self.loop_read() File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1 556, in loop_read rc = self._packet_read() File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 2 439, in _packet_read rc = self._packet_handle() File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3 039, in _packet_handle return self._handle_connack() File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3 139, in _handle_connack self, self._userdata, flags_dict, result) TypeError: on_mqtt_connect() takes 3 positional arguments but 4 were given

Tinbum1 commented 2 years ago

To answer my own question above I couldn't get this to work and found this. (I don't do much coding and am still learning but the following seems to work ok).

in alarmserver.conf

[mqtt] port = 8883 which I think should normally be 1883

In alarmrx.py change

`def on_mqtt_connect(client, userdata, rc): logger.info("MQTT connection established: %d" % (rc), extra={'tag': ''})

def on_mqtt_disconnect(client, userdata, rc): `

to

`def on_mqtt_connect(client, userdata, flags, rc): logger.info("MQTT connection established: %d" % (rc), extra={'tag': ''})

def on_mqtt_disconnect(client, userdata, flags, rc):

`