Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana shows "Datasource TeslaMate not found" and MQTT does not add device/entities (auto discovery) #63

Closed
hemy81 opened this issue Jan 18, 2025 · 8 comments

Comments

@hemy81
Copy link

hemy81 commented Jan 18, 2025

Image

Dear all,

I really appreciate this add-on. TeslaMate work great for me.
However I have a few issues with the Grafana and MQTT.

Settings:
Raspberry Pi 4
Core 2024.12.5
Supervisor 2024.12.3
Operating System 14.1
Frontend 20241127.8
PostGres addon: 15.7-14
Grafana add-on: 10.2.2
Teslama addon: 1.4.0

In Grafana I always see "No Data", although I can explore the PostGres15 database manually within Grafana. I can see the database and general data, such as Name, VID, VIN, Charges. Thus I think the connection between Postgres and Grafan is working, it must only be the dashboard, which does not show the data. Upon editing the dashboard, and clicking in "Run Query" I see the following error message:

db query error: pq: invalid input syntax for type json
or
db query error: pq: invalid input syntax for type smallint:

Does anybody know what this issue is?

For MQTT, I can read the topic in both HA and with a MQTTAnalyzer app, but neither entities nor a new device(s) are auto discovered?
I made a new teslamate user and also configured ACL as suggested.

Thanks for your help!

Hemy

@hemy81
Copy link
Author

hemy81 commented Jan 18, 2025

I found this here: teslamate-org/teslamate#3640
They said it's a database issue and refer upgrading to Postgres17, while home assistant has only Postgres15.

@lildude
Copy link
Owner

lildude commented Jan 20, 2025

First a disclaimer: this is all outside of the realm of this addon and is squarely in the upstream app's realm.

That said, I'm not convinced this is a database version issue. By their own admission in the v1.31.0 release notes, this is NOT a hard requirement:

Although TeslaMate currently runs fine with PostgreSQL 12+ we strongly recommend upgrading to the latest supported version.

Many users of this addon are still running on Postgres 15 without any issues. Certain dashboards are known to show no data when you first start using TeslaMate or when the car has been offline for an extended period of time and the default graph view range is only for a time during that offline period. Extending the range or waiting reveals the data.

My suspicion is either you don't have any or enough data to render the graphs (formatting an empty value will obviously fail) or the initial database migrations haven't run or encountered problems and I think the "upgrading to Postgres 17" resolves things because it forces the migrations, essentially resets things, and also forces someone to stop and wait.

If you restart the addon you should see something like this:

s6-rc: info: service legacy-services: starting
[09:18:31] INFO: Starting NGINX...
s6-rc: info: service legacy-services successfully started
[09:18:34] INFO: Checking for Grafana folder: TeslaMate
[09:18:34] INFO: ... RESTORED mileage.json
[09:18:35] INFO: ... RESTORED charge-level.json
[09:18:35] INFO: ... RESTORED drive-stats.json
[09:18:35] INFO: ... RESTORED charges.json
[09:18:35] INFO: ... RESTORED vampire-drain.json
[09:18:35] INFO: ... RESTORED battery-health.json
[09:18:36] INFO: ... RESTORED charging-stats.json
[09:18:36] INFO: ... RESTORED updates.json
[09:18:36] INFO: ... RESTORED drives.json
[09:18:36] INFO: ... RESTORED overview.json
[09:18:36] INFO: ... RESTORED projected-range.json
[09:18:37] INFO: ... RESTORED efficiency.json
[09:18:37] INFO: ... RESTORED visited.json
[09:18:37] INFO: ... RESTORED statistics.json
[09:18:37] INFO: ... RESTORED states.json
[09:18:37] INFO: ... RESTORED locations.json
[09:18:37] INFO: ... RESTORED timeline.json
[09:18:38] INFO: ... RESTORED trip.json
[09:18:38] INFO: ... RESTORED charge-details.json
[09:18:38] INFO: ... RESTORED drive-details.json
[09:18:38] INFO: ... RESTORED home.json
[09:18:38] INFO: Finished Importing Grafana Dashboards
[09:18:38] INFO: Creating database 'teslamate' on db21ed7f-postgres
[09:18:39] INFO: Database teslamate already exists
[09:18:39] INFO: Starting TeslaMate...
2025-01-20 09:18:42.170 [info] Migrations already up  ‼️ HERE
2025-01-20 09:18:47.051 [info] No tzdata release files found in custom data dir. Copying release file from tzdata priv dir.
2025-01-20 09:18:47.330 [info] System Info: Erlang/OTP 26 (jit)
2025-01-20 09:18:47.330 [info] Version: 1.32.0
2025-01-20 09:18:47.747 [info] POST https://auth.tesla.com/oauth2/v3/token -> 200 (302.510 ms)
2025-01-20 09:18:47.747 [info] Refreshed api tokens
2025-01-20 09:18:47.762 [info] Scheduling token refresh in 6 h
2025-01-20 09:18:47.779 [info] Running TeslaMateWeb.Endpoint with cowboy 2.12.0 at :::4000 (http)
2025-01-20 09:18:47.781 [info] Access TeslaMateWeb.Endpoint at http://localhost
2025-01-20 09:18:48.151 [info] Starting logger for [REDACTED]
2025-01-20 09:18:48.248 car_id=1 [info] Start / :offline
2025-01-20 09:18:49.164 [info] MQTT connection has been established. ‼️ HERE

The two ‼️ points about should indicate all is well with the DB config and MQTT so it should only be a matter of waiting.

If you're in the same position as one of the commenters where a DB query of SELECT * FROM cars LIMIT 50 returns nothing, then you're in a different position and something else is at play where TeslaMate isn't populating vital info when you first configure it.

In this case, you could try uninstalling the addon, removing the database (or use a new database name), reinstall and reconfigure the addon.

@hemy81
Copy link
Author

hemy81 commented Jan 21, 2025

Thank you very much for the detailed reply: Here are the logs:
From that side it looks good.

s6-rc: info: service teslamate: starting
s6-rc: info: service teslamate successfully started
s6-rc: info: service nginx: starting
s6-rc: info: service nginx successfully started
s6-rc: info: service legacy-services: starting
[20:40:45] INFO: Starting NGINX...
s6-rc: info: service legacy-services successfully started
[20:40:50] INFO: Checking for Grafana folder: TeslaMate
[20:40:53] INFO: ... RESTORED mileage.json
[20:40:54] INFO: ... RESTORED drive-stats.json
[20:40:54] INFO: ... RESTORED trip.json
[20:40:54] INFO: ... RESTORED visited.json
[20:40:55] INFO: ... RESTORED overview.json
[20:40:55] INFO: ... RESTORED projected-range.json
[20:40:55] INFO: ... RESTORED states.json
[20:40:56] INFO: ... RESTORED locations.json
[20:40:56] INFO: ... RESTORED drives.json
[20:40:56] INFO: ... RESTORED battery-health.json
[20:40:56] INFO: ... RESTORED efficiency.json
[20:40:57] INFO: ... RESTORED charging-stats.json
[20:40:57] INFO: ... RESTORED statistics.json
[20:40:57] INFO: ... RESTORED vampire-drain.json
[20:40:58] INFO: ... RESTORED updates.json
[20:40:58] INFO: ... RESTORED charge-level.json
[20:40:58] INFO: ... RESTORED charges.json
[20:40:58] INFO: ... RESTORED timeline.json
[20:40:59] INFO: ... RESTORED home.json
[20:40:59] INFO: ... RESTORED drive-details.json
[20:40:59] INFO: ... RESTORED charge-details.json
[20:40:59] INFO: Finished Importing Grafana Dashboards
[20:41:00] INFO: Creating database 'teslamate' on db21ed7f-postgres
[20:41:00] INFO: Database teslamate already exists
[20:41:00] INFO: Starting TeslaMate...
2025-01-21 20:41:06.495 [info] Migrations already up
2025-01-21 20:41:13.435 [info] No tzdata release files found in custom data dir. Copying release file from tzdata priv dir.
2025-01-21 20:41:13.806 [info] System Info: Erlang/OTP 26 (jit)
2025-01-21 20:41:13.806 [info] Version: 1.32.0
2025-01-21 20:41:16.327 [info] POST https://auth.tesla.com/oauth2/v3/token -> 200 (2381.949 ms)
2025-01-21 20:41:16.328 [info] Refreshed api tokens
2025-01-21 20:41:16.348 [info] Scheduling token refresh in 6 h
2025-01-21 20:41:16.380 [info] Running TeslaMateWeb.Endpoint with cowboy 2.12.0 at :::4000 (http)
2025-01-21 20:41:16.385 [info] Access TeslaMateWeb.Endpoint at http://localhost
2025-01-21 20:41:18.591 [info] Starting logger for [removed]
2025-01-21 20:41:19.024 [info] tzdata release in place is from a file last modified Thu, 05 Sep 2024 18:47:42 GMT. Release file on server was last modified Thu, 16 Jan 2025 17:10:51 GMT.
2025-01-21 20:41:19.721 [info] MQTT connection has been established
2025-01-21 20:41:22.024 [info] Tzdata has updated the release from 2024b to 2025a

@hemy81
Copy link
Author

hemy81 commented Jan 21, 2025

If you're in the same position as one of the commenters where a DB query of SELECT * FROM cars LIMIT 50 returns nothing, then you're in a different position and something else is at play where TeslaMate isn't populating vital info when you first configure it.

SELECT * FROM cars LIMIT 50 spits out much data about the car, such as id eid, vid, model, efficiency, inserted_at, updated_at. I have about 10 drives and 2 charges already done. So vital info is there.

In addition, I installed Grafana docker on a different device and get the same results.

@lildude
Copy link
Owner

lildude commented Jan 21, 2025

🤔 everything looks good to me so I'm really not sure what's going on. Probably best to open an issue upstream.

@hemy81
Copy link
Author

hemy81 commented Jan 26, 2025

Upstream issue opened: teslamate-org/teslamate#4494

@hemy81
Copy link
Author

hemy81 commented Jan 26, 2025

Problem solved! The connection to Postgres within Grafana should be named TeslaMate (and not Postgres...)!

@lildude
Copy link
Owner

lildude commented Jan 27, 2025

Woohoo!! 🎉

Looks like this is a hard-requirement so I'll change the addon docs to make this clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants