Fixed price config

This commit is contained in:
Gunnar Skjold
2024-04-14 14:20:46 +02:00
parent 77873f4a38
commit 3a980fac4c
3 changed files with 9 additions and 9 deletions

View File

@@ -106,8 +106,8 @@ float PriceService::getValueForHour(uint8_t direction, time_t ts, int8_t hour) {
return ret;
tmElements_t tm;
breakTime(tz->toLocal(ts + (hour) * SECS_PER_HOUR), tm);
uint8_t day = 0x01 << (tm.Wday - 2);
breakTime(tz->toLocal(ts + (hour * SECS_PER_HOUR)), tm);
uint8_t day = 0x01 << ((tm.Wday+5)%7);
uint32_t hrs = 0x01 << tm.Hour;
for (uint8_t i = 0; i < priceConfig.size(); i++) {
@@ -137,8 +137,8 @@ float PriceService::getValueForHour(uint8_t direction, time_t ts, int8_t hour) {
float PriceService::getEnergyPriceForHour(uint8_t direction, time_t ts, int8_t hour) {
tmElements_t tm;
breakTime(tz->toLocal(ts + (hour) * SECS_PER_HOUR), tm);
uint8_t day = 0x01 << (tm.Wday - 2);
breakTime(tz->toLocal(ts + (hour * SECS_PER_HOUR)), tm);
uint8_t day = 0x01 << ((tm.Wday+5)%7);
uint32_t hrs = 0x01 << tm.Hour;
float value = PRICE_NO_VALUE;