phev-remote / phev-ttgo

13 stars 2 forks source link

MQTT connection with password? #2

Closed yoakim82 closed 3 years ago

yoakim82 commented 3 years ago

Hi!

Thanks for the amazing work you all have done with this software, I'm really looking forward to getting this up and running to be able to eventually integrate my car into Homeassistant.

I've sucessfully configured the ttgo board with my Outlander Wifi SSID etc and it seems to connect. I'm using my own MQTT broker and I can see in the broker logs that something indeed is trying to connect, but fails to do so. This is no surprise, since I don't allow Anonymous access to the broker.

mosquitto log (repeated): 1612620799: New connection from 83.187.174.114 on port 1883. 1612620799: Socket error on client , disconnecting.

On the ttgo serial output: W (13733) MQTT_CLIENT: Connection refused, not authorized I (13733) MQTT: MQTT_EVENT_ERROR E (13733) MQTT_CLIENT: MQTT connect failed I (13733) MQTT: MQTT_EVENT_DISCONNECTED E (13743) MQTT_CLIENT: Client has started I (23743) MQTT: Other event id:7 W (25073) MQTT_CLIENT: Connection refused, not authorized ...

So, where/how can I configure correct credentials for the mqtt connection? I'd rather not leave my broker open for anyone to connect, especially since it is now exposed to connections outside my LAN.

Any help is appreciated, thanks

yoakim82 commented 3 years ago

The sollution was simpler than I realized at first, you simply append the credentials to the URI like so:

user:password@broker.address.com

Now I get messages with { "responses": [{ "updatedRegister": { "register": 192, "length": 13, "data": [48, 48, 53, 49, 48, 50, 49, 48, 48, 48, 17, 0, 0], "xor": 195 }, "time": "2021-02-06T15:35:16Z" }] }

Is there a way to interpret these messages from python?