MattJeanes / TeslaMateAgile

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

Problem going from Octopus Agile to Go #18

Closed IMgoRt closed 3 years ago

IMgoRt commented 3 years ago

Hi Matt, I was on Octopus Agile which worked correctly, I've now moved to Go Faster. I have edited the yml as follows:

      - TeslaMate__UpdateIntervalSeconds=300
      - TeslaMate__GeofenceId=1
      - TeslaMate__Phases=1
      - TeslaMate_EnergyProvider=FixedPrice
      - FixedPrice__TimeZone=Europe/London
      - FixedPrice__Prices__0=00:00-20:30=13.8
      - FixedPrice__Prices__1=20:30-23:30=4.5
      - FixedPrice__Prices__2=23:30-23:59=13.8

but I receive the following error:

Microsoft.Extensions.Options.OptionsValidationException: DataAnnotation validation failed for members: 'RegionCode' with the error: 'The RegionCode field is required.

If I add in the region_code field I previously had then the pricing is derived from the Octopus API lookup ignoring the FixedPrice option.

Thanks

MattJeanes commented 3 years ago

You look to only have one underscore in the environment variable for EnergyProvider so TeslaMateAgile is defaulting to Octopus Agile integration, it should be TeslaMate__EnergyProvider

MattJeanes commented 3 years ago

Additionally the prices configuration should wrap all the way around 24 hours so set that last one to 00:00 instead of 23:59 🙂

IMgoRt commented 3 years ago

You look to only have one underscore in the environment variable for EnergyProvider so TeslaMateAgile is defaulting to Octopus Agile integration, it should be TeslaMate__EnergyProvider

So it was just luck that it worked previously ;-)

IMgoRt commented 3 years ago

Additionally the prices configuration should wrap all the way around 24 hours so set that last one to 00:00 instead of 23:59 🙂

I wasn't sure

IMgoRt commented 3 years ago

Thanks Matt, closed due to poor eyesight

MattJeanes commented 3 years ago

Glad I could help! As an additional tip you only actually need 2 price configurations for this scenario as the times can go beyond midnight, in your case it could be:

      - FixedPrice__Prices__0=23:30-20:30=13.8
      - FixedPrice__Prices__1=20:30-23:30=4.5

It will work perfectly fine how you have it now just an fyi 🙂

IMgoRt commented 3 years ago

Glad I could help! As an additional tip you only actually need 2 price configurations for this scenario as the times can go beyond midnight, in your case it could be:

      - FixedPrice__Prices__0=23:30-20:30=13.8
      - FixedPrice__Prices__1=20:30-23:30=4.5

It will work perfectly fine how you have it now just an fyi 🙂

I tried that originally, but it wasn't working for the lack of an underscore

IMgoRt commented 3 years ago

OK, something's gone horribly wrong, i get the cost calculation returning the following:

Calculating cost for charges 04/13/2021 19:46:13 UTC - 04/13/2021 22:02:46 UTC 
Calculated cost 125.29 and energy 16.78 kWh for charging process 275

Which gives an effective rate of 7.467/kWh

That's using:

      - FixedPrice__Prices__0=23:30-20:30=13.8
      - FixedPrice__Prices__1=20:30-23:30=4.5
MattJeanes commented 3 years ago

Hmm, I'm assuming this is probably a timezone issue (https://xkcd.com/1883/ 😁)

The charging times there are marked as UTC, which would make them 20:46 -> 23:02 BST, which makes the charge completely within the range of the 4.5p/kWh cost but it looks like it's calculating it as if your cost is 19:46 -> 22:02 BST which would result in approximately that cost.

Would you be able to export the relevant data from the charging_processes and charges tables for this charging session and send it to me? Check out the troubleshooting section of the README for a little more info on how to access the database if you're not sure. I also noted in this comment how to do it as well https://github.com/MattJeanes/TeslaMateAgile/issues/17#issuecomment-772895618

There is no personal information in those tables as location data for example is stored in a different table but be sure to read the output before sending it over just in case!

I'll use the data to replicate the issue and prepare a fix, and if you're happy include it in the unit tests for this project.

IMgoRt commented 3 years ago

Hmm, I'm assuming this is probably a timezone issue (https://xkcd.com/1883/ 😁)

The charging times there are marked as UTC, which would make them 20:46 -> 23:02 BST, which makes the charge completely within the range of the 4.5p/kWh cost but it looks like it's calculating it as if your cost is 19:46 -> 22:02 BST which would result in approximately that cost.

Would you be able to export the relevant data from the charging_processes and charges tables for this charging session and send it to me? Check out the troubleshooting section of the README for a little more info on how to access the database if you're not sure. I also noted in this comment how to do it as well #17 (comment)

There is no personal information in those tables as location data for example is stored in a different table but be sure to read the output before sending it over just in case!

I'll use the data to replicate the issue and prepare a fix, and if you're happy include it in the unit tests for this project.

Sent, more than happy to help/give back to the community

MattJeanes commented 3 years ago

Thank you very much! I have tracked down the issue and fixed it, now released with version v1.5.1

Please update your TeslaMateAgile, and set the cost for this charge (and any other affected charges) in the charging_process table to NULL and it should pick them back up within 5 minutes!

With your provided data I calculated a cost of 75.5p with 16.78kWh of energy, which comes out to 4.5p/kWh.

Let me know how it goes, fingers crossed everything works perfectly!

IMgoRt commented 3 years ago

Thank you very much! I have tracked down the issue and fixed it, now released with version v1.5.1

Please update your TeslaMateAgile, and set the cost for this charge (and any other affected charges) in the charging_process table to NULL and it should pick them back up within 5 minutes!

With your provided data I calculated a cost of 75.5p with 16.78kWh of energy, which comes out to 4.5p/kWh.

Let me know how it goes, fingers crossed everything works perfectly!

Thanks Matt, tested and all working

Thanks for your great work and support

MattJeanes commented 3 years ago

That's great to hear! By the way I'll be publishing another new version shortly as all of this has reminded me to upgrade to .NET 5!