Skip to content

Commit

Permalink
refactor: Add config entry data cached property
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Dec 9, 2024
1 parent ba2077b commit 1312035
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/solarman/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class ConfigurationProvider:
hass: HomeAssistant
config_entry: ConfigEntry

@cached_property
def _data(self):
return self.config_entry.data

@cached_property
def _options(self):
return self.config_entry.options
Expand All @@ -35,11 +39,11 @@ def _additional_options(self):

@cached_property
def name(self):
return protected(self.config_entry.data.get(CONF_NAME), "Configuration parameter [name] does not have a value")
return protected(self._data.get(CONF_NAME), "Configuration parameter [name] does not have a value")

@cached_property
def serial(self):
return protected(self.config_entry.data.get(CONF_SERIAL, self.config_entry.data.get(OLD_[CONF_SERIAL])), "Configuration parameter [serial] does not have a value")
return protected(self._data.get(CONF_SERIAL, self._data.get(OLD_[CONF_SERIAL])), "Configuration parameter [serial] does not have a value")

@cached_property
def host(self):
Expand Down

0 comments on commit 1312035

Please sign in to comment.