Skip to content

Commit

Permalink
Docs on time delay of energy data, config option for update interval …
Browse files Browse the repository at this point in the history
…of energy sensors
  • Loading branch information
signalkraft committed Mar 23, 2024
1 parent d00b987 commit fa80777
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 11 deletions.
11 changes: 9 additions & 2 deletions custom_components/mypyllant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
SERVICE_GENERATE_TEST_DATA,
SERVICE_EXPORT,
SERVICE_REPORT,
OPTION_UPDATE_INTERVAL_DAILY,
DEFAULT_UPDATE_INTERVAL_DAILY,
)
from .coordinator import SystemCoordinator, DailyDataCoordinator

Expand Down Expand Up @@ -93,6 +95,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
username: str = entry.data.get("username") # type: ignore
password: str = entry.data.get("password") # type: ignore
update_interval = entry.options.get(OPTION_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL)
update_interval_daily = entry.options.get(
OPTION_UPDATE_INTERVAL_DAILY, DEFAULT_UPDATE_INTERVAL_DAILY
)
country = entry.options.get(
OPTION_COUNTRY, entry.data.get(OPTION_COUNTRY, DEFAULT_COUNTRY)
)
Expand All @@ -117,8 +122,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await system_coordinator.async_refresh()
hass.data[DOMAIN][entry.entry_id]["system_coordinator"] = system_coordinator

# Daily data coordinator is updated hourly, but requests data for the whole day
daily_data_coordinator = DailyDataCoordinator(hass, api, entry, timedelta(hours=1))
# Daily data coordinator is updated hourly by default, but requests data for the whole day
daily_data_coordinator = DailyDataCoordinator(
hass, api, entry, timedelta(seconds=update_interval_daily)
)
_LOGGER.debug("Refreshing DailyDataCoordinator")
await daily_data_coordinator.async_refresh()
hass.data[DOMAIN][entry.entry_id]["daily_data_coordinator"] = daily_data_coordinator
Expand Down
7 changes: 7 additions & 0 deletions custom_components/mypyllant/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
DEFAULT_QUICK_VETO_DURATION,
DEFAULT_HOLIDAY_DURATION,
)
from . import OPTION_UPDATE_INTERVAL_DAILY, DEFAULT_UPDATE_INTERVAL_DAILY

from .const import (
DEFAULT_COUNTRY,
Expand Down Expand Up @@ -122,6 +123,12 @@ async def async_step_init(
OPTION_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL
),
): positive_int,
vol.Required(
OPTION_UPDATE_INTERVAL_DAILY,
default=self.config_entry.options.get(
OPTION_UPDATE_INTERVAL_DAILY, DEFAULT_UPDATE_INTERVAL_DAILY
),
): positive_int,
vol.Required(
OPTION_REFRESH_DELAY,
default=self.config_entry.options.get(
Expand Down
2 changes: 2 additions & 0 deletions custom_components/mypyllant/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DOMAIN = "mypyllant"
OPTION_UPDATE_INTERVAL = "update_interval"
OPTION_UPDATE_INTERVAL_DAILY = "update_interval_daily"
OPTION_REFRESH_DELAY = "refresh_delay"
OPTION_DEFAULT_QUICK_VETO_DURATION = "quick_veto_duration"
OPTION_DEFAULT_HOLIDAY_DURATION = "holiday_duration"
Expand All @@ -11,6 +12,7 @@
OPTION_FETCH_MPC = "fetch_mpc"
OPTION_FETCH_AMBISENSE_ROOMS = "fetch_ambisense_rooms"
DEFAULT_UPDATE_INTERVAL = 60 # in seconds
DEFAULT_UPDATE_INTERVAL_DAILY = 3600 # in seconds
DEFAULT_REFRESH_DELAY = 5 # in seconds
DEFAULT_COUNTRY = "germany"
DEFAULT_TIME_PROGRAM_OVERWRITE = False
Expand Down
6 changes: 5 additions & 1 deletion custom_components/mypyllant/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
"init": {
"data": {
"update_interval": "Sekundy mezi kontrolami (při nižších hodnotách hrozí riziko překročení kvóty a dočasné zákazy)",
"update_interval_daily": "Sekundy mezi aktualizacemi energetických dat (při nižších hodnotách hrozí riziko překročení kvóty a dočasné zákazy)",
"refresh_delay": "Zpoždění před obnovením dat po aktualizacích",
"quick_veto_duration": "Nastavené trvání v hodinách pro rychlé veto",
"holiday_duration": "Nastavená doba trvání dovolené ve dnech",
"time_program_overwrite": "Regulátory teploty přepisují časový program namísto nastavení rychlého veta",
"default_holiday_setpoint": "Výchozí teplota pro dovolenou",
"country": "Země",
"brand": "Značka"
"brand": "Značka",
"fetch_rts": "Načíst statistiky v reálném čase (není podporováno na každém systému)",
"fetch_mpc": "Načíst využití energie v reálném čase (není podporováno na každém systému)",
"fetch_ambisense_rooms": "Načíst termostaty místnosti Ambisense"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions custom_components/mypyllant/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"init": {
"data": {
"update_interval": "Intervall zwischen Updates in Sekunden (niedrige Werte führen zu 'Quota Exceeded' Fehlern)",
"update_interval_daily": "Intervall zwischen Energiedaten Updates in Sekunden (niedrige Werte führen zu 'Quota Exceeded' Fehlern)",
"refresh_delay": "Verzögerung bevor Daten nach einer Änderung aktualisiert werden",
"quick_veto_duration": "Standard Dauer in Stunden für Quick Veto",
"holiday_duration": "Standard Dauer in Tagen für Abwesenheitsmodus",
Expand Down
5 changes: 3 additions & 2 deletions custom_components/mypyllant/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"step": {
"init": {
"data": {
"update_interval": "Seconds between scans (lower values risk 'quota exceeded' errors and temporary bans)",
"refresh_delay": "Delay before refreshing data after updates",
"update_interval": "Seconds between updates (lowering risks 'quota exceeded' errors and temporary bans)",
"update_interval_daily": "Seconds between energy data updates (lowering risks 'quota exceeded' errors and temporary bans)",
"refresh_delay": "Delay in seconds before refreshing data after updates",
"quick_veto_duration": "Default duration in hours for quick veto",
"holiday_duration": "Default duration in days for away mode",
"time_program_overwrite": "Temperature controls overwrite time program instead of setting quick veto",
Expand Down
6 changes: 5 additions & 1 deletion custom_components/mypyllant/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
"init": {
"data": {
"update_interval": "Secondi tra le scansioni (valori più bassi riducono il rischio di 'quota exceeded' e ban temporanei)",
"update_interval_daily": "Secondi tra gli aggiornamenti dei dati energetici (valori più bassi rischiano errori 'quota exceeded' e ban temporanei)",
"refresh_delay": "Ritardo prima dell'aggiornamento dei dati",
"quick_veto_duration": "Durata di default in ore per l'acqua calda rapida",
"holiday_duration": "Durata di default in giorni per le vacanze",
"time_program_overwrite": "Controlla la temperatura sovrascrivendo la programmazione oraria invece di attivare acqua calda rapida",
"default_holiday_setpoint": "Temperatura di default per le vacanze",
"country": "Stato",
"brand": "Marca"
"brand": "Marca",
"fetch_rts": "Recupera le statistiche in tempo reale (non supportato su tutti i sistemi)",
"fetch_mpc": "Recupera l'uso della potenza in tempo reale (non supportato su tutti i sistemi)",
"fetch_ambisense_rooms": "Recupera i termostati ambiente Ambisense"
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion custom_components/mypyllant/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
"init": {
"data": {
"update_interval": "Sekundy między skanowaniami (niższe wartości grożą błędami 'przekroczenia limitu' i tymczasowymi banami)",
"update_interval_daily": "Sekundy między aktualizacjami danych energetycznych (niższe wartości ryzykują błędy 'przekroczono limit' i tymczasowe bany)",
"refresh_delay": "Opóźnienie przed odświeżeniem danych po aktualizacji",
"quick_veto_duration": "Domyślny czas trwania szybkiego weta w godzinach",
"holiday_duration": "Domyślny czas trwania wakacji w dniach",
"time_program_overwrite": "Kontrola temperatury nadpisuje program czasowy zamiast ustawiać szybkie weto",
"default_holiday_setpoint": "Domyślna temperatura wakacyjna",
"country": "Kraj",
"brand": "Marka"
"brand": "Marka",
"fetch_rts": "Pobierz statystyki w czasie rzeczywistym (nie jest obsługiwane na każdym systemie)",
"fetch_mpc": "Pobierz rzeczywiste zużycie energii (nie jest obsługiwane na każdym systemie)",
"fetch_ambisense_rooms": "Pobierz termostaty pokojowe Ambisense"
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion custom_components/mypyllant/translations/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
"init": {
"data": {
"update_interval": "Sekundy medzi kontrolami (pri nižších hodnotách hrozí riziko prekročenia kvóty a dočasné zákazy)",
"update_interval_daily": "Sekundy medzi aktualizáciami energetických údajov (pri nižších hodnotách hrozí riziko prekročenia kvóty a dočasné zákazy)",
"refresh_delay": "Oneskorenie pred obnovením údajov po aktualizáciách",
"quick_veto_duration": "Predvolené trvanie v hodinách pre rýchle veto",
"holiday_duration": "Predvolená doba trvania dovolenky v dňoch",
"time_program_overwrite": "Regulátory teploty prepisujú časový program namiesto nastavenia rýchleho veta",
"default_holiday_setpoint": "Predvolená teplota počas dovolenky",
"country": "Krajina",
"brand": "Značka"
"brand": "Značka",
"fetch_rts": "Načítať štatistiky v reálnom čase (nie je podporované na každom systéme)",
"fetch_mpc": "Načítať využitie energie v reálnom čase (nie je podporované na každom systéme)",
"fetch_ambisense_rooms": "Načítať termostaty miestnosti Ambisense"
}
}
}
Expand Down
38 changes: 35 additions & 3 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,25 @@ Uses the [myPyllant Python library](https://github.com/signalkraft/mypyllant).

After setting up the integration, you can configure it further in Settings :material-arrow-right: Devices & Services :material-arrow-right: myVAILLANT :material-arrow-right: Configure.

### Seconds between scans
### Seconds between updates

: Wait interval between updating (most) sensors. The energy data and efficiency sensors have a fixed hourly interval.
: Wait interval between updating (most) sensors. The energy data and efficiency sensors are controlled by the next option.
Setting this too low can cause "quota exceeded" errors.

You should restart Home Assistant after changing this setting.

:material-cog: Default is 60 seconds.

### Delay before refreshing data after updates
### Seconds between energy data updates

: Wait interval between updating sensors with hourly data. The energy data and efficiency sensors have a fixed hourly interval.
Setting this too low can cause "quota exceeded" errors.

You should restart Home Assistant after changing this setting.

:material-cog: Default is 3600 seconds.

### Delay in seconds before refreshing data after updates

: How long to wait between making a request (i.e. setting target temperature) and refreshing data.
The Vaillant API takes some time to return the updated values. Setting this too low will return the old values.
Expand Down Expand Up @@ -280,3 +291,24 @@ Home Assistant has certain pre-defined modes, that can't be changed.

### Energy & Efficiency Sensors are delayed / incomplete / behave oddly around midnight

How Vaillant reports energy data, and how Home Assistant deals with sensor data is not a good match:

* Vaillant's API provides energy data in hourly increments, some time after the full hour has passed (let's say at 10:30am for the energy data from 9-10am)
* This integration fetches energy data every hour, for the current day, up to the current time
* Depending on when your HA schedules this hourly update, it may happen right after Vaillant provides the new hourly data, or almost an hour later
* Home Assistant doesn't support setting a past date for a sensor reading, the value is always displayed at the time when it was saved
* Data for the whole day is fetched, so that the total is correct even if the API is temporarily unavailable, or the integration misses an hour window for some other reason
* Worst case, you end up with a 30min delay from Vaillant and a 59min delay from the integration: Your energy data from 9-10am will show up at 11:29am. Best case is probably around 10:30am.
* After midnight, the integration will fetch data for the new day, which will be empty until the first full hour + delay has passed
* If you have new energy data between 11pm and midnight, it won't show up in your total for the previous day

Home Assistant would need to allow setting a timestamp with each new energy value, to improve this situation.
The delay would still be there, but at least the values would be displayed at the correct time.

You can lower the update interval for fetching energy data, to minimize the delay between Vaillant's updates and HA.
See [Options](#seconds-between-energy-data-updates). But it's not recommended, since it's a lot of data to fetch
and Vaillant may ban you temporarily with 'quota exceeded' errors.

To fix data loss around midnight, the integration could fetch a longer period of time (for example a whole month).
But then the sensor would no longer show a daily total, which would potentially mess with users' setups.
The change from daily to monthly would also show up as a strange spike of energy usage when the update is done.

0 comments on commit fa80777

Please sign in to comment.