teslamate-org/teslamate

Geofences inside one another

Open

#1,135 opened on Dec 22, 2020

View on GitHub
 (4 comments) (1 reaction) (0 assignees)Elixir (932 forks)batch import
Hacktoberfestarea:teslamatekind:bugnote:needs investigation

Repository metrics

Stars
 (7,981 stars)
PR merge metrics
 (Avg merge 5d 19h) (41 merged PRs in 30d)

Description

Describe the bug

I intentionally have two geofences, one inside the other (not concentric) but teslamate sometimes seems to publish the wrong one to mqtt.

Expected behavior

The expected behaviour should publish the same result as this query for latitude and longitude yyy and xxx:

SELECT name FROM geofences ORDER BY earth_distance(ll_to_earth(yyy,xxx), ll_to_earth(latitude, longitude)) ASC LIMIT 1; How to reproduce it (as minimally and precisely as possible):

  1. Drive in to geofence1 area
  2. MQTT publishes geofence=geofence1
  3. Drive to smaller geofence2 area inside geofence1 area
  4. MQTT continues to publish geofence=geofence1

Relevant entries from the logs

teslamate_1   | 01:55:22.681 car_id=1 [info] Start / :online
teslamate_1   | 01:55:22.697 car_id=1 [info] Connecting ...
teslamate_1   | 01:55:22.698 car_id=1 [info] Driving / Start
teslamate_1   | 01:55:38.040 car_id=1 [info] Fetch already in progress ...
teslamate_1   | 01:55:42.237 car_id=1 [info] Driving / Ended / 0 km – 0 min
teslamate_1   | 01:55:42.237 car_id=1 [info] Start / :online
teslamate_1   | 01:55:44.792 car_id=1 [info] Driving / Start
teslamate_1   | 02:05:59.344 [info] GET /
teslamate_1   | 02:05:59.360 [info] Sent 200 in 15ms
teslamate_1   | 02:05:59.732 [info] GET /apple-touch-icon-120x120-precomposed.png
teslamate_1   | 02:05:59.733 [info] Sent 404 in 686µs
teslamate_1   | 02:05:59.742 [info] GET /apple-touch-icon-120x120.png
teslamate_1   | 02:05:59.743 [info] Sent 404 in 748µs
teslamate_1   | 02:09:25.332 car_id=1 [info] Driving / Ended / 5 km – 14 min
teslamate_1   | 02:09:25.332 car_id=1 [info] Start / :online
teslamate_1   | 02:13:07.310 car_id=1 [info] Suspending logging
teslamate_1   | 02:14:30.845 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:14:41.892 [info] Connection was closed (a:1|t:2|d:1). Reconnecting …
teslamate_1   | 02:15:19.111 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:19:37.606 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:20:18.640 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:24:45.567 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:24:56.574 [info] Connection was closed (a:1|t:2|d:1). Reconnecting …
teslamate_1   | 02:37:07.386 [info] GET /
teslamate_1   | 02:37:07.401 [info] Sent 200 in 15ms
teslamate_1   | 02:37:10.804 [info] GET /geo-fences
teslamate_1   | 02:37:10.823 [info] Sent 200 in 18ms
teslamate_1   | 02:37:16.730 [info] GET /geo-fences/9/edit
teslamate_1   | 02:37:16.739 [info] Sent 200 in 8ms
teslamate_1   | 02:37:35.587 [info] GET /geo-fences
teslamate_1   | 02:37:35.596 [info] Sent 200 in 8ms
teslamate_1   | 02:39:51.081 car_id=1 [info] Driving / Start
teslamate_1   | 02:39:55.103 car_id=1 [info] Fetch already in progress ...
teslamate_1   | 02:39:55.605 car_id=1 [info] Fetch already in progress ...
teslamate_1   | 02:39:55.851 car_id=1 [info] Fetch already in progress ...
teslamate_1   | 02:39:59.372 car_id=1 [info] Driving / Ended / 0 km – 0 min
teslamate_1   | 02:39:59.372 car_id=1 [info] Start / :online
teslamate_1   | 02:43:22.230 car_id=1 [info] Suspending logging
teslamate_1   | 02:54:37.386 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:54:48.360 [info] Connection was closed (a:1|t:2|d:1). Reconnecting …
teslamate_1   | 02:55:28.872 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:59:36.861 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 02:59:47.837 [info] Connection was closed (a:1|t:2|d:1). Reconnecting …
teslamate_1   | 03:00:28.892 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 03:04:37.424 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …
teslamate_1   | 03:04:48.422 [info] Connection was closed (a:1|t:2|d:1). Reconnecting …
teslamate_1   | 03:04:49.205 [info] control:hello – 0
teslamate_1   | 03:05:28.919 [info] Connection was closed (a:1|t:1|d:1). Reconnecting …

Screenshots

Data

teslamate=#
SELECT name
FROM geofences
ORDER BY earth_distance(ll_to_earth(yyy,xxx), ll_to_earth(latitude, longitude))
ASC LIMIT 1;

     name     
--------------
 Home Outside
(1 row)

root@pi4:~# mosquitto_sub -t '#' -v | ts | grep tesla
Dec 22 13:47:15 teslamate/cars/1/latitude yyy
Dec 22 13:47:15 teslamate/cars/1/longitude xxx
Dec 22 13:47:15 teslamate/cars/1/geofence Home

note that "Home Outside" is within "Home"

Environment

  • TeslaMate version: 1.20.1
  • Type of installation: Docker
  • OS TeslaMate is installed on: Linux pi4 5.4.79-v7l+ #1373 SMP Mon Nov 23 13:27:40 GMT 2020 armv7l GNU/Linux
  • User OS & Browser: MacOS Safari
  • Others:

Contributor guide