PetHubLocal / pethublocal

Replacement for SurePetCare "Connect" cloud service connecting via MQTT to Home Assistant
MIT License
69 stars 9 forks source link

Unable to set remote mqtt username and password #14

Open iFloris opened 2 years ago

iFloris commented 2 years ago

Hello, thanks for building this great local alternative!

I am trying to get this working with the docker install version, as I already have Mosquitto broker running on my home assistant install with other MQTT tools.

However, I am having trouble getting pethublocal to talk to my Home Assistant Mosquitto broker. I do not know how to tell pethublocal to use a username and password for MQTT. As such, I am getting the following:

2022-09-08T06:52:23.901221299Z INFO:pethublocal:MQTT: Init MQTT Host 192.168.1.x
2022-09-08T06:52:23.902791369Z INFO:pethublocal:Error "[code:5] The connection was refused.". Reconnecting in 3 seconds.

I tried to edit the pethubconfig.json, inserting a username and password as a test (which I also added as a user in home assistant):

        "MQTT": {
            "Host": "192.168.1.x",
            "Username": "pethublocal",
            "Password": "pethublocal"
        },

But that does not seem to work.

How can I get pethublocal to use a username and password when connecting to a remote MQTT server?

En3myNightmare commented 1 year ago

You must use "ClientUsername" and "ClientPassword". This is how it is defined in Frontend.py.

fpschrisiom commented 10 months ago

Just to clarify for anyone, in your pethubconfig.json you set your MQTT user/pass that is in home assistant, like this:


        "MQTT": {
            "Host": "YOUR_HA_IP",
            "ClientUsername": "WHATEVER_MQTT_USER_YOU_HAVE_IN_HA",
            "ClientPassword": "WHATEVER_MQTT_PASS_YOU_HAVE_IN_HA"
        },