MattJeanes / TeslaMateAgile

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

UTC time issue #36

Closed PalleRaa closed 1 year ago

PalleRaa commented 1 year ago

First of all, thanks for the new 1.11.0 @marval

I was trying to calculate the cost for my most recent charge. It is Tesla Mate identified correctly to have started at 3AM DK time. image

My config is as simple as possible with no fixed prices added.

teslamateagile:
    image: mattjeanes/teslamateagile:latest
    restart: always
    environment:
    - DATABASE_USER=teslamate
    - DATABASE_PASS=secret
    - DATABASE_NAME=teslamate
    - DATABASE_HOST=database
    - TeslaMate__UpdateIntervalSeconds=10
    - TeslaMate__GeofenceId=4
    - TeslaMate__EnergyProvider=Energinet
    - Energinet__Region=DK2 # See below a list of all Energinet regions
    - Energinet__VAT=1.25 # Optional: VAT multiplier. In this example 25%
#    - Energinet__FixedPrices__TimeZone=Europe/Copenhagen # Optional: IANA (tz database) time zone code, used for below times
#    - Energinet__FixedPrices__Prices__0=00:00-06:00=0.29 # Optional: You can have as many as these as you need
#    - Energinet__FixedPrices__Prices__1=06:00-20:00=0.3983
#    - Energinet__FixedPrices__Prices__2=20:00-00:00=0.1432
    - Logging__LogLevel__Default=Debug

When it is calculating the cost I get the following in the log:

dbug: TeslaMateAgile.PriceHelper[0]
      Calculated charge cost for 01/08/2023 02:00:00 UTC - 01/08/2023 03:00:00 UTC (unit cost: 0.08645000500, fee per kWh: 0): 0.9237491879774529519465957432 for 10.68535725333333354864 energy
dbug: TeslaMateAgile.PriceHelper[0]
      Calculated charge cost for 01/08/2023 03:00:00 UTC - 01/08/2023 04:00:00 UTC (unit cost: 0.08460000, fee per kWh: 0): 0.9292778226959999640258240000 for 10.98437142666666624144 energy
dbug: TeslaMateAgile.PriceHelper[0]
      Calculated charge cost for 01/08/2023 04:00:00 UTC - 01/08/2023 05:00:00 UTC (unit cost: 0.03867500125, fee per kWh: 0): 0.1678530743541153746034887952 for 4.34009228000000063616 energy
info: TeslaMateAgile.PriceHelper[0]
      Calculated cost 2.02 and energy 26.01 kWh for charging process 363

It takes my 03:00-04:00 DK time and converts it ti 02:00-03:00UTC which is correct. However, when looking at a data dump from energidataservice I get the following:

image

So TeslaMateAgile says it pulls a cost of 0.0864500500 from 01/08/2023 02:00:00 UTC - 01/08/2023 03:00:00 UTC but the price is actually 0.03867500125. It seems that TeslaMateAgile thinks it gets the cost from 02:00 UTC to 03:00 UTC, but actually takes the cost from 00:00 UTC - 01:00 UTC.

marval commented 1 year ago

I would have to check this, but it seems it definitely seems wrong. To be honest I am always confused looking at the datetimes 😕

MattJeanes commented 1 year ago

Hey @PalleRaa, I've just made some fixes in the provider for this, the issue was that it was affected by your local timezone.

There is also a new required parameter of Energinet__Currency, check the README for more info on this.

The changes for this new version are:

Please try out the unreleased image version v1.11.1 and let me know if works better for you 😄

PalleRaa commented 1 year ago

Haleluja. It works!

Messed a lot with the fact that the fixed prices should be without VAT. But now it fits my manual calculations 1:1. This is absolutely great.

MattJeanes commented 1 year ago

Fantastic! I've just published that version now for everyone to enjoy, thanks for testing it! 🙂