Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

tesla-apiscraper: Yet another selfhosted Teslog/Teslafi alternative

This site may earn commission on affiliate links.
OK I got everything installed (and grafana setup and showing nice dashboard). Now I need data.

So I started the apiscraper on the command line and got two problems. The first is that I could not wake up the car. I kept getting a 408 response code every second the scraper was running, for several minutes until I stopped it. I had too open the Tesla pp on my phone to wake up my car.

Then I ran the apiscraper again and got the following,

2019-06-02 11:24:28 INFO HTTP Server Thread started on port 8023
2019-06-02 11:24:30 INFO Writing Points to Influx: charge_state
2019-06-02 11:24:30 INFO Writing Points to Influx: climate_state
2019-06-02 11:24:30 INFO Writing Points to Influx: drive_state
2019-06-02 11:24:30 INFO Writing Points to Influx: gui_settings
2019-06-02 11:24:30 INFO Writing Points to Influx: vehicle_state
2019-06-02 11:24:30 INFO Asleep since: 0 Sleeping for 1 seconds..
Lockfile detected, skipping
2019-06-02 11:24:33 INFO Asleep since: 0 Sleeping for 2 seconds..
INFO:apiscraper:Asleep since: 0 Sleeping for 2 seconds..
Exception in thread elevator:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/hroussel/tesla-apiscraper/srtmread.py", line 29, in elevationtoinflux
ifclient.write_points(elev_json_body)
File "/usr/lib/python3/dist-packages/influxdb/client.py", line 456, in write_points
tags=tags, protocol=protocol)
File "/usr/lib/python3/dist-packages/influxdb/client.py", line 506, in _write_points
protocol=protocol
File "/usr/lib/python3/dist-packages/influxdb/client.py", line 302, in write
headers=headers
File "/usr/lib/python3/dist-packages/influxdb/client.py", line 263, in request
raise InfluxDBClientError(response.content, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {"error":"unable to parse 'drive_state,display_name=Orion,vin=__mycorrectvin____ 1559489068109000000': invalid field format"}

Anybody else hit that problem?
 
Hi, how is tesla-apiscraper behaving when your car is parked with/without cabin overheat protection running?

When running the python script, the console shows this every second:

Code:
2019-07-01 20:28:47 INFO     Asleep since: 0 Sleeping for 1 seconds..
2019-07-01 20:28:49 INFO     Writing Points to Influx: charge_state

It seems to prevent the car from sleeping. If I start it while the car is asleep, it will check every 64 seconds but otherwise does not wake up the car.
 
I have the same issue, pings every second and the car hasn't slept in days! Poor lady
2019-07-17 10_47_09-Driving - Grafana.png
 
It seems to prevent the car from sleeping. If I start it while the car is asleep, it will check every 64 seconds but otherwise does not wake up the car.

I setup tesla-apiscraper on a new Raspberry Pi 4 and encountered this problem of the car not sleeping.

I increased the debug level in config.py to "alog_level=10" and then could see messages like this:
Value Change, SG: charge_state: Logging...est_battery_range: old value: 217.24, new value: 214.66

I increased the tolerance in apiscraper.py to 2.5 and that seems to have allowed the sleep interval to increase:

if new_value and old_value and (
(element == "battery_range") or
(element == "est_battery_range") or
(element == "ideal_battery_range")
):
if abs(new_value - old_value) < 0.5: // Increase this value, 2.5 worked quite well

However, I'm now up to a script sleep value of 512 seconds and car is still awake...
It's time for me to sleep now :), so I will investigate again tomorrow.
 
Just played around with getting this installed in Windows. For some reason my Geolocation dashboard fails to load the plugin no matter how many times I try to get it to install. Anyone else see this error?


Panel plugin not found: pr0ps-trackmap-panel
 
Got everything installed (I think), then ran the apiscraper.py to test and got some data visible in Grafana. However, sometimes the scraper only runs one time and stops with the following below. If I manually re-run the scraper, there's usually a good chance it'll run fine.

My question, if I setup tmux to create the scraper to run automatically per the installation instructions, if the TypeError: '>' not supported between instances of 'NoneType' and 'int' should occur, would the scraper be dead in the water?

2019-08-26 16:51:52 INFO HTTP Server Thread started on port 8023
2019-08-26 16:51:56 INFO Writing Points to Influx: charge_state
2019-08-26 16:51:57 INFO Writing Points to Influx: climate_state
2019-08-26 16:51:57 INFO Writing Points to Influx: drive_state
2019-08-26 16:51:57 INFO Writing Points to Influx: gui_settings
2019-08-26 16:51:57 INFO Writing Points to Influx: vehicle_state
2019-08-26 16:51:57 INFO Asleep since: 0 Sleeping for 1 seconds..
Traceback (most recent call last):
File "./apiscraper.py", line 426, in <module>
car_active_state = state_monitor.ongoing_activity_status()
File "./apiscraper.py", line 120, in ongoing_activity_status
or self.old_values['charge_state'].get('charger_voltage', 0) > 0 or self.old_values['charge_state'].get('charger_actual_current', 0) > 0:
TypeError: '>' not supported between instances of 'NoneType' and 'int'


Also, I'm not big into linux, just know enough to get what i need done done. Thanks
 
I was using APIScaper earlier and was having a lot of issues - and eventually discovered TeslaMate (adriankumpf/teslamate) and moved over to that - and couldn't be happier. Fundamentally same thing, but I think the community around this is more responsive and lots of activity (which is good). I run it on a Pi (via docker).
 
Not sure why a Tesla driver would need any of this information

Curiosity about consumption etc.
Check state of car without waking it up (as APP does)
See data that the APP shows, but after-the-fact
Business Miles reimbursement
When did I visit X? How often? is my Spouse having an affair :rolleyes:
What time will my spouse be home ... can do that from the APP, but Logging will show how the traffic has been, how long stationary in current traffic jam, etc. etc. Did spouse already stop at Supermarket ... all sorts.
How much money I have saved using XXX public charging
Diagnosing why/when my charger drops from 32AMPs to 16AMPs in the middle of the night
How often did X happen - e.g. battery heater come on, charge to over 100%, ...
What is my battery degradation - is it outside warranty limits?
Schedule something - e.g. battery to charge for an hour before leaving for work on cold mornings, car climate to come on [but only weekday mornings, only if parked at HOME, only if plugged in ...]
... the list is endless ...
 
  • Like
Reactions: SigRed12
Finally getting around to trying this out and running into an issue with Grafana and the InfluxDB datasource.

I've created a Debian 10.3 VM in Virtualbox on the Mac to do my testing with. I've gotten InfluxDB and Grafana and all the plug in modules created, have the apiscraper running and logging output in the terminal window like it's collecting data from the car.

I get logged into Grafana using the admin/admin account and try to add an InfluxDB datasource, but when I select the Save & Test link, I get a Bad Gateway error. The password I'm typing into grafana is the same password I set for the tesla user in InfluxDB (create user tesla with password '<password>'). Any suggestions on what I'm doing wrong?

Screen Shot 2020-02-17 at 11.50.09 PM.png


I'll also take a peek at the teslamate software mentioned in this thread to see if I can get that to work a little easier.
 
I feel I'm so close....but still so,far...need some help. So I have this setup on my rbpi3b+. I can see my position, and my charge level, but I can't get historical data..is this capable of that? ...and my thingy crashes... I wanna know where my wife went last night :) She also wants to know where I went last night afterwards :)

any help appreciated this in advance.
 
Anyone here still using this setup? Specifically, I'd like to know if this thing can get historical data...like the 90 day selection actually works, and how did you set it up? this.

@Redbrick, I don't use tesla-apiscraper (I just started using Teslamate about a month ago) but I believe most if not all of these types of applications work pretty much the same way in that they collect and log data going forward from the time that you started using the application. The data gets stored in a database which allows you to go back and see historical data and trends but only back to the point that you started using the application. So if you started using the application 7 days ago, you could go and look at the data for the past 7 days, but there is no way to go back and see the data for 8 days ago because it was never captured and saved into the database. To get the 90 selection you mentioned to actually view the last 90 days, you would have had to have the application up and logging over the past 90 days.

Hope that helps make sense of it all, although probably not what you were hoping to hear.
 
  • Informative
Reactions: f205v