fsaris / home-assistant-zonneplan-one

Unofficial Zonneplan integration for Home Assistant
https://github.com/fsaris/home-assistant-zonneplan-one
MIT License
104 stars 17 forks source link

New property: Tomorrows gas price #73

Closed R-ens closed 9 months ago

R-ens commented 1 year ago

Since the last Zonneplan App update they are publishing the new gas price already the day before around 18.30 PM. It would be nice if we have this price as a new sensor within this integration.

Release notes Jun 29, 2023 (https://play.google.com/store/apps/details?id=com.zonneplanapp):

Met deze update publiceren we de gasprijs van de volgende dag veel sneller. Ongeveer rond 18:30 uur verschijnt de prijs in het dashboard. Zo kun je als klant je gasverbruik eerder sturen naar een ander moment. Daarnaast is de app op enkele punten verbeterd.
fsaris commented 1 year ago

I don't have a energy contract so will not get these values.

Can you post the debug info maybe we can spot the value and add it as sensor to the integration. https://github.com/fsaris/home-assistant-zonneplan-one#troubleshooting

R-ens commented 1 year ago

This is the only diff that I have found, within the price_per_hour array. It's all based on datetime, the same as the current prices.

[
   {
      "electricity_price":3100732,
      "gas_price":10894555,
      "tariff_group":"normal",
      "solar_percentage":0,
      "solar_yield":0,
      "datetime":"2023-07-04T04:00:00.000000Z",
      "sustainability_score":338
   },
   {
      "electricity_price":2649281,
      "gas_price":10770199,
      "tariff_group":"low",
      "solar_percentage":0,
      "solar_yield":0,
      "datetime":"2023-07-05T04:00:00.000000Z",
      "sustainability_score":216
   }
]
fsaris commented 9 months ago

@renslinden could you test current main (beta) version, I added a additional sensor for this? But I'm not able to test this fully as I don't have a energy contract

R-ens commented 9 months ago

Looks good so far, unfortunately there is no price change over the weekend so it shows me the current price.

It might be better to show None or Unknown instead.

Screenshot_2023-11-18-13-19-55-50_c3a231c25ed346e59462e84656a70e50.jpg

fsaris commented 9 months ago

It's the next known value. Can you add the debug output here? Or check it for the gas_price value? I expect that tomorrow is filled with this value even if it doesn't change regarding to today.

R-ens commented 9 months ago

Yes i know, I've checked your change. You revert the list and pick the first item as the next day price, right?

Currently there is only one price available from the ZP api:

{'electricity_price': 2767377, 'gas_price': 12002777, 'tariff_group': 'low', 'solar_percentage': 0, 'solar_yield': 0, 'datetime': '2023-11-18T05:00:00.000000Z', 'sustainability_score': 176}
fsaris commented 9 months ago

are you sure the price isn't updated during the weekend? Maybe it's only know every day after 18:30 like you mentioned in your first message.

R-ens commented 9 months ago

As far as I know during the weekend the gas market is closed so the current price is valid till Monday 6.00 AM.

Anyways, does it impact the implementation? I don't think so.

Is there anything I can test/debug/clarify for you?

R-ens commented 9 months ago

So let me elaborate a bit more. This is what I see at this moment in the Zonneplan app.

IMG_20231118_145957.jpg

Around the clock of 6/7 PM the tomorrow's price will become available and is shown underneath 'Gasprijs vandaag'. Unfortunately I currently do not have a screenshot of that.

Technical wise the API gives two gas prices.

In the morning the tomorrow's price disappear from the app. As the next price is not known anymore. At this moment I do expect a sensor with status None or Unknown.

Technical wise the API gives only one gas price.

fsaris commented 9 months ago

@renslinden updated the code to only show a next gas price when there is a next price known (there a 2 prices in the list)

R-ens commented 9 months ago

Getting an error with latest version:

Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.zonneplan_one.coordinator
Source: helpers/update_coordinator.py:290
Integration: Zonneplan ONE (documentation, issues)
First occurred: 16:38:14 (4 occurrences)
Last logged: 16:40:32

Unexpected error fetching zonneplan_one data: name 'false' is not defined
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zonneplan_one/coordinator.py", line 63, in _async_update_data
    return await self._fetch_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zonneplan_one/coordinator.py", line 120, in _fetch_data
    result[uuid]["summary_data"]["gas_price_next"] = getNextGasPriceFromSummary(summary)
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zonneplan_one/coordinator.py", line 32, in getNextGasPriceFromSummary
    first_price_found = false
                        ^^^^^
NameError: name 'false' is not defined
fsaris commented 9 months ago

@renslinden wrong value is fixed

R-ens commented 9 months ago

It looks good so far!

This was the situation before 6 PM:

Screenshot_2023-11-18-18-13-18-07_c3a231c25ed346e59462e84656a70e50.jpg

And this after 6 PM:

IMG_20231119_004047.jpg

Screenshot_2023-11-19-00-41-26-06_c3a231c25ed346e59462e84656a70e50.jpg

R-ens commented 9 months ago

The situation this morning (8.30 AM):

Screenshot_2023-11-19-08-27-55-62_c3a231c25ed346e59462e84656a70e50.jpg

So what I notice is that the state didn't reset to Onbekend / Unknown. That's what I initially did expect, but we can ask ourselves if that should be the desired option.

What do you think?

fsaris commented 9 months ago

Can you check the data you receive from the api? It should go back to unknown if there aren't 2 prices in the data

fsaris commented 9 months ago

Ah, there was still some use of known value in place

R-ens commented 9 months ago

I'll let you know if it works as expected. Thanks!

R-ens commented 9 months ago

Can confirm that it works as expected, good job!

Ready to release

fsaris commented 9 months ago

released https://github.com/fsaris/home-assistant-zonneplan-one/discussions/86