matt-FFFFFF / hassio-addon-teslamate

Teslamate addon for Home Assistant
MIT License
68 stars 22 forks source link

MQTT integration doesn't work #87

Open Jens-Wymeersch opened 1 year ago

Jens-Wymeersch commented 1 year ago

Describe the bug I don't get any reports into Grafana nor do I see any entities in MQTT. Secondly, the initial MQTTuser that I have defined doesn't have access anymore.

Steps to reproduce 1. config in grafana certfile: fullchain.pem env_vars:

In Grafana - added datasource

image

2. In Postgres

image

3. In MQTT

logins: [] require_certificate: false certfile: fullchain.pem keyfile: privkey.pem customize: active: true folder: mosquitto

Created files /share/mosquitto/acecesscontrollist and /share/mosquitto/acl.conf

Created an user teslamate in Home assistant (settings)

4 in Teslamate

database_user: teslamate database_pass: pw database_name: teslamate database_host: 29b65938-postgres database_ssl: false database_port: 5432 disable_mqtt: false encryption_key: aradomencryptionkey grafana_import_dashboards: true grafana_folder_name: TeslaMate grafana_host: a0d7b954-grafana grafana_port: 3000 grafana_user: admin grafana_pass: pw import_dir: /share/teslamate mqtt_host: core-mosquitto mqtt_user: teslamate mqtt_pass: pw mqtt_tls: false mqtt_tls_accept_invalid_certs: false mqtt_namespace: "" timezone: Asia/Jerusalem

logs Teslamate

2023-02-09 11:15:28.298 [info] Start of drive initiated by: %TeslaApi.Stream.Data{elevation: 265, est_heading: 352, est_lat: 31.887999, est_lng: 35.01521, est_range: 94, heading: 357, odometer: 20004.9, power: 2, range: 125, shift_state: "R", soc: 39, speed: 0, time: ~U[2023-02-09 09:15:28.195Z]}
2023-02-09 11:15:28.298 car_id=1 [info] Driving / Start
2023-02-09 11:28:26.992 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (603.217 ms)
2023-02-09 11:28:27.509 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (516.479 ms)
2023-02-09 11:28:27.518 [info] End of drive initiated by: %TeslaApi.Vehicle.State.Drive{gps_as_of: 1675934905, heading: 342, latitude: 31.906416, longitude: 35.017888, native_latitude: 31.906416, native_location_supported: 1, native_longitude: 35.017888, native_type: "wgs", power: 1, shift_state: "P", speed: 0, timestamp: 1675934906256}
2023-02-09 11:28:27.518 car_id=1 [info] Driving / Ended / 5 km – 13 min
2023-02-09 11:28:27.518 car_id=1 [info] Start / :online
2023-02-09 11:29:55.811 car_id=1 [info] Received stream data: :inactive
2023-02-09 11:39:24.107 [warning] Too many disconnects from streaming API
2023-02-09 11:39:24.107 car_id=1 [info] Creating new connection … 
2023-02-09 11:39:24.107 car_id=1 [info] Disconnecting ...
2023-02-09 11:39:24.109 car_id=1 [info] Connecting ...
2023-02-09 11:42:36.353 [info] Start of drive initiated by: %TeslaApi.Vehicle.State.Drive{gps_as_of: 1675935755, heading: 342, latitude: 31.906416, longitude: 35.017888, native_latitude: 31.906416, native_location_supported: 1, native_longitude: 35.017888, native_type: "wgs", power: 1, shift_state: "R", speed: 0, timestamp: 1675935756175}
2023-02-09 11:42:36.353 car_id=1 [info] Driving / Start
2023-02-09 11:49:37.749 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (345.439 ms)
2023-02-09 11:49:38.241 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (491.345 ms)
2023-02-09 11:49:38.246 [info] End of drive initiated by: %TeslaApi.Vehicle.State.Drive{gps_as_of: 1675936175, heading: 204, latitude: 31.900113, longitude: 35.008391, native_latitude: 31.900113, native_location_supported: 1, native_longitude: 35.008391, native_type: "wgs", power: 1, shift_state: "P", speed: 0, timestamp: 1675936177148}
2023-02-09 11:49:38.246 car_id=1 [info] Driving / Ended / 1 km – 7 min
2023-02-09 11:49:38.246 car_id=1 [info] Start / :online
2023-02-09 11:49:57.966 [info] Start of drive initiated by: %TeslaApi.Stream.Data{elevation: 232, est_heading: 204, est_lat: 31.900116, est_lng: 35.008392, est_range: 95, heading: 204, odometer: 20009.0, power: 1, range: 120, shift_state: "D", soc: 38, speed: 0, time: ~U[2023-02-09 09:49:57.863Z]}
2023-02-09 11:49:57.966 car_id=1 [info] Driving / Start
2023-02-09 11:51:15.946 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (290.800 ms)
2023-02-09 11:51:16.940 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (993.101 ms)
2023-02-09 11:51:16.950 [info] End of drive initiated by: %TeslaApi.Vehicle.State.Drive{gps_as_of: 1675936274, heading: 52, latitude: 31.899524, longitude: 35.008917, native_latitude: 31.899524, native_location_supported: 1, native_longitude: 35.008917, native_type: "wgs", power: 1, shift_state: "P", speed: 0, timestamp: 1675936275372}
2023-02-09 11:51:16.950 car_id=1 [info] Driving / Ended / 0 km – 1 min
2023-02-09 11:51:16.950 car_id=1 [info] Start / :online
2023-02-09 11:53:07.433 car_id=1 [info] Received stream data: :inactive
2023-02-09 12:01:34.531 [warning] Too many disconnects from streaming API
2023-02-09 12:01:34.531 car_id=1 [info] Creating new connection … 
2023-02-09 12:01:34.531 car_id=1 [info] Disconnecting ...
2023-02-09 12:01:34.533 car_id=1 [info] Connecting ...
2023-02-09 12:10:04.678 car_id=1 [info] Received stream data: :inactive
2023-02-09 12:10:48.631 [info] Start of drive initiated by: %TeslaApi.Vehicle.State.Drive{gps_as_of: 1675937447, heading: 46, latitude: 31.899514, longitude: 35.008895, native_latitude: 31.899514, native_location_supported: 1, native_longitude: 35.008895, native_type: "wgs", power: 1, shift_state: "R", speed: 1, timestamp: 1675937448370}
2023-02-09 12:10:48.631 car_id=1 [info] Driving / Start
2023-02-09 12:16:51.411 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/number/vehicle_data -> 408 (134.447 ms)
2023-02-09 12:16:51.543 car_id=1 [warning] Vehicle went offline while driving
2023-02-09 12:16:52.410 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/numbervehicle_data -> 408 (133.107 ms)
2023-02-09 12:16:52.911 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/number/vehicle_data -> 408 (127.359 ms)
2023-02-09 12:16:53.418 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/number/vehicle_data -> 408 (128.390 ms)
2023-02-09 12:16:55.247 car_id=1 [info] Vehicle is back online
2023-02-09 12:16:55.538 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (283.640 ms)
2023-02-09 12:16:56.046 [info] GET https://nominatim.openstreetmap.org/reverse -> 200 (507.982 ms)
2023-02-09 12:16:56.055 [info] End of drive initiated by: %TeslaApi.Vehicle.State.Drive{gps_as_of: number1, heading: 360, latitude: 31.887778, longitude: 35.002349, native_latitude: 31.887778, native_location_supported: 1, native_longitude: 35.002349, native_type: "wgs", power: 0, shift_state: "P", speed: 0, timestamp: 1675937814457}
2023-02-09 12:16:56.055 car_id=1 [info] Driving / Ended / 3 km – 6 min
2023-02-09 12:16:56.055 car_id=1 [info] Start / :online
2023-02-09 12:19:42.585 car_id=1 [info] Received stream data: :inactive
2023-02-09 12:21:15.383 car_id=1 [info] Suspending logging
2023-02-09 12:28:10.973 [warning] Too many disconnects from streaming API
2023-02-09 12:28:10.973 car_id=1 [info] Creating new connection … 
2023-02-09 12:28:10.973 car_id=1 [info] Disconnecting ...
2023-02-09 12:28:10.974 car_id=1 [info] Connecting ...
2023-02-09 12:51:16.793 car_id=1 [info] Start / :asleep
2023-02-09 12:51:16.795 car_id=1 [info] Disconnecting ...
2023-02-09 13:30:40.229 car_id=1 [info] Start / :online
2023-02-09 13:30:40.237 car_id=1 [info] Connecting ...
2023-02-09 13:34:14.777 car_id=1 [info] Suspending logging
2023-02-09 13:41:27.970 [info] GET /
2023-02-09 13:41:27.972 [info] Sent 200 in 1ms
2023-02-09 13:41:34.741 car_id=1 [info] Resuming logging
2023-02-09 13:42:21.675 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/number/vehicle_data -> 408 (9125.905 ms)
2023-02-09 13:42:21.675 [warning] TeslaApi.Error / %{"error" => "{\"error\": \"timeout\"}", "error_description" => "", "response" => nil}
2023-02-09 13:42:21.675 car_id=1 [error] Error / :unknown
2023-02-09 13:42:50.820 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/number/vehicle_data -> 408 (9143.671 ms)
2023-02-09 13:42:50.820 [warning] TeslaApi.Error / %{"error" => "{\"error\": \"timeout\"}", "error_description" => "", "response" => nil}
2023-02-09 13:42:50.820 car_id=1 [error] Error / :unknown
2023-02-09 13:43:44.216 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1493132975230022/vehicle_data -> 408 (131.968 ms)
2023-02-09 13:43:54.479 car_id=1 [info] Start / :asleep
2023-02-09 13:43:54.486 car_id=1 [info] Disconnecting ...

MQTT

2023-02-07 11:00:55: New connection from 172.30.33.8:42808 on port 1883.
2023-02-07 11:00:55: New client connected from 172.30.33.8:42808 as TESLAMATE_302E3135393 (p2, c0, k60, u'teslamate').

Postgres

PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-02-07 09:45:50.203 IST [7] LOG:  starting PostgreSQL 12.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit
2023-02-07 09:45:50.203 IST [7] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-02-07 09:45:50.203 IST [7] LOG:  listening on IPv6 address "::", port 5432
2023-02-07 09:45:50.236 IST [7] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-02-07 09:45:50.250 IST [34] LOG:  database system was shut down at 2023-02-07 09:45:49 IST
2023-02-07 09:45:50.254 IST [7] LOG:  database system is ready to accept connections

Grafana

Grafana server is running with elevated privileges. This is not recommended
logger=settings t=2023-02-09T14:00:25.414425747+02:00 level=info msg="Starting Grafana" version=9.2.4 commit=64017e8ca6 branch=HEAD compiled=2022-11-08T12:38:42+02:00
logger=settings t=2023-02-09T14:00:25.414543213+02:00 level=info msg="Config loaded from" file=/usr/share/grafana/conf/defaults.ini
logger=settings t=2023-02-09T14:00:25.41456+02:00 level=info msg="Config loaded from" file=/etc/grafana/grafana.ini
logger=settings t=2023-02-09T14:00:25.414564135+02:00 level=info msg="Config overridden from Environment variable" var="GF_SECURITY_ADMIN_USER=admin"
logger=settings t=2023-02-09T14:00:25.41456779+02:00 level=info msg="Config overridden from Environment variable" var="GF_SECURITY_ADMIN_PASSWORD=*********"
logger=settings t=2023-02-09T14:00:25.414571239+02:00 level=info msg="Path Home" path=/usr/share/grafana
logger=settings t=2023-02-09T14:00:25.414574396+02:00 level=info msg="Path Data" path=/data
logger=settings t=2023-02-09T14:00:25.414577133+02:00 level=info msg="Path Logs" path=/var/logs/grafana
logger=settings t=2023-02-09T14:00:25.414579906+02:00 level=info msg="Path Plugins" path=/var/lib/grafana/plugins
logger=settings t=2023-02-09T14:00:25.414582999+02:00 level=info msg="Path Provisioning" path=/usr/share/grafana/conf/provisioning
logger=settings t=2023-02-09T14:00:25.414586463+02:00 level=info msg="App mode production"
logger=sqlstore t=2023-02-09T14:00:25.414627727+02:00 level=info msg="Connecting to DB" dbtype=sqlite3
logger=migrator t=2023-02-09T14:00:25.423498462+02:00 level=info msg="Starting DB migrations"
logger=migrator t=2023-02-09T14:00:25.427134676+02:00 level=info msg="migrations completed" performed=0 skipped=452 duration=616.503µs
logger=plugin.loader t=2023-02-09T14:00:25.469209948+02:00 level=info msg="Plugin registered" pluginID=input
logger=plugin.loader t=2023-02-09T14:00:27.41710066+02:00 level=info msg="Plugin registered" pluginID=pr0ps-trackmap-panel
logger=plugin.loader t=2023-02-09T14:00:27.417117678+02:00 level=info msg="Plugin registered" pluginID=grafana-image-renderer
logger=plugin.loader t=2023-02-09T14:00:27.417122673+02:00 level=info msg="Plugin registered" pluginID=grafana-piechart-panel
logger=plugin.loader t=2023-02-09T14:00:27.417126895+02:00 level=info msg="Plugin registered" pluginID=natel-discrete-panel
logger=secrets t=2023-02-09T14:00:27.417277436+02:00 level=info msg="Envelope encryption state" enabled=true currentprovider=secretKey.v1
logger=query_data t=2023-02-09T14:00:27.418284371+02:00 level=info msg="Query Service initialization"
logger=live.push_http t=2023-02-09T14:00:27.421953761+02:00 level=info msg="Live Push Gateway initialization"
logger=infra.usagestats.collector t=2023-02-09T14:00:27.480787862+02:00 level=info msg="registering usage stat providers" usageStatsProvidersLen=2
logger=provisioning.alerting t=2023-02-09T14:00:27.481225884+02:00 level=info msg="starting to provision alerting"
logger=provisioning.alerting t=2023-02-09T14:00:27.481237907+02:00 level=info msg="finished to provision alerting"
logger=http.server t=2023-02-09T14:00:27.482547433+02:00 level=info msg="HTTP Server Listen" address=[::]:3000 protocol=http subUrl=/api/hassio_ingress/dWyHGMaIDKSFwBC0jCemQhGHr1oMlxI65YtUKsQ59mM socket=
logger=ngalert t=2023-02-09T14:00:27.482621435+02:00 level=info msg="warming cache for startup"
logger=grafanaStorageLogger t=2023-02-09T14:00:27.491947621+02:00 level=info msg="storage starting"
logger=ticker t=2023-02-09T14:00:27.501516488+02:00 level=info msg=starting first_tick=2023-02-09T14:00:30+02:00
logger=ngalert.multiorg.alertmanager t=2023-02-09T14:00:27.501528083+02:00 level=info msg="starting MultiOrg Alertmanager"
[14:00:27] INFO: Starting NGINX...
logger=plugin.grafana-image-renderer t=2023-02-09T14:00:28.001754487+02:00 level=warn msg="Plugin process is running with elevated privileges. This is not recommended"
pezlin commented 1 year ago

I have partly the same issue as you. I can't get the MQTT integration to work. There are no errors in the logs. I have installed MQTT Explorer as well but can't see any topics.

matt-FFFFFF commented 1 year ago

It looks like login is working. Have you set up any ACLs?

matt-FFFFFF commented 1 year ago

To add to this, I keep getting an error message - pq: password authentication failed for user when I add the username and password to the data source. I am sure it's correct as I am copy pasting it from the config.

The DB user and password is only set in the initial Postgres container initialisation. If you change it afterwards it won't work sadly.

I'd suggest removing the Postgres add on, then re-adding and setting the configuration before 1st run.

mobiletru commented 1 year ago

image Had the same problem make sure the datasource is "TeslaMate" with a capital M

matt-FFFFFF commented 1 year ago

If you are not seeing data in Grafana then the issue is the Postgres connection, not MQTT.

I think we have multiple issues being discussed here.

Hufflepuff-source commented 1 year ago

@matt-FFFFFF Got it working. I had the MQTT set to true all this time :/ Do you know how to integrate TeslaMate with HA so I can see the entities within HA? (https://docs.teslamate.org/docs/integrations/home_assistant) TIA.

matt-FFFFFF commented 1 year ago

Hi,

If you have MQTT working you can follow the instructions on the Teslamate website. It's the same from here on in.

jiaton commented 1 year ago

For me, I gave the write access to my mqtt user for all the topics to make it work.

user mymqttuser
topic readwrite #