Skip to content

Commit

Permalink
Merge pull request #2 from Ludy87/v1.1.0
Browse files Browse the repository at this point in the history
✅ add show dyndns_update_limit
  • Loading branch information
Ludy87 authored Jun 24, 2023
2 parents 054af2f + a2b07eb commit 647256f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
14 changes: 7 additions & 7 deletions custom_components/ipv64/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ async def check_domain_login(hass: core.HomeAssistant, data: dict[str, str]):
headers=headers,
raise_for_status=True,
)
result = await resp.json()
result = dict(await resp.json())
except aiohttp.ClientResponseError as error:
_LOGGER.error("Your 'Account Update Token' is incorrect. Error: %s | Status: %i", error.message, error.status)
raise TokenError() from error

url_account_info = "https://ipv64.net/api.php?get_account_info"
async with async_timeout.timeout(TIMEOUT):
url_account_info = "https://ipv64.net/api.php?get_account_info"
try:
resp = await session.get(
resp_account_info = await session.get(
url_account_info,
headers=headers,
raise_for_status=True,
)
account_result = await resp.json()
account_result = await resp_account_info.json()
if account_result["update_hash"] != data[CONF_API_KEY]:
raise APIKeyError()
result["dyndns_update_limit"] = account_result["dyndns_update_limit"]
result.update({"dyndns_update_limit": account_result["account_class"]["dyndns_update_limit"]})
except aiohttp.ClientResponseError as error:
_LOGGER.error("Your 'API Key' is incorrect. Error: %s | Status: %i", error.message, error.status)
raise APIKeyError() from error
_LOGGER.debug(result)
return result


Expand Down Expand Up @@ -113,7 +113,7 @@ async def async_step_user(self, user_input=None):
CONF_DOMAIN: user_input[CONF_DOMAIN],
CONF_API_KEY: user_input[CONF_API_KEY],
CONF_TOKEN: user_input[CONF_TOKEN],
"dyndns_update_limit": info["dyndns_update_limit"],
"dyndns_update_limit": info["data"]["dyndns_update_limit"],
},
options={CONF_SCAN_INTERVAL: user_input[CONF_SCAN_INTERVAL]},
)
Expand Down
6 changes: 4 additions & 2 deletions custom_components/ipv64/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def _async_update_data(self):
result = await resp.json()
result_dict = {
"wildcard": result["subdomains"][self.config_entry.data[CONF_DOMAIN]]["wildcard"],
"updates": result["subdomains"][self.config_entry.data[CONF_DOMAIN]]["updates"],
"updates": f"{result['subdomains'][self.config_entry.data[CONF_DOMAIN]]['updates']}/{self.config_entry.data['dyndns_update_limit']}",
CONF_IP_ADDRESS: result["subdomains"][self.config_entry.data[CONF_DOMAIN]]["records"][0]["content"],
"last_update": result["subdomains"][self.config_entry.data[CONF_DOMAIN]]["records"][0]["last_update"],
}
Expand All @@ -75,7 +75,9 @@ async def _async_update_data(self):
errors = {
"Account Update Token": "incorrect",
"wildcard": self.data["wildcard"] if self.data and "wildcard" in self.data else "unlivable",
"updates": self.data["updates"] if self.data and "updates" in self.data else "unlivable",
"updates": f"{self.data['updates']}/{self.data['dyndns_update_limit']}"
if self.data and "updates" in self.data and "dyndns_update_limit" in self.data
else "unlivable",
CONF_IP_ADDRESS: self.data[CONF_IP_ADDRESS]
if self.data and CONF_IP_ADDRESS in self.data
else "unlivable",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ipv64/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/Ludy87/ipv64/issues",
"requirements": [],
"version": "1.0.0"
"version": "1.1.0"
}
2 changes: 2 additions & 0 deletions custom_components/ipv64/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ async def update(self):
class IPv64Sensor(IPv64BaseEntity, SensorEntity):
"""Sensor entity class for IPv64."""

_attr_icon = "mdi:ip"

def __init__(
self,
coordinator: IPv64DataUpdateCoordinator,
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "IPv64",
"country": ["DE", "US"],
"render_readme": true,
"homeassistant": "2023.6.1",
"homeassistant": "2023.6.3",
"hacs": "1.32.1"
}

0 comments on commit 647256f

Please sign in to comment.