Skip to content

Commit

Permalink
아이콘 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
lunDreame authored Oct 28, 2024
1 parent 0ad6a54 commit 730f07f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion custom_components/apti/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up the APT.i integration."""
coordinator = APTiDataUpdateCoordinator(hass, entry)

#await coordinator.api.login()
await coordinator.api.login()
await coordinator.async_config_entry_first_refresh()

async_track_time_interval(
Expand Down
7 changes: 4 additions & 3 deletions custom_components/apti/apti.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import aiohttp
import re

Expand Down Expand Up @@ -47,7 +48,7 @@ def remove_callback(self, callback: Callable):
"""Remove a callback"""
self.callbacks.discard(callback)

async def update_callback(self):
def update_callback(self):
"""Updates registered callbacks."""
for callback in self.callbacks:
if callable(callback):
Expand Down Expand Up @@ -348,13 +349,13 @@ async def get_energy_type(self):
try:
energy_info["사용량"] = usage_down.text.split("(")[1].split(")")[0].strip()
except IndexError:
LOGGER.debug(f"Could not parse usage for {energy_type}")
LOGGER.warning(f"Could not parse usage for {energy_type}")

if usage_up := box.find("p", class_="eneUpTxt"):
try:
energy_info["평균 사용량"] = usage_up.text.split("(")[1].split(")")[0].strip()
except IndexError:
LOGGER.debug(f"Could not parse average usage for {energy_type}")
LOGGER.warning(f"Could not parse average usage for {energy_type}")

if details := box.find("div", class_="tbl_bill"):
for row in details.find_all("tr"):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/apti/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.const import Platform

DOMAIN = "apti"
VERSION = "1.0.5"
VERSION = "1.0.6"

PLATFORMS: list[Platform] = [
Platform.SENSOR
Expand Down
10 changes: 5 additions & 5 deletions custom_components/apti/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:

async def _update_maint_energy(self, _=None):
"""Fetch maintenance/energy data from the API."""
#if isinstance(_, datetime):
# LOGGER.info("Update maintenance/energy data.")
await self.api.login()
if isinstance(_, datetime):
LOGGER.info("Update maintenance/energy data.")
await self.api.login()
await asyncio.gather(
self.api.get_maint_fee_item(),
self.api.get_maint_fee_payment(),
self.api.get_maint_fee_item(),
self.api.get_energy_category(),
self.api.get_energy_type()
)
await self.api.data.update_callback()
self.api.data.update_callback()

def data_to_entities(self) -> dict[str, dict | list]:
"""Convert APT.i data to entities."""
Expand Down
1 change: 1 addition & 0 deletions custom_components/apti/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async def get_icon(
data = json.loads(content)

if category in data:
key = re.sub(r"\d+동", "", key).strip()
icon = data[category].get(key, None)
if icon is None:
LOGGER.warning(f"Icon for key '{key}' in category '{category}' not found.")
Expand Down
4 changes: 3 additions & 1 deletion custom_components/apti/icons/icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"선관위운영비": "mdi:ballot-outline",
"입대의운영비": "mdi:account-group-outline",
"장기수선비": "mdi:tools",
"공동난방비": "mdi:fire"
"공동난방비": "mdi:fire",
"소방유지대행료": "mdi:fire-truck",
"특별수선충당금": "mdi:cash-plus"
},
"energy_detail": {
"수도": "mdi:water",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/apti/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"aiofiles==24.1.0",
"beautifulsoup4==4.12.3"
],
"version": "1.0.5"
"version": "1.0.6"
}

0 comments on commit 730f07f

Please sign in to comment.