[SOLVED] Read Tesla Model 3 values via pre 2.4 mqtt

I am trying to display the status of my Tesla Model 3 in Openhab2, using the old (pre 2.4) mqtt method.
I have not switched to mqtt 2.4 method yet, because I have a lot of Tasmota devices running via mqtt (defined in the items file) and have not used PaperUI for them, like for instance

Switch Stecker_Rechner “Steckdose DVBViewer Rechner” (KG_Technik) { mqtt=">[mosquitto:cmnd/sonoff-10155A/POWER:command:*:default],<[mosquitto:stat/sonoff-10155A/POWER:state:default]" }

When I subscribe to the Tesla topic via mqtt.fx, I receive something like

{“charging”:false,“driving”:false,“online”:true,“sleeping”:false,“speed”:82,“power”:21,“odometer”:13095.093747686564,“ideal_battery_range_km”:243.38156010106698,“outside_temp”:32,“battery_level”:49,“charger_voltage”:0,“charger_phases”:0,“charger_actual_current”:0,“charge_energy_added”:0,“charger_power”:0,“car_version”:“2019.28.3.1 f9e95acd”,“trip_start”:“13:46”,“trip_max_speed”:157,“trip_max_power”:288,“trip_duration_sec”:1226,“trip_kwh”:4.1268165505254473,“trip_avg_kwh”:170.59976834495549,“trip_distance”:24.190047797608713}

To display for instance Tesla ideal_battery_range_km I thought I can place a line like

Number Tesla_Rest km “Reichweite Tesla [%1.0f %%]” (gTesla) { mqtt="<[mosquitto:Tesla/ideal_battery_range_km]" }

in my items file - but this does not display anything.

Any hints and help is appreciated - thanks a lot!

P.S: The Tesla binding only works until the Model 3 goes to sleep - so its not a solution here.

That’s JSON, so you would want to find out about JSON with MQTT-1 binding.

1 Like

Thanks rossko57!

You mean I should do it like this?

Number Tesla_Restkm “Reichweite Tesla [%1.0f %%]” (gTesla) { mqtt="<[mosquitto:Tesla:state:JSONPATH($.ideal_battery_range_km)]" }

That’s the general idea.

When you do decide to make the move I recommend the following approach:

  1. Create one Generic Thing for one of your Tasmota devices
  2. Using the REST API Docs query for that Thing to get the JSON
  3. Paste that example into Notepad or some text editor
  4. Edit the JSON to make a Thing for another of your Tasmota devices, there should only be a handful of fields to change
  5. Using the REST API Docs, add a new Thing, using the edited JSON for the Thing definition.

Working in this way you can very quickly create your Things without messing with all the clicking and waiting in PaperUI.


Thank you guys, its working now with mqtt 1.x binding. The mqtt topic is tele/Tesla and my items file looks like

Number Tesla_SOC “Ladestand Tesla [%.1f %%]” (gTesla) { mqtt="<[mosquitto:tele/Tesla:state:JSONPATH($.battery_level)]" }
Number Tesla_km “km Stand Tesla [%.1f km]” (gTesla) { mqtt="<[mosquitto:tele/Tesla:state:JSONPATH($.odometer)]" }
Number Tesla_Restkm “Reichweite Tesla [%.1f km]” (gTesla) { mqtt="<[mosquitto:tele/Tesla:state:JSONPATH($.ideal_battery_range_km)]" }

As long as it is working I’m not going to migrate…