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

Feature request - Make available in Home Assitant hassio #47

Closed lhomann closed 5 months ago

lhomann commented 6 months ago

Hi Is it possible to make this available to Home Assistant hassio installations. I have installed TeslaMate via https://github.com/matt-FFFFFF/hassio-addon-teslamate but is not able to add this TeslaMateAgile to my HA installation.

MattJeanes commented 6 months ago

Ooh, I like the idea of this! Especially given we have HA integration into this already it seems like a logical next step.

I'll take a look when I get a moment, but in the mean time you can run something like the Portainer addon in HA to run custom Docker containers and use it that way.

lhomann commented 6 months ago

Thank you for trying to look into this, and maybe put it on your roadmap. I will be happy to test this out. At the moment Portainer is unfortunately deprecated. I do not know how to work a round that.

MattJeanes commented 6 months ago

Ah okay, I can only recommend running it on another machine with docker for now then if you can't do that anymore, I will look at this when I can but I am super busy so I can't guarantee that it will be soon :)

lhomann commented 6 months ago

Hi Matt No hurry, I'm just happy that you like the feature request, and that it maybe someday be available.

tougher commented 6 months ago

I'm actually running it from "inside" Home Assistant currently. I start it manually via SSH. The biggest issue is that you have to install the dotnet runtime, which is wiped on reboots. I did try to build as self-constrained, but that is for some reason not enough. I don't think I have the knowledge to drive this feature, but I would like to help and test when needed, I'm already working on a fork to support data from Monta.

MattJeanes commented 6 months ago

Interesting, sounds like this would be useful to a few people. I haven't forgotten about this, just been a bit caught up you know how it is :)

I'll be sure to reach out if I need some testers, thank you for your offer

tougher commented 6 months ago

It was actually more straight forward than I initially thought, so I did take a stab at:

image

It's sort of just metadata for now, next step is a Dockerfile, but I will use this as inspiration: https://github.com/matt-FFFFFF/hassio-addon-teslamate/blob/main/Dockerfile

tougher commented 6 months ago

IT'S ALIVE! But config is obviously missing :)

image

I pushed my changes here: https://github.com/tougher/hassio-addon-TeslaMateAgile

MattJeanes commented 6 months ago

Ooh, vey nice! If you need anything from me please let me know, I'd be more than happy to link to this from the description once it's up and running, and help contribute if I make any changes in future that affect this.

lhomann commented 6 months ago

It is working!!! I'm using @tougher version. I'm very happy This is my config file:

database_user: username database_pass: password database_name: databasename database_host: 29b65938-postgres database_port: 5432 args:

Screenshot 2024-01-06 at 09 57 29
tougher commented 5 months ago

Sounds good @lhomann! I will test it more tonight.

I will also change the maintainer of the HA add-on, currently you are @MattJeanes https://github.com/tougher/hassio-addon-TeslaMateAgile/blob/main/repository.yaml :)

Another question for you guys: should the add-on follow the same version as TeslaMateAgile? After some thinking I guess not, since it might get its own bugfixes/features.

MattJeanes commented 5 months ago

Yeah it should have an independent version I think! You could bump it alongside when mine is bumped but they shouldn't necessarily be identical

tougher commented 5 months ago

I tested the FixedPrice and Energinet providers in my "prod" setup and don't see why the other providers should not work.

This is my current config taken straight from Home Assistant:

database_user: teslamate
database_pass: ****
database_name: teslamate
database_host: 29b65938-postgres
database_port: 5432
args:
  - TeslaMate__UpdateIntervalSeconds=3600
  - TeslaMate__GeofenceId=1
  - TeslaMate__LookbackDays=7
  - Logging__Console__FormatterName=simple
  - "Logging__Console__FormatterOptions__TimestampFormat=[HH:mm:ss]\u2009"
  - TeslaMate__EnergyProvider=Energinet
  - Energinet__Region=DK2
  - Energinet__Currency=DKK
  - Energinet__VAT=1.25
  - Energinet__FixedPrices__TimeZone=Europe/Copenhagen
  - Energinet__FixedPrices__Prices__0=00:00-06:00=0.1519
  - Energinet__FixedPrices__Prices__1=06:00-17:00=0.4556
  - Energinet__FixedPrices__Prices__2=17:00-21:00=1.3668
  - Energinet__FixedPrices__Prices__3=21:00-00:00=0.4556
  - TeslaMate__FeePerKilowattHour=1.30

The only thing that does not fully work as expected is the custom timestamp format on the logger. The space in the end is trimmed away because of how I load the arguments from yaml to exported variables. It's really not a dealbreaker, but I guess it could be fixed. In my own config you see above I made the workaround and added \u2009, which is not trimmed.

I will do the last changes (and update to 1.13) tomorrow and "ship" it.

Thanks a lot @MattJeanes for making this!

tougher commented 5 months ago

I made a 1.0.1 release of the add-on. I guess you can close this now :)

MattJeanes commented 5 months ago

Absolute legend! Thank you so much!

I've added a note into the README of this project referencing your repository.

Please let me know if there's anything that I can do to help you in future with this.