Skip to content

Extension of time from 23:59 to 00:00 (midnight, the following day) #48

@VYarda

Description

@VYarda

Zkontrolujte existující požadavky

  • Completed

Popište řešení, které chcete

I have a suggestion for modifying the isHdo function. For example, with the A3B5DP5 tariff, isHdo incorrectly switches off for one minute, while the real HDO signal remains active. My proposed modification in the downloader.py file is:

def isHdo(jsonCalendar):
    """
    Find out if the HDO is enabled for the current timestamp

    :param jsonCalendar: JSON with calendar schedule from CEZ
    :param daytime: relevant time in "Europe/Prague" timezone to check if HDO is on or not
    :return: bool
    """
    daytime = datetime.datetime.now(tz=CEZ_TIMEZONE)
    # select Mon-Fri schedule or Sat-Sun schedule according to current date
    if daytime.weekday() < 5:
        dayCalendar = next(
            (x for x in jsonCalendar if x["PLATNOST"] == "Po - Pá" or x["PLATNOST"] == "Po - Ne"), None
        )
    else:
        dayCalendar = next(
            (x for x in jsonCalendar if x["PLATNOST"] == "So - Ne" or x["PLATNOST"] == "Po - Ne"), None
        )

    checkedTime = daytime.time()
    hdo = False

    # iterate over scheduled times in calendar schedule
    for i in range(1, 11):
        startTime = parseTime(dayCalendar["CAS_ZAP_" + str(i)])
        #endTime = parseTime(dayCalendar["CAS_VYP_" + str(i)]) - deleted and replaced with the following:
        endTimeRaw = dayCalendar["CAS_VYP_" + str(i)]
        
        # If the end time is 23:59, interpret it as 00:00 the following day.
        if endTimeRaw == "23:59":
            endTime = datetime.time(0, 0)
        else:
            endTime = parseTime(endTimeRaw)
        # end of new version
        hdo = hdo or timeInRange(start=startTime, end=endTime, x=checkedTime)
    return hdo

Popište alternativy, které jste zvažovali

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions