How to make default Torque integration work in Home Assistant

I noticed that a lot of HA users struggled with making default Torque Integration work. Therefore I decided to write up this tutorial.

It is actually relatively simple. This tutorial is basically an elaboration of the setup instructions provided here. (All the answers are basically there, but if you struggle with individual steps, this tutorial is for you. :slight_smile:)

(This tutorial assumes that you have the OBDII adapter setup and you connected it successfully to Torque app in your phone. It also assumes that you have vehicle profile setup in the Torque app.)

A. Home Assistant setup:

1. In your HA installation, edit the configuration.yaml file like this:

(email address can be any string you like, but it can’t be left empty)

sensor in config

2. Go to user (in my case “Peter”, obviously yours will be your name) in the bottom left of HA interface:

HA user

3. Scroll down to the bottom of the page where you can see your “Long-Lived Access Tokens” and chose “Create Token”:

4. Give your token a name (you can call it whatever you like, I called it “Torque Default Integration”) and click “OK”:

Screenshot 2022-12-13 111348

5. A token will be generated. Copy it, paste it somewhere, e.g. Google Keep or Notepad as it won’t be shown again after you close this dialog box. (You will need it later in Torque phone app.):

Screenshot 2022-12-13 102925

6. Restart HA

B. Torque app setup:

(You should be able to use Torque Light app, but this tutorial was made using Torque Pro app.)

1. In Torque app select the clog wheel icon in the bottom left corner of the app welcome screen:

2. Then select “Settings”:

3. Then select “Data Logging & Upload”:

4. Then select three dots in the top right corner:

5. Then select “Select what to log”:

6. Chose which parameters you would like to log:

(It is better if you do this while connected to OBDII as it will make it clearer which items your adapter is able to log from your engine data.)

7. Go back to “Data Logging & Upload”. My “File Logging” settings look like this - they are not that crucial but just in case you struggle to make things work, I have them setup like this:

8. Scroll down to “Realtime web upload”. These settings are the most important! Make sure you enable “Upload to webserver”:

9. “Weblogging interval” - 5 seconds. (You can make it whatever you like, but it could quickly overload HA database if the value is too low, or you won’t get sufficient information if the value is too high).

Enable “Only when OBD connected”. (It works either way but more data might flood your HA database.)

10. Select “Webserver URL”. Enter the web address you use to login to your HA installation remotely from outside of your home network (e.g. Nabu Casa or DuckDNS, etc.). It’s very important to add “…/api/torque” after your address! Then click “OK”.

(Connection from the webserver URL has to be encrypted with SSL/TLS as stated in the referenced article.)

11. Select “Set Bearer Token”. Insert your token you generated earlier in your HA installation (in steps A.3 and A.4). Then click “OK”:

12. Select “User Email Address” and enter the same email address you entered in HA configuration.yaml file (in step A.1):

13. Restart HA

14. Connect your Torque app to OBDII adapter and drive your car for couple of minutes to generate data.

15. Entities should now be loaded in your HA installation with names that begin with “sensor.vehicle_…”, e.g. In my installation it looks they look like this:

In my dashboard they appear like this:

Hope this tutorial will be helpful to some. :wink:

28 Likes

Very helpful!

Any Ideas on why my Bearer token is grayed out in torque pro? I cannot toggle it on.

Did you check you have the other options set up correctly, particularly the “Webserver URL”? Connection from the webserver URL has to be encrypted with SSL/TLS as stated in the referenced article. (I have now edited my original post to emphasize this.) If you use the Nabu Casa URL (like I do) I believe it is set up for you automatically. If you use any other option like DuckDNS there might be some tweaking involved.

if you have a separate sensor.yaml file, do you still put the configuration text on config? or do you put it in the sensor.yaml file?

Either of these two options should definitely work just like they do generally in Home Assistant.

(You can have it either in “configuration.yaml” file under “sensor” category like I do or you can have it in separate “sensor.yaml” file. Of course, if you use seperate “sensor.yaml” file you should have a reference to it in your configuration.yaml file - “sensor: !include sensor.yaml”)

How to debug if no vehicule sensors are created on Home Assistant side, and nothing related to torque in the HA logs ? There are some videos on youtube, but they are not using the native Web Upload feature of Torque (Pro))

ok i used http://in.torque-bhp.com as web server, and i could see on https://view.torque-bhp.com/
the PIDs i selected under Torque App.
Under HA logs i can see error when i try to do a HTTP GET on /api/torque on my HA. (but i dont see any connexion try from Torque App).
I double checked the web server url to my HA that i set in the app. (provoking the above logging faillure above).

Any idea ?
2 potentials pb i see :

  • I will recreate a token and set it again in the app (could be an https specific in my case, but https is working ok on my side when accessing /lovelace/default_view )

  • frequency of upload to webserver seems not to be very strictly applied from Torque (pro) app. I set 1 min but https://view.torque-bhp.com/ does not react every minutes… so maybe need to double recheck (including if targetting HA).

Did you check if your connection from the webserver URL is encrypted with SSL/TLS? (I mentioned this in one of my previous replies above.)

1 Like

Yes, i’m SSL/TLS under DuckDns.
It this known working configuration with Torque ?

When exiting torque app, the app is uploading the file. Works ok with the in.torque-bhp.com
But infinite wait when targeting my HA instance
I tried doing a GET on my HA server /api/torque, can i can see some logs failures (complaining about email mismatch)

It is like the app could not reach my HA instance.

Same issue here - my logging to HA stalls each time. Doesn’t seem to matter what webserver address I use - I’ve used nabu casa’s web address and even a cloudflared tunnel (so both HTTPS), doesn’t seem to change anything. The logs in HA:
INFO (SyncWorker_1) [homeassistant.loader] Loaded torque from homeassistant.components.torque
INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.torque

But I do not see any errors or anything showing that a device is trying to connect and failing like I do with other apps.

Am I missing where other logs would be?

Have you tried enabling more detailed logging information in your “configuration.yaml” file?

If not, try adding the following to your “configuration.yaml” file:

logger:
  default: warning
  logs:
    homeassistant.components.torque: debug

or

logger:
  default: warning
  logs:
    homeassistant.components.torque: info

You can find more information on how to setup logger in home assistant here.

(I apologize if you have the logger setup this way already, I’m just trying to make sure the logger shows you all the information.)

I’m just waiting for a bluetooth OBD reader to arrive, and I was wondering if this should work if using nabucasa URL as opposed to the local instance URL via port forward on the home router?

Yes. Using the nabucasa URL can actually make the entire process easier. (My example uses nabucasa URL.)

1 Like

My apologies, in my haste I didn’t read your post properly

I assume the Torque app must be running in the phone when driving for this to work?

Yes, Torque app needs to run on your phone while driving for it to work.

Thanks. I have successfully integrated this thanks to your guide. The main reason for me to do this is to get the car total mileage value into HA so that it can remind me when it’s time to service the car. But the value given by Torque is not that accurate. It seems like the value is calculated not the actual reading on my car’s odometer. Do you know how to obtain the actual mileage value as shown on the odometer?

1 Like

I believe this depends on the particular car model and OBDII adapter model being used. For example, my adapter doesn’t have this option at all. You can double-check if your adapter supports it by going to the ‘Select what to log’ setting in your Torque app (Step 6 of my tutorial). If you don’t see this option, it probably means that it isn’t supported by your OBDII adapter or car model.

As a workaround, I believe you could set up a template sensor in your configuration.yaml file. This sensor would add the ‘trip distance’ every time you finish a trip. Alternatively, you could use the Google Sheets integration in your Home Assistant to log each trip distance on a separate row. This way, you can calculate the overall sum of the distances.

Another problem is I share my car with other family members. If the car is driven by others and that person is not carrying my phone, the trip distance will not be recorded right?

I understand your situation and have faced a similar problem before. I found a solution that may work for you: I used an old phone with Torque installed and kept it in my car at all times. I ensured that no other phone was set up to connect to the OBDII. The phone was plugged into a charger and never fully discharged as there was never enough time between rides.

Additionally, the phone could connect to Wifi at home, or you could use your main phone as a hotspot for it.

While you could install this system on multiple devices, such as your family members’ phones, note that Home Assistant may recognize them as sensors from separate vehicles, which may not be ideal.

2 Likes