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

[aWATTar] include fees in calculation #17557

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tl-photography
Copy link
Contributor

The current calculations are a bit off and the config is not able to compensate for this.

This MR would include the correct fees for the service directly in the calculation.

There seems to be a little diverge:
In DE the 3% fee seems to be calculated directly from the net price, while in AT the absolute value of the net prices is used to calculate the fee.

Maybe there is another way of reflecting that in config, I'm open for suggestions.

@tl-photography tl-photography force-pushed the feature/awattar-correct-price-calculation branch from c2e3634 to c81b979 Compare October 13, 2024 12:20
@lsiepel lsiepel added the enhancement An enhancement or new feature for an existing add-on label Oct 13, 2024
@tl-photography
Copy link
Contributor Author

Con someone confirm the calculation for Germany? I'm not sure anymore if the absolute value is used or not.

netTotal += Math.abs(netTotal) * 0.03;
} else if ("DE".equals(country)) {
// add 3% fee for the aWATTar service (Ausgleichskomponente)
netTotal = netTotal * 1.03;
Copy link
Contributor

@lsiepel lsiepel Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AT and DE both add 3%, why are you using two different ways of doing the same? Only in a negative case it would be different. For example:
if nettotal is 105, both will be 108,15
if nettotal is -105, AT will be 101.85 and DE will be -108,15 (i guess this is wrong, as the fee that you have to pay to awattar, gives you extra in return?)

Copy link

@Herschdorfer Herschdorfer Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not clear ro me if they are really doing the same.
I mentioned this in the description and added a commet if someone can confirm.

I would find it strange if they would not use the absolute value to calculate the 3% fees, but i wasn't sure.

The current caculations are like this

DE:

 20 * 1.03 =  20.6
-20 * 1.03 = -20.6

AT:

 20 + |20|  * 0.03 =  20
-20 + |-20| * 0.03 = -19.4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We share the same view on this. Hopefully somebody from DE can confirm.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am no longer an aWATTar customer, so I can't tell finally, sorry. But however the logic looks like, I recommend to make the percentage configurable for the binding, similar to the VAT. Otherwise, if aWATTar changes the factor from 3% to 4% a new version of the binding would be necessary.

Copy link
Contributor

@jlaur jlaur Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to add it at all then, rather than using a transformation? For VAT, there is VAT Transformation Service. This seems like a simple case of multiplying a value?

I'm not sure what is the best fit, but could even be done inline. Otherwise there is https://docs.smarthomej.org/4.2.0/org.smarthomej.transform.math.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it can be made this way.
The only thing that's missing would be to get an absolute value.

@tl-photography
Copy link
Contributor Author

i now changed it that way that there is an addtional parameter that can be used as a service fee. this will be cacluated from the absolute value.

@@ -12,6 +12,8 @@ bridge-type.config.awattar.bridge.basePrice.label = Base price
bridge-type.config.awattar.bridge.basePrice.description = Specifies the net base price per kWh
bridge-type.config.awattar.bridge.timeZone.label = Time zone
bridge-type.config.awattar.bridge.timeZone.description = Time zone to apply to the hour definitions. Default CET aligns to the aWATTar API
brifge-type.config.awattar.bridge.serviceFee.label = Service fee
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo "bridge".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to wait for fixing this ypo. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just put that there to remember.. I'm case ther might be more changes needed... :)

@tl-photography
Copy link
Contributor Author

Hi,

Any progress on this? :)

@lsiepel
Copy link
Contributor

lsiepel commented Nov 10, 2024

As it defaults to the current behavior (serviceFee = 0), it can be merged as is. There is also a trasnformation possible that the user can use to calculate the same and or adjust accordingly to their specific situation. I don't have a specific preference. But as @jlaur brought this up, he might have more to say about it.

@jlaur
Copy link
Contributor

jlaur commented Nov 10, 2024

There is also a trasnformation possible that the user can use to calculate the same and or adjust accordingly to their specific situation. I don't have a specific preference. But as @jlaur brought this up, he might have more to say about it.

IMHO adding configuration parameters to add VAT, fees, etc. is bloat when there are more elegant ways to do it:

There is also some related context here: https://www.openhab.org/addons/bindings/energidataservice/#total-price

In any case, I'm not binding maintainer, and this is a small thing, so maybe having a "built-in" calculation outweights the inconvenience of having to configure something additional outside of the binding for this case. So please go ahead if @Wolfgang1966 approves - and @J-N-K also did some recent work on this binding, and might have an opinion as well.

@tl-photography
Copy link
Contributor Author

There is also a trasnformation possible that the user can use to calculate the same and or adjust accordingly to their specific situation. I don't have a specific preference. But as @jlaur brought this up, he might have more to say about it.

IMHO adding configuration parameters to add VAT, fees, etc. is bloat when there are more elegant ways to do it:

There is also some related context here: https://www.openhab.org/addons/bindings/energidataservice/#total-price

In any case, I'm not binding maintainer, and this is a small thing, so maybe having a "built-in" calculation outweights the inconvenience of having to configure something additional outside of the binding for this case. So please go ahead if @Wolfgang1966 approves - and @J-N-K also did some recent work on this binding, and might have an opinion as well.

Well ok, then there might be a way of adding this tax in config. But to be honest, this is not very convenient, looking at the example configuration (I haven't checked in detail now).

I wanted to add a easy way of having this specific tax to the price, without having to configure a lot.

But I'll not insist on this, so if it's not desirable, I'll just close the PR and try to add it with time series.

@tl-photography
Copy link
Contributor Author

@jlaur could you maybe give an example of the usage of transformation service?
I checked and i do not see a way of adding the percentage of the absolut value...

@jlaur
Copy link
Contributor

jlaur commented Nov 19, 2024

could you maybe give an example of the usage of transformation service?

TBH, I've struggled at lot with this because I never used script transformations before. First success was using JavaScript and UI configuration. In $OPENHAB_CONF/transform/test.js:

(function(data) {
  return Quantity(input).multiply('1.03').toString()
})(input)

Linked item:

image

Compared to "raw" item with no transformation:

image

I also tried the SmartHome/J MULTIPLY transformation from the Math transformation package, but it doesn't support time series.

@tl-photography
Copy link
Contributor Author

Ah thanks, I'll give it a shot and try to use it. If you don't mind I would, if I succeed, change the MR to only change documentation adding this.

@Wolfgang1966
Copy link

Also here sorry for the delay. Changes look good to me, just please correct the typo.

Sorry, I am no longer customer of aWATTar, so I don't know whether a service fee is now part of the price in Germany.

General thought:

Originally I thought it would be a good idea to do all the calculations to make the binding easy to use for the aWATTar customers. I am no longer sure if this decision was correct (or more specifically: I tend to think that it was not the best idea in the first place at all). I was not aware of transformations, but I was aware of Rules which could be used to achieve the same results. But computing the gross price in the binding means now, that everytime aWATTar changes the pricing model the binding needs to be adapted too, as we see here.

Strictly speaking my price calculation was not complete from the very beginning, as it did not respect the pricing limits that existed at that time (+/-20ct at the beginning, +/-40ct later). Also, the price calculation is not needed to determine the cheapest hours, which requires more complex calculations and therefore is in my opinion the more relevant part of the binding.

So how about declaring the net and gross price calculation as deprecated and open the door to remove them sometimes in the future or at least no longer adapt them if the pricing model changes again?

Signed-off-by: Wolfgang Klimt <[email protected]>
Copy link

@Wolfgang1966 Wolfgang1966 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after correcting the typo :-)

Thanks

Wolfgang

@tl-photography
Copy link
Contributor Author

LGTM after correcting the typo :-)

Thanks

Wolfgang

Thanks :)

@lolodomo lolodomo added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Dec 3, 2024
@tl-photography
Copy link
Contributor Author

tl-photography commented Jan 9, 2025

@jlaur

i have tested the transformation services without any success.

I added awattar.js

(function(data) {
    return data
  })(input)

but i only get as error in the logs:

2025-01-09 20:32:23.975 [ERROR] [.module.script.profile.ScriptProfile] - Failed to process script 'awattar.js': (function(data) {
    return data
})(input)

Either the transformation service docu (https://www.openhab.org/docs/configuration/transformations.html#js) is wrong or somthing is broken...

EDIT:

Sorry had forgotten to add JS again in my new installation.

Anyway, after 3h of fiddeling I was not able to get this to work...

@SKLD-OH3
Copy link

the update is on the next day not working. only the action to save (again) the binding is starting receive.

@tl-photography
Copy link
Contributor Author

@SKLD-OH3 I don't think this is the correct place here.

Did you build this branch or do you have an issue with the current version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants