Skip to content

Commit

Permalink
HACS Update - GArbage collection - #16
Browse files Browse the repository at this point in the history
  • Loading branch information
BeardedTinker committed Sep 10, 2020
1 parent d26ed32 commit 1ce50f1
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 220 deletions.
2 changes: 1 addition & 1 deletion custom_components/garbage_collection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async def update_listener(hass, entry):
"""Update listener."""
# The OptionsFlow saves data to options.
# Move them back to data and clean options (dirty, but not sure how else to do that)
if entry.options != {}:
if len(entry.options) > 0:
entry.data = entry.options
entry.options = {}
await hass.config_entries.async_forward_entry_unload(entry, SENSOR_PLATFORM)
Expand Down
12 changes: 6 additions & 6 deletions custom_components/garbage_collection/config_singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ def __init__(self) -> None:
@property
def defaults(self) -> Dict:
"""Return default values."""
return self.__defaults
return self._defaults

def reset_defaults(self) -> None:
"""Reset the defaults from const.py."""
self.__defaults = {}
self._defaults = {}
items = {
key: value for (key, value) in self.options.items() if "default" in value
}
for key, value in items.items():
self.__defaults[key] = value["default"]
self._defaults[key] = value["default"]

def compile_config_flow(self, step: int, valid_for=None) -> Dict:
"""Generate configuration options relevant for current step and frequency."""
Expand All @@ -65,10 +65,10 @@ def compile_config_flow(self, step: int, valid_for=None) -> Dict:
)
}
for key, value in items.items():
if key in self.__defaults:
if key in self._defaults:
result[
value["method"](
key, description={"suggested_value": self.__defaults[key]}
key, description={"suggested_value": self._defaults[key]}
)
] = value["type"]
else:
Expand Down Expand Up @@ -108,4 +108,4 @@ def set_defaults(self, step: int, data) -> None:
if data[key] is not None and (
type(data[key]) not in [list, dict] or len(data[key]) != 0
):
self.__defaults[key] = data[key]
self._defaults[key] = data[key]
Loading

0 comments on commit 1ce50f1

Please sign in to comment.