Skip to content

Commit

Permalink
Merge pull request #93 from bruxy70/development
Browse files Browse the repository at this point in the history
CountryHolidays minimal version
  • Loading branch information
bruxy70 authored Jan 27, 2020
2 parents d93dfec + 3e335f5 commit 1285762
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

.vscode/settings.json
7 changes: 4 additions & 3 deletions custom_components/garbage_collection/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,17 +832,18 @@ async def _show_final_form(self, user_input):
] = vol.In(COUNTRY_CODES)
data_schema[
vol.Optional(
CONF_PROV, default=self.config_entry.options.get(CONF_PROV, ""),
CONF_PROV, default=self.config_entry.options.get(CONF_PROV, "")
)
] = str
data_schema[
vol.Optional(
CONF_STATE, default=self.config_entry.options.get(CONF_STATE, ""),
CONF_STATE, default=self.config_entry.options.get(CONF_STATE, "")
)
] = str
data_schema[
vol.Optional(
CONF_OBSERVED, default=self.config_entry.options.get(CONF_OBSERVED, True),
CONF_OBSERVED,
default=self.config_entry.options.get(CONF_OBSERVED, True),
)
] = bool
return self.async_show_form(
Expand Down
4 changes: 2 additions & 2 deletions custom_components/garbage_collection/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"requirements": [
"datetime",
"integrationhelper",
"holidays",
"integrationhelper>=0.2.2",
"holidays>=0.10.1",
"typing",
"uuid",
"voluptuous"
Expand Down
12 changes: 5 additions & 7 deletions custom_components/garbage_collection/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,21 @@ def __init__(self, hass, config):
state = config.get(CONF_STATE)
observed = config.get(CONF_OBSERVED, True)
_LOGGER.debug(
"(%s) Country Holidays with parameters: prov: %s, state: %s, observed: %s",
"(%s) Country Holidays with parameters: country: %s, prov: %s, state: %s, observed: %s",
self.__name,
country_holidays,
prov,
state,
observed
observed,
)
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:
if observed is not None and type(observed) == bool and observed == False:
kwargs["observed"] = observed
hol = holidays.CountryHoliday(
country_holidays,
**kwargs
).items()
hol = holidays.CountryHoliday(country_holidays, **kwargs).items()
try:
for date, name in hol:
if date >= today:
Expand Down

0 comments on commit 1285762

Please sign in to comment.