myTselection / MyEnergy

Home Assistant custom component HACS integration to Belgium MijnEnergie.be (MonEnergie.be) sites to compare and save on your electricity and gas prices in Belgium,
https://hacs.xyz/
MIT License
12 stars 1 forks source link

Add option to retrieve tariff from selected(current) provider #12

Open Jurgen-DOUCHY opened 10 months ago

Jurgen-DOUCHY commented 10 months ago

It would be useful to retrieve also the tariff for the current provider selected in the configuration. To verify the current tariff and to compare to the least expensive one.

myTselection commented 10 months ago

Not sure if this would always be possible. Your current contract may no longer be listed and different contracts exist for the same provider...

Jurgen-DOUCHY commented 10 months ago

Not sure if this would always be possible. Your current contract may no longer be listed and different contracts exist for the same provider...

True, but if available, show, otherwise null.

TekFan commented 9 months ago

At first, I thought this was the answer to my quest for current price to feed the energy dashboard. But I was disappointed to discover that the value received was not from the provider I gave in the config, but for the cheapest one at the moment, which is obviously useless for that purpose. In fact, I then don't understand why we have to give the provider in the first place ?

So this integration is of no use to me atm, unless, indeed, the current provider tariff (or at least the closest based on the config) is added in the future. That would be awesome.

myTselection commented 9 months ago

This was not build to follow rates of a specific provider. who cares about a provider if you can switch very easily ;) This was build, as is the my energy site, to find the cheapest contract on the market...

This site can't be used to know your current provider tariff rates, as these rates may change every day for new customers, while other rates may apply within your own specific contract.

The site will consider your current provider to find the cheapest offer. Only when switching providers you may get access to promotions as a 'new' customer.

myTselection commented 9 months ago

Yet, I'd suppose you could still use the site and integration to know the current applicable fixed cost rates (which are independent of the provider).

TekFan commented 9 months ago

This was not build to follow rates of a specific provider. who cares about a provider if you can switch very easily ;) This was build, as is the my energy site, to find the cheapest contract on the market...

Yes, I get that now, but this is not clear from the description, hence the confusion.

This site can't be used to know your current provider tariff rates, as these rates may change every day for new customers, while other rates may apply within your own specific contract.

Well, I found my contract in the list and prices seem ok to me, so I thought the integration could be tweaked to find it by reference instead of picking the top of the list.

The site will consider your current provider to find the cheapest offer. Only when switching providers you may get access to promotions as a 'new' customer.

I get that too. My expectations were too high. I really wish some site could give us our actual provider prices because it's almost impossible to calculate from the providers own site. Getting the cheapest promo at a specific time is nice, but kind of limited if you have nothing to compare it to. In my case for instance, the cheapest price is not worth the hassle to switch, but I almost had a headache by doing all the calculations. And, sure, I should put the formula in an excel sheet for next time, but even finding the correct input data is a hassle. And that would not put it automatically in the energy dashboard anyway.

myTselection commented 9 months ago

Thx for the feedback! I've updated the readme to make it a bit more clear it's fetching the cheapest current market rate.

What I did: I defined a local input_number var in which I kept the total price (€/kWh incl promo) of the contract for which I subscribed at some point. This can then be compared with the myenergy sensor price in €/kWh incl promo, eg in a graph. This allows to get a rough idea when you should consider switching when these value differ a lot. Yet, other promo criteria will need to be taken into account too (eg most promo are only fully attributed if you stayed at least 1 year).

Jurgen-DOUCHY commented 9 months ago

On second thought, MyEnergy does not have all energy providers in its comparison. Unlike VREG, MyEnergy is not a government agency, but a for-profit company. So all paying suppliers are allowed in the comparison.

That implies that there are also many suppliers not in the comparison and so the cheapest supplier is simply the cheapest paying one.

Actually, the plugin would only become really useful once we can use the data from the vreg.

myTselection commented 9 months ago

I agree! But initially I tested the v-test VREG comparison and didn't get good results out of it. Many promotions are only available when ordered through the mijnenergie site and so far I always had better rates as via VREG.

I'll see if adding V-Test over time would be possible too. Having both might even be bette ;)

danito commented 8 months ago

My 2cents: Someone should oblige all companies to allow their users to connect to an API with their prices. I just found out that Engie uses an Restfull API to show you your tariff, but have to find out how to use this. https://www.engie.be/api/engie/be/ms/pricing/customer/v1/business-agreements/xxxxxxxxx/energy-prices?maxGranularity=MONTHLY You need to be logged into the site (and post a Bearer token in the header). That's the Request:

HTTP/2 200 OK
content-type: application/json
content-length: 4307
x-content-type-options: nosniff
x-xss-protection: 0
cache-control: no-cache, no-store, max-age=0, must-revalidate
pragma: no-cache
expires: 0
strict-transport-security: max-age=31536000 ; includeSubDomains
x-frame-options: DENY
date: Wed, 07 Feb 2024 17:09:20 GMT
x-trace-id: a29a00dc-ed31-4b26-bd77-bb308497c0b0
vary: Origin
access-control-allow-credentials: true
x-cdn: Imperva
x-iinfo: 11-20009484-XXXXXXXXPNNN RT(1707325703409 56128) q(0 0 0 -1) r(1 1) U16
X-Firefox-Spdy: h2
GET /api/engie/be/ms/pricing/customer/v1/business-agreements/XXXXXXXXX/energy-prices?maxGranularity=MONTHLY HTTP/2
Host: www.engie.be
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Accept: application/json
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://www.engie.be/fr/espace-client/situation/prix-%C3%A9nergie/?ebl_location=ca.dashboard&ean=541448920704813628_ID1
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJZeV9CX2s1TDlHV2tfcVNwaEJscjZUYUJZNEFXbjQ2a2dlMUtfMEJtckswIn0.eyJle...LfgfmM2PVWKo_iph7w_Tn3QyOuY0YDAmEjTPQIuEhKUFfsX7o3rfJShR5qThl7iQwDLl0VcbHYe28d3VrXahjcqFnD7yJufBBKm3k3NWJ6WZPZK5wqi1APTWdUYSH1ZaLAHFf2xV6u4wkKFLQHk4PY99jMc-jGu3Vif1-eSbwkVhIlXre6jNs3KCxILvHytYvrXIBdi4HJ3BeZn91KuSefaUUnVzBYpX0NchdKXCxEjCA-Q
x-site-segment: residential
x-site-language: fr
traceparent: 00-9743876f6866b808e182c12f223dd12d-6f4cb77c09355395-01
DNT: 1
Connection: keep-alive
Cookie: JSESSIONID=E65DE4EE9099C1517EA15EF6EDD8ECBE; csrf=YMxor5f2egMwqDHwr9ZLVOIrftSAICLW8gM0AFrDQfR407FTpO8ThIhlP4hT24jl-b0qAMMCnX5VJZ1wSmjWyQ:AAABjYSKx2I:poapx3QQDiGQogZBoOUMBw; _ga_sessionParams=gclid: undefined | source/medium: undefined/undefined | campaign: undefined; OAuth_Token_Request_State=f78aca13-4700-48c5-9bb9-f48270c09d79; contractAccountId=002209554803; limit=32.32036162242752; visid_incap_2131963=yxMqr1BPTcOazHLnZxbBnAe5w2UAAAAAQUIPAAAAAACLjlltWcz975w8ab3vDfS8; incap_ses_764_2131963=ZzsxfB+DAVbYYwjLgUaaCge5w2UAAAAAL6osCdoTikWM98I6ovUeUg==; site-language=fr; site-segment=residential; Profile=LOGGED; visid_incap_2814592=cHuD9AHrQqGi1RIBO8ZPMwe5w2UAAAAAQUIPAAAAAACgt3aNa8DMpKK5jc9QV5ez; incap_ses_764_2814592=vWyHNxatZhWHZAjLgUaaCge5w2UAAAAArN8yYMyI05tOiggKm0JNLg==; _ga_E97BGG6JBK=GS1.1.1707325705.1.0.1707325708.0.0.0; _ga=GA1.1.599059982.1707325705; cookie-consent=required; visid_incap_2131964=0Zx3FFiIT4WLMgnMVR+9HRS5w2UAAAAAQUIPAAAAAACD2IUm6gCtCI/KR2Kl3ok6; incap_ses_764_2131964=gQepPmIkREzIewjLgUaaChS5w2UAAAAAVlRxhkpuNGGLoqgKSfK5HQ==; KEYCLOAK_ADAPTER_STATE=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJZeV9CX2s1TDlHV2tfcVNwaEJscjZUYUJZNEFXbjQ2a2dlMUtfMEJtckswIn0.eyJleHAiO...XpwIjoibWFnbm9saWEiLCJzZXNzaW9uX3N0YXRlIjoiM2UwYTVlZWQtNzEwYS00MjQ0LTkwMzUtYzNmNjBhNzgzNWRhIiwic2NvcGUiOiJvcGVuaWQgYXBpIiwic2lkIjoiM2UwYTVlZWQtNzEwYS00MjQ0LTkwMzUtYzNmNjBhNzgzNWRhIn0.dE0eIA82Ch5_GuD_Kjd28CyLsRa4WNvyuw19kFlsAT4
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
TE: trailers

I opened a case with them, requesting access to this API, but never got an answer. Maybe there's another way to get this data....?

That's the response:


{
    "prices": [
        {
            "ean": "XXXXXXXXXX",
            "prices": [
                {
                    "date": "2023-11-01",
                    "from": "2023-11-01",
                    "to": "2023-12-01",
                    "proportionalPriceConfigurations": {
                        "energy": {
                            "offtake": {
                                "peak": {
                                    "priceValue": 0.16000883,
                                    "vatTariff": 6
                                },
                                "offPeak": {
                                    "priceValue": 0.11005832,
                                    "vatTariff": 6
                                }
                            },
                            "injection": {
                                "peak": {
                                    "priceValue": 0.09076482,
                                    "vatTariff": 0
                                },
                                "offPeak": {
                                    "priceValue": 0.03835194,
                                    "vatTariff": 0
                                }
                            }
                        }
                    }
                },
                {
                    "date": "2023-12-01",
                    "from": "2023-12-01",
                    "to": "2024-01-01",
                    "proportionalPriceConfigurations": {
                        "energy": {
                            "offtake": {
                                "peak": {
                                    "priceValue": 0.12833258,
                                    "vatTariff": 6
                                },
                                "offPeak": {
                                    "priceValue": 0.08956467,
                                    "vatTariff": 6
                                }
                            },
                            "injection": {
                                "peak": {
                                    "priceValue": 0.06893724,
                                    "vatTariff": 0
                                },
                                "offPeak": {
                                    "priceValue": 0.02917067,
                                    "vatTariff": 0
                                }
                            }
                        }
                    }
                },
                {
                    "date": "2024-01-01",
                    "from": "2024-01-01",
                    "to": "2024-02-01",
                    "proportionalPriceConfigurations": {
                        "energy": {
                            "offtake": {
                                "peak": {
                                    "priceValue": 0.14147938,
                                    "vatTariff": 6
                                },
                                "offPeak": {
                                    "priceValue": 0.09807028,
                                    "vatTariff": 6
                                }
                            },
                            "injection": {
                                "peak": {
                                    "priceValue": 0.07799648,
                                    "vatTariff": 0
                                },
                                "offPeak": {
                                    "priceValue": 0.03298123,
                                    "vatTariff": 0
                                }
                            }
                        }
                    }
                },
                {
                    "date": "2024-02-01",
                    "from": "2024-02-01",
                    "to": "2024-02-08",
                    "proportionalPriceConfigurations": {
                        "energy": {
                            "offtake": {
                                "peak": {
                                    "priceValue": 0.11525252,
                                    "vatTariff": 6
                                },
                                "offPeak": {
                                    "priceValue": 0.08110223,
                                    "vatTariff": 6
                                }
                            },
                            "injection": {
                                "peak": {
                                    "priceValue": 0.05992398,
                                    "vatTariff": 0
                                },
                                "offPeak": {
                                    "priceValue": 0.02537945,
                                    "vatTariff": 0
                                }
                            }
                        }
                    }
                }
            ]
        }
    ]
}