Tertiush / ParadoxIP150v2

Python-based IP150 'middle-ware' that uses the IP module's software port for monitoring and control of the alarm via an MQTT Broker.
Eclipse Public License 1.0
73 stars 35 forks source link

Add support for MQTT auth in config.ini #15

Open AngelosF opened 7 years ago

AngelosF commented 7 years ago

If possible, add in the [MQTT Broker] section, a Username and Password config parameters. I got it to work by modifying manually:

lib/client.py (and hard-coding in self._username & self._password)

and

lib/publish.py (and hard-coding in): def single(topic, payload=None, qos=0, retain=False, hostname="localhost", port=1883, client_id="", keepalive=60, will=None, auth= {'username':"user_name", 'password':"pass_word"}, tls=None, protocol=mqtt.MQTTv31):

FigJam23 commented 7 years ago

I am getting this on my raspberry pi running mosquito Connected to MQTT broker with result 5 Connected to MQTT broker with result 5 Connected to MQTT broker with result 5

but yet would work on my Ubuntu setup
I am now thinking its because of MQTT user name and Password as well

yusufk commented 7 years ago

How about:

# -------------- MQTT ----------------
        elif State_Machine == 1:

            try:

                if speciallogging:
                    logging.info("State machine 1: starting client again")

                logging.info("State01:Attempting connection to MQTT Broker: " + MQTT_IP + ":" + str(MQTT_Port))
                client = mqtt.Client()
                client.on_connect = on_connect
                client.on_message = on_message
>>>>>>>>>
                client.username_pw_set(MQTT_User, MQTT_Password)
<<<<<<<<<
                client.connect(MQTT_IP, MQTT_Port,  MQTT_KeepAlive)