brchri / tesla-geogdo

A lightweight app that will operate your smart garage door openers (GDOs) based on the location of a defined tracker, automatically closing when you leave, and opening when you return. Supports multiple vehicles, trackers, geofence types, and smart GDO devices.
GNU General Public License v3.0
17 stars 2 forks source link

Setting up project #23

Closed natrlhy closed 3 months ago

natrlhy commented 4 months ago

So my Raspberry Pi SD card decided to fail on me and I kept notes on how to setup this project. I had saved off my working config.yml file after I initially got it all working. However when I start it up I get this error:

tesla-geogdo | 07/08/2024 15:00:10 [ ] No trackers found for garage door #0! Please ensure proper spacing in the config file tesla-geogdo exited with code 0

My docker compose file:

services:
  tesla-geogdo:
    image: brchri/tesla-geogdo:latest
    container_name: tesla-geogdo
    user: 1000:1000 # optional, sets user to run in container; must have read access to mounted config volume (+ write if using token caching)
    environment:
      - TZ=America/Los_Angeles # optional, sets timezone for container
    volumes:
      - ./:/app/config # required, mounts folder containing config file(s) into container
    restart: unless-stopped

I have the teslamate-mosquitto-1 1883 port exposed as well. My config.yml file sits in the same directory as the docker compose file.

natrlhy commented 4 months ago

So I saw the newer options of running the wizard and I did. It created a new config.yml file and I get this error now:

tesla-geogdo | 07/08/2024 16:01:32 [ INF ] Config loaded successfully tesla-geogdo | 07/08/2024 16:01:32 [ ] could not connect to mqtt broker: network Error : dial tcp [::1]:1883: connect: connection refused

My config.yml file looks like this for the mqtt broker:

global:
  tracker_mqtt_settings:
    connection:
      host: localhost
      port: 1883
      user: ""
      pass: ""

My teslamate container is running on the same physical system and is functioning fine.

natrlhy commented 4 months ago

So I just edited the config.yml file and change the host from localhost to the IP address of my server and it looks like it's running!

tesla-geogdo  | 07/08/2024 16:28:42 [ INF ] Config loaded successfully
tesla-geogdo  | 07/08/2024 16:28:42 [ INF ] Connected to Teslamate MQTT broker
tesla-geogdo  | 07/08/2024 16:28:42 [ INF ] Subscribing to MQTT topics for tracker 1
tesla-geogdo  | 07/08/2024 16:28:43 [ INF ] Topics subscribed, listening for events...

I forget how to test without driving around :)

brchri commented 4 months ago

Glad you got it sorted, it sounds like you were probably using an older version on your old rpie, so your config wasn't compatible with the latest version that you downloaded on your new hardware. In regards to the wizard, it should've told you that if you're running the app in a container, you shouldn't use localhost for the MQTT broker, as each container has its own networking stack, so localhost is local to the geogdo container, but not your MQTT broker even if it's on the same host, as that would be running in a separate container with its own separate localhost.

For testing, you can set DEBUG=true and TESTING=true environment variables in your docker compose service declaration for this container. Then you can use a tool like MQTT Explorer to connect to your broker and push test coordinates to the relevant topics and observe the logs for the geogdo container.

Hope that helps!

natrlhy commented 4 months ago

Thanks, I read some prior threads and saw you mentioned the MQTT Explorer tool. I didn't try it yet but the car will be used tomorrow.

I got a little hung up when the wizard asked about "topics" to use. I saw a config example in the README.md and just copied those.

I was also reading up on the Teslamate Docs and noticed that the topics:

teslamate/cars/$car_id/latitude teslamate/cars/$car_id/longitude

are deprecated and the teslamate/cars/$car_id/location topic should be used (has both as a json blob).

Has this been tested with your project?

brchri commented 3 months ago

Yes, both the old (deprecated) topics and the new topic is fully supported, you just need to use a complex topic instead of simple topics (the config wizard asks which you want to use). Then for the json key for latitude and longitude, you just enter latitude and longitude respectively. The end result should look something like this:

    trackers:
      - id: 1
        complex_topic:
          topic: teslamate/cars/1/location
          lat_json_key: latitude
          lng_json_key: longitude
natrlhy commented 3 months ago

Thanks @brchri. I've got a fully working new config now and it's working great!