Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Template - Vehicle - Tessie #17274

Merged
merged 2 commits into from
Nov 16, 2024
Merged

Add Template - Vehicle - Tessie #17274

merged 2 commits into from
Nov 16, 2024

Conversation

djfanatix
Copy link
Contributor

Tessie Template

Configured that it doesn't wake up the vehicle when polling. Interval can be set to 'always' and 1m.
Tessie server uses last available data when asleep or live data when vehicle is awake.

Tessie api can also be used to make a Tesla charger, not implemented now.

@andig andig added the vehicles Specific vehicle support label Nov 16, 2024
@andig
Copy link
Member

andig commented Nov 16, 2024

Tessie api can also be used to make a Tesla charger, not implemented now.

That would be great- happy to help!

@andig andig merged commit 512aca5 into evcc-io:master Nov 16, 2024
@manuelmrmorgado
Copy link

Amazing! Even better if you can use it with dumb chargers i/o Tesla fleet api and their recent limitations.

@djfanatix
Copy link
Contributor Author

@andig I am not really familiar with Go language, but how to combine the api calls into 1 api call? I tried a few things, but it always fails in test.
If not possible, never mind

@bill340
Copy link

bill340 commented Nov 17, 2024

It should definitly be possible to build a charger with the commands as described here.
I have one setup with the data from teslalogger and a bluetooth proxy on a raspberry.
That should all be possible to be replaced by tessi:
https://developer.tessie.com/reference/

But I am also not able to code that in the evcc.yaml

Who can help?

@djfanatix
Copy link
Contributor Author

I already have the charger working, that is not the problem.
I am struggling with the amount of api calls.

Or I have to rewrite everything in go language, or find a good way in yaml.
Otherwise tessie will block evcc soon

@bill340
Copy link

bill340 commented Nov 17, 2024

Can you share please?

@andig
Copy link
Member

andig commented Nov 17, 2024

@djfanatix evcc should respect ETag cache headers. If you want more you can statically set cache to the desired value, see http.go.

@bartashevich
Copy link

One thing confuses me in this, if you have chargeEnable, why isn't there chargeDisable?

How will EVCC will know how to stop charging?

@bill340
Copy link

bill340 commented Nov 18, 2024

I have the part for "enable" like below.
So if it is not "enable", it will stop charging.

enable:
source: http
uri: "http://192.168.2.110:8080/api/1/vehicles/LRWYGCEKXNCxxxxxxx/command/{{if .enable}}charge_start{{else}}charge_stop{{end}}"
method: POST
body: ""

@bartashevich
Copy link

Well, that make sense. But I'm interested in a file in this Pull request for Tessie. I'm experimenting.

@bill340
Copy link

bill340 commented Nov 18, 2024

Me too... Would be very interested if someone got a custom charger with tessie already running.

@djfanatix
Copy link
Contributor Author

Yeah I got it somehow working, but is too sketchy
It is on the limits of the http api

maybe I should rewrite in go, or clone the tesla files and replace the endpoints with Tessie.

I will try to post tomorrow the code

@bill340
Copy link

bill340 commented Nov 18, 2024

Yes, let me have a look.
I have it running with data coming from teslalogger and commands sent via a blutooth proxy.
So maybe we can get something working by comparing...

@bartashevich
Copy link

I guess something like this should do it, right?

  chargeEnable:
    source: http
    uri: https://api.tessie.com/{{ .vin }}/command/{{if .chargeenable}}charge_start{{else}}charge_stop{{end}}?retry_duration=40&wait_for_completion=true
    headers:
      Authorization: Bearer {{ .token }}
    method: POST

@djfanatix
Copy link
Contributor Author

maybe,

you can see my code at, but I changed a few parameters for testing, so don't rely on it

https://github.com/djfanatix/evcc/edit/master/templates/definition/charger/tessie-charger.yaml

@bartashevich
Copy link

What physical charger do you use? I have Tesla Wall Connector 3

@bill340
Copy link

bill340 commented Nov 18, 2024

I use a Tesla Wall Connector 1, that is not able to be controlled by anything...
I just looked at our code. The problem is, to detect if you charge at home or not we used the location in the past.
Here is my charger with the bluetooth proxy and teslalogger.
I guess in yours we need the location as well...

chargers:

@djfanatix
Copy link
Contributor Author

depends on the use case :-)

For example:

  • someone could you use to charge at a vacation house with dynamic rates.
  • in Belgium we can do 'energy sharing', use your exported energy at an other location, so again vacation house, with your home solar

@bill340
Copy link

bill340 commented Nov 18, 2024

Ok, but do you really want the same behaviour at any location you are charging?
Can we somehow get the location like here:
https://developer.tessie.com/reference/get-location
And only charge when at the specific location, e.g. "home"?

@bill340
Copy link

bill340 commented Nov 18, 2024

Stupid question...
How can I test your template, as charger templates are not supported in the web configuration interface?
I have mine in the evcc.yaml

@djfanatix
Copy link
Contributor Author

This file is not working for the moment.

If you want to test you need to build a docker image of your fork

@djfanatix
Copy link
Contributor Author

This template (when inserting in your EVCC.yaml) will work.
When I have more time I will try to integrate it, but not possible at the moment
replace VIN and TOKEN

https://github.com/djfanatix/EVCC_templates/blob/main/tessiecharger.yml

@bill340
Copy link

bill340 commented Nov 19, 2024

Great, thank you so much. Will try asap.
This is now without the location based charging and will be used everytime I charge, regardless where it is,, right?

@bill340
Copy link

bill340 commented Nov 19, 2024

It works really good so far.
Found just one issue:
After charging stopped, the car is shown as not plugged in.

However evcc takes over charging steering now regardless where I charge.
Can you somehow implement to query the location and only control charging when e.g. saved location is "home" ?

@djfanatix
Copy link
Contributor Author

It is just a template so not part of evcc, so you can adjust whatever you like

@GrimmiMeloni
Copy link
Collaborator

@GrimmiMeloni would this be something you'd be interested in digging in?

Sure. I assume @djfanatix can first try your suggested change in escape syntax. If that does not work, we can look further.

@djfanatix
Copy link
Contributor Author

djfanatix commented Nov 23, 2024

I tried:

uri: https://api.tessie.com/{{ .vin }}/command/{{ if {{.enable}} }}start{{ else }}stop{{ end }}_charging?retry_duration=40&wait_for_completion=true

uri: https://api.tessie.com/{{{{ .vin }}}}/command/{{{{ if {{{{.enable}}}} }}}}start{{{{ else }}}}stop{{{{ end }}}}_charging?retry_duration=40&wait_for_completion=true

uri: https://api.tessie.com/{{{{ .vin }}}}/command/{{{{ if .enable }}}}start{{{{ else }}}}stop{{{{ end }}}}_charging?retry_duration=40&wait_for_completion=true
None of them work

@andig
Copy link
Member

andig commented Nov 23, 2024

Vin needs 2 braces since itd stativ, the rest 4. then a trace log might give insight.

@andig
Copy link
Member

andig commented Nov 23, 2024

If .enable is a string comparison, hence

if (eq .enable „true“)

@djfanatix
Copy link
Contributor Author

This

uri: https://api.tessie.com/{{ .vin }}/command/{{{{ if .enable }}}}start{{{{ else }}}}stop{{{{ end }}}}_charging?retry_duration=40&wait_for_completion=true

[openwb] INFO 2024/11/23 12:57:19 connecting evcc-1781395867 at tcp://localhost:1883
--- FAIL: TestTemplates (0.00s)
    --- FAIL: TestTemplates/tessie-charger (0.00s)
        render_testing.go:70: 
        render_testing.go:70: template: eebus.tpl:48: unexpected "{" in command
FAIL

the second try:

uri: https://api.tessie.com/{{ .vin }}/command/{{ if (eq .enable "true") }}start{{ else }}stop{{ end }}_charging?retry_duration=40&wait_for_completion=true

[tessiecharger] TRACE 2024/11/23 14:12:06 POST https://api.tessie.com/LRW3E7FS1RC056456/command/stop_charging?retry_duration=40&wait_for_completion=true
[tessiecharger] TRACE 2024/11/23 14:12:08 true -- { "result": true }

@andig
Copy link
Member

andig commented Nov 23, 2024

Looking at helm/helm#2798 please try

uri: https://api.tessie.com/{{ .vin }}/command/{{`{{ if (eq .enable "true") }}start{{ else }}stop{{ end }}`}}_charging?retry_duration=40&wait_for_completion=true 

This will make the init template render

{{ if (eq .enable "true") }}start{{ else }}stop{{ end }}

as part of the URI which the runtime template wir parse/execute again.

@djfanatix
Copy link
Contributor Author

djfanatix commented Nov 24, 2024

@andig Thank you! that is that magic trick :-)
with a slight modification (.enable is a boolean in the end)

uri: https://api.tessie.com/{{ .vin }}/command/{{`{{ if .enable ) }}start{{ else }}stop{{ end }}`}}_charging?retry_duration=40&wait_for_completion=true 

@andig
Copy link
Member

andig commented Nov 24, 2024

This template stuff is tricky but powerful.

with a slight modification (.enable is a boolean in the end)

You're right. .enable does not come from the template but is generated by the runtime and hence a typed value.

@djfanatix
Copy link
Contributor Author

djfanatix commented Nov 24, 2024

Yes, I am still doubting to implement it.
Everything works fine including location based charging, but:

2 questions related to api based chargers.

  • If I stop charging, the car is disabled for future charging. (so I will go to a public charger it will not charge without enabling in the app)
  • EVCC last current command is retained in the car, so same thing for next charging session.

@bill340
Copy link

bill340 commented Nov 24, 2024

That's strange... I do not have these issues with my teslalogger-api-based charger... So I think it is not a general problem with an api-based charger... (although I only use the data from teslalogger and send the commands via ble-proxy)
Can I somehow test your template?

@djfanatix
Copy link
Contributor Author

If you use home assistant addon:

Add addon:

https://github.com/djfanatix/hassio-addon

It uses evvctest.yaml instead of evvc.yaml

Config:


- name: tessiecharger
  type: template
  template: tessie-charger
  vin:
  token:
  maxcurrent: 16
  location: home #write always for always or a random name and lat lon below to specify a custom location
  lat: 
  lon: 

@bill340
Copy link

bill340 commented Nov 24, 2024

I cannot use the home assistant addon, as I run evcc container version on a seperate machine...
Can you provide what I need to get into my evcc.yaml to test the tessiecharger?
Or is it already in the nightlys and I can use above in my evcc.yaml?

@djfanatix
Copy link
Contributor Author

Try the docker image

djfanatix/evcc

@bill340
Copy link

bill340 commented Nov 24, 2024

Sorry... My mistake. I'm not running evcc in docker. It is an installation on a linux machine.
Nay chance to get your template in there, or can you provide the code to use in evcc.yaml like here:
https://github.com/djfanatix/EVCC_templates/blob/main/tessiecharger.yml
But I think it is still old without location, etc...

@djfanatix
Copy link
Contributor Author

The plan is not to make a template, but integrate it in evcc, it is different code.

I will try maybe this evening to get it in nightly

@djfanatix
Copy link
Contributor Author

@bill340
Copy link

bill340 commented Nov 24, 2024

Ok, and where do I need to put the above file then?

@bill340
Copy link

bill340 commented Nov 27, 2024

Is there any news on this? Would be so happy to use the tessi charger instead of teslalogger with ble-proxy...

@djfanatix
Copy link
Contributor Author

I made a pull request, so it can go to a nightly

You also edit the template to make it work in the evcc.yaml but I will not do this.

@bill340
Copy link

bill340 commented Nov 29, 2024

Thanks very much!!
But I think 1 check failed, so it is not in nightly...

@djfanatix
Copy link
Contributor Author

I just read this:

https://developer.tesla.com/en_US/

And

https://www.reddit.com/r/teslamotors/s/QGiqsagvuj

So if Tesla starts charging money for their API, it makes no more sense to develop the Tessie functionality

@bill340
Copy link

bill340 commented Nov 30, 2024

That is exactly the point why it is so important to get the Tessie functionality, because Tessie already uses this paid API and all the others won't work anymore sooner or later...

@djfanatix
Copy link
Contributor Author

djfanatix commented Nov 30, 2024

No, if you read the reddit topic where the Tessie developer is commenting: if this is implemented it would be 60m dollars yearly for him.

So maybe this is the end of Tessie in the current form.
Same for the Tesla integration in EVCC

Maybe Tesla ble is the future

@bill340
Copy link

bill340 commented Nov 30, 2024

Don't know from when the reddit topic you mention is, but on their website they say they already use the paid tesla fleet api.
So everything will be fine with tessie in my opinion:

https://developer.tessie.com/reference/access-tesla-fleet-api

"Premium paid access to Tesla Fleet API at no additional cost"

@djfanatix
Copy link
Contributor Author

That's 4 months old info. The tariffs were announced 2 days ago.

I'v put the Tessie charger on hold until we know how to fix this. We can't wake or send commands without limits anymore. (or from 2025)

Maybe we will need a personal Tesla API code and use the streaming api instead of this one

@bill340
Copy link

bill340 commented Nov 30, 2024

Thats really sad...
But for my understanding, Tessie uses the paid tesla api to access.
We pay tessie to use it.
So there should not be any problem with the tessie integration like this...
Why don't we just try it?
Can you just put it in nightly, so that I could at least test it a bit?

@bill340
Copy link

bill340 commented Nov 30, 2024

But you mentioned tesla ble to be the solution...
Do you see any way there to use it for that kind of charger without any other third party api like tessie or teslalogger?
For now I always need to use teslalogger in combination with tesla ble proxy to get data like position, etc. from teslalogger that ble proxy does not provide.
But actually if we only use the ble proxy we probably don't even need the position anymore, because it only work when within bluetooth range anyhow.
What do you think?

@djfanatix
Copy link
Contributor Author

djfanatix commented Nov 30, 2024

I think to avoid the high costs, BLE is the way to go, but I know nothing about BLE, so someone will have to implement this.

EVCC's own Tesla api will need a rewrite or it will cease to exist!

@bill340
Copy link

bill340 commented Nov 30, 2024

Yes, I think you are right...
Do you think we could use tessie to get the data that we need, location. etc...
And then use BLE to send the commands?
I have the BLE running at the moment to send the commands and get the data from teslalogger, so this should be working with tessie too then...

@bill340
Copy link

bill340 commented Nov 30, 2024

Here is the official answer from Tessie developer. So we definitly should be fine without any problems...

Considering Tesla's new pricing, if you use our data endpoint (https://developer.tessie.com/reference/get-state) and issue commands at a reasonable rate (e.g. as needed) you should be fine.

This data endpoint intelligently merges Fleet API data with new direct vehicle streaming data in a backwards compatible way and will not be subject to Tesla's prices and limits.

James

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vehicles Specific vehicle support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants