Torque login won't work

Following the guide on https://home-assistant.io/components/sensor.torque/

When i click “Test settings” in Torque it says OK.
But the log in HA says:
16-09-15 15:46:29 homeassistant.components.http: Login attempt or request with an invalid password from x.x.x.x

When i test the “Webserver url” http://HOST:PORT/api/torque?api_password=YOUR_PASSWORD (with my settings)
in a webbrowser i get:
{"message": "400: Bad Request", "result": "error"}
Anyone have a working setup?

Same here, and also looking for a solution, only difference I have is my HA is secured using https…

have you added the port as 443? just tried this and its now working ok.

turns out i lied it was not working =/

Is there anyone that have this working?
Can anyone provide a little tutorial on how to get it to work, or at least show some images or text on what you can do with this?
Would be great if this could work. I have been googling a bit and found some other way to let tasker pull out some values from the log, going to test this out when I get home…
There are a few values I would like to have access to in Hass.

Bump, anyone managed to make it work?

Check out the information added in this discussion:

The current Torque component does respond in the way that it looks like the Torque app requires, so all of the messages just pile up until you close the Torque app, and it will keep try to send those over and over again. Additionally the Torque app is dropping the api_key parameter in the URL, so it looks like you have to use some sort of proxy to add that back. Another issue is that Torque doesn’t support HTTPS right now, so that’s yet another reason you’d need to proxy if the rest of your HASS install is all completely behind TLS.

I can’t fix the issues with the Torque app, but I have a fix in a pull request for the component issues here that will hopefully get pulled in soon :smiley::

Is HTTPS stil not working with torque? I can’t get it to work :confused: nothing in the log with debug enabled.

Bump. I can’t get Torque to upload using https. Still not supported?

I think it is a crazy bug in the app… I tested it with NGINX and PHP script and with a NodeRed HTTP GET endpoint, but SSL doesnt seem to work :frowning:

So, thats my solution:

  • let Torque log to file (CSV)
  • let Tasker read the newest log file (I use command line head and tail), when car disconnects.
  • let Tasker send data to HAss

I created a generic webhook for publishing data to my HAss Mosquitto instance:

1 Like

For anyone wanting to get car telemetry using Torque into Home Assistant, i have a solution at http://childof69.co.uk/blog/2019/06/25/car-telemetry/. Comments welcome.

Here is a solution:
https://github.com/home-assistant/core/issues/28836

“You just need to create a script on Dory and paste the following code (make sure you replace the variables accordingly). Also, set the Web Server URL on Torque to http://localhost:8123/api/torque instead of the Home Assistant API path. Once you done this, you can make it to start on boot, so you won’t need to touch it again.”

const http = require('http');
const https = require('https');
const url = require('url');

let app = http.createServer((request, response) => {

    let address = url.parse(request.url, true).pathname;

    try {

        if (request.method == 'GET' && address == '/api/torque') {
    
            const input = {
                hostname: '<your-domain>.duckdns.org',
                port: 8123,
                method: request.method,
                path: request.url,
                headers: {
                    'Authorization': 'Bearer <paste your long-lived access token here>'
                }
            }
    
            let process = https.request(input, (output) => {
                output.on('data', (data) => {
                    response.write(data);
                });
                output.on('end', () => {
                    response.end();
                });
            });

            process.on('error', (error) => {
                handleResponse(response, error.message);
            });

            process.end();

        } else {
            throw 'Bad Request';
        }
    }
    catch (exception) {
        handleResponse(response, exception);
    }

    function handleResponse(response, exception) {
        response.writeHead(400);
        response.end(exception);
    }
});

// Start the server on port 8123
app.listen(8123, '0.0.0.0');

Setting up Dory
https://dev.to/danenglishby/setting-up-a-nodejs-web-server-on-your-android-phone-or-tablet-3fim

I have limitless data plan on phone,so I don’t have to think how much data is transferred.
Torque 20200615

1 Like

Any Torque users still? I’m a little bit annoyed that Torque sensors are not registered until something is transmitted(= car is used) so there’s a lot of ‘Entity not available’ errors on the screen?

Nevermind, wrote my own version that does not have that problem.

How did you solve the problem? I see several entities when something is transmitted but after some seconds the entities are not available anymore…

I think I had a different problem than you.
When I started HA, the entities are highlighted with ‘Entity not available’. Only after I used my car and got data downloaded, the entities were registered. So, my entities never change back to ‘Entity not available’, at least until I restart my HA.

What was your solution in the end?

( wow, I cannot correct my earlier post by deleting it and posting this as an answer because “Body is too similar than earlier post” so I have to write this nonsence so its not similar )

Me or lukasrininsland?

1 Like

It was you :slight_smile:

I forked and made a new version, where all sensors names are read first from configuration.yaml and created as sensors in HA. The original version does that when the actual measurements arrive for the first time.

Names of the sensors cannot be hard-coded because different cars have different measurements.

I’ll look if can make a fork in Github to release the code. The version seems to be working with this years HA version, but right now I’m not using Torque plugin. I found out my current car’s(Skoda) OBDII is powered always so it drains battery and allows anyone to connect to it for instance in supermarkets parking lot. My earlier car Peugeot had it powered only when car’s electricity was on. A bit of a security issue now and have to change OBDII to get it’s power from for instance radios +12v.

Example of changes in yaml:

    sensors:
       - 16716334:
           Name: 0-100kph Time
           Unit: s
       - 16716388:
           Name: 100-0kph Time
           Unit: s

Clever idea! I’m looking into the mqtt method at the moment as it looks like it will preserver the sensors between reboots.

I have a OBD2 dongle that apparently turns itself off with the engine so hopefully battery drain won’t be an issue.