from datetime import datetime


def calculateAlarmLevel(wasteDate):
    """takes an waste element and calculates the domoticz alarm level

    Arguments:
        wasteDate {[type]} -- the element to check

    Returns:
        [{int}, text ]-- alarm level and text holding the days till date
    """

    level = 1
    smallerTxt = ""
    if wasteDate is not None:
        delta = wasteDate - datetime.now().date()
        # Level = (0=gray, 1=green, 2=yellow, 3=orange, 4=red)
        if delta.days <= 1:
            level = 4
        elif delta.days == 2:
            level = 3
        elif delta.days == 3:
            level = 2
        else:
            level = 0

        if delta.days == 2:
            smallerTxt = "{} ({})".format(smallerTxt, "Übermorgen")
        elif delta.days == 1:
            smallerTxt = "{} ({}!)".format(smallerTxt, "Morgen")
        elif delta.days == 0:
            smallerTxt = "{} ({}!!!)".format(smallerTxt, "Heute")
        else:
            smallerTxt = "{} ({} Tage)".format(smallerTxt, delta.days)
    return [level, smallerTxt]