Skip to content

Commit

Permalink
add api calling from ip/econet/regParams endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jontofront committed Nov 12, 2024
1 parent ea8755b commit abe0a07
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"editor.defaultFormatter": "vscode.json-language-features"
},
"cSpell.words": [
"aiohttp",
"econet",
"hass",
"homeassistant",
"MILLIWATT",
"PARAMSUNITSNAMES"
Expand Down
22 changes: 21 additions & 1 deletion custom_components/econet300/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
API_EDITABLE_PARAMS_LIMITS_URI,
API_REG_PARAMS_DATA_PARAM_DATA,
API_REG_PARAMS_DATA_URI,
API_REG_PARAMS_PARAM_DATA,
API_REG_PARAMS_URI,
API_SYS_PARAMS_PARAM_HW_VER,
API_SYS_PARAMS_PARAM_MODEL_ID,
API_SYS_PARAMS_PARAM_SW_REV,
Expand Down Expand Up @@ -204,7 +206,7 @@ def hw_ver(self) -> str:
return self._hw_version

async def init(self):
"""Econet300 Api initilization."""
"""Econet300 Api initialization."""
sys_params = await self._client.get_params(API_SYS_PARAMS_URI)

if API_SYS_PARAMS_PARAM_UID not in sys_params:
Expand Down Expand Up @@ -287,6 +289,24 @@ async def get_param_limits(self, param: str):
curr_limits = limits[param]
return Limits(curr_limits["min"], curr_limits["max"])

async def fetch_reg_params(self) -> dict[str, Any]:
"""Fetch and return the regParam data from ip/econet/regParams endpoint."""
_LOGGER.info("Calling fetch_reg_params method")
regParams = await self._client.get_params(API_REG_PARAMS_URI)
_LOGGER.debug("Fetched regParams data: %s", regParams)

if API_REG_PARAMS_PARAM_DATA in regParams:
_LOGGER.info(
"Response contains expected keys. API_REG_PARAMS_PARAM_DATA: %s",
regParams[API_REG_PARAMS_PARAM_DATA],
)
else:
_LOGGER.warning(
"Response does not contain expected keys. API_REG_PARAMS_PARAM_DATA is missing."
)

return regParams

async def fetch_data(self) -> dict[str, Any]:
"""Fetch data from regParamsData."""
regParamsData = await self._fetch_reg_key(
Expand Down

0 comments on commit abe0a07

Please sign in to comment.