MattJeanes / TeslaMateAgile

Integration to automatically fill in prices for charge data captured by TeslaMate for smart energy providers
MIT License
76 stars 9 forks source link

Enhancement / Feature Upgrade - integration of EMS evcc #45

Closed mailkluge closed 8 months ago

mailkluge commented 8 months ago

Idea is to integrate evcc. Evcc provides various data via MQTT including a price. Enhancement is that currently solar power (=0 costs) is not dynamically possible with your implementation. With integration of evcc, evcc calculates the price recognizing dynamic tariffs like Tibber, too and provides it via mqtt. Your application could fetch the current calculated price recognizing solar and grid mix and pushed it into teslamate database.

MattJeanes commented 8 months ago

Hey, I'm assuming you're talking about this project: https://github.com/evcc-io/evcc

From what I can see on my brief look at the API (might be wrong potentially) I can't see a way to get the information TeslaMateAgile needs to calculate prices over a given time range.

This project works after the fact and not in realtime which means it relies on historical data that can be queried later, which works well for dynamic energy tariffs but not so well for MQTT/REST based realtime feeds.

My recommended workaround for such a use case would be to stream the current energy price as an entity into Home Assistant and let that keep track of the history, which you can then use in TeslaMateAgile with the Home Assistant integration.

I could be reading their documentation wrong though, I've literally only just looked at it now for 5 minutes so if they do have the ability to read historical data for prices via an API then we can have another look.

It is also possible to implement support for realtime price feeds but that would make this project a lot more complicated as it would then need to store it's own data and state, and realistically most people who are using this are smart home enthusiasts who probably already have Home Assistant setup, not to mention having to support many different providers or the flexibility to configure your own which is something HA excels at doing already.

Hope that helps!

mailkluge commented 8 months ago

Hey Matt Thx for your answer. Yes, I think you are right. I tried TeslamateAgile today for the first time and I understood your concept. EVCC calculates a session price and the price is available via MQTT. A session is the time the charging plug is connected to the car. For this duration the price is calculated by evcc recognizing solar and grid power mix and dynamic tariffs. But I understand what you wrote and it is different how teslamate works (session is between start and stop charging). Theoretically evcc includes a database where the prices are stored but these information is not available via API. And you had to map the entries in teslamate to a session in evcc…could be error-prone. thx for the hint with Home Assistant - maybe I will give it a try.