diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da8d1e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.vscode/settings.json diff --git a/custom_components/garbage_collection/sensor.py b/custom_components/garbage_collection/sensor.py index 8abdde7..aecfe04 100644 --- a/custom_components/garbage_collection/sensor.py +++ b/custom_components/garbage_collection/sensor.py @@ -157,28 +157,17 @@ def __init__(self, hass, config): state, observed ) - if state is None or state == "": - if prov is None or prov == "": - hol = holidays.CountryHoliday( - country_holidays, years=years, observed=observed - ).items() - else: - hol = holidays.CountryHoliday( - country_holidays, years=years, prov=prov, observed=observed - ).items() - else: - if prov is None or prov == "": - hol = holidays.CountryHoliday( - country_holidays, years=years, state=state, observed=observed - ).items() - else: - hol = holidays.CountryHoliday( - country_holidays, - years=years, - state=state, - prov=prov, - observed=observed - ).items() + kwargs = {"years": years} + if state is not None and state != "": + kwargs["state"] = state + if prov is not None and prov != "": + kwargs["prov"] = prov + if observed is not None: + kwargs["observed"] = observed + hol = holidays.CountryHoliday( + country_holidays, + **kwargs + ).items() try: for date, name in hol: if date >= today: