Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram van Dartel committed Dec 18, 2024
1 parent d8ad570 commit 0632338
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
46 changes: 23 additions & 23 deletions custom_components/afvalwijzer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const.const import DOMAIN
# from homeassistant.config_entries import ConfigEntry
# from homeassistant.core import HomeAssistant
# from homeassistant.helpers.typing import ConfigType
# from .const.const import DOMAIN


async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Afvalwijzer integration."""
hass.data.setdefault(DOMAIN, {})
return True
# async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
# """Set up the Afvalwijzer integration."""
# hass.data.setdefault(DOMAIN, {})
# return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Afvalwijzer from a config entry."""
# Store config entry data
hass.data[DOMAIN][entry.entry_id] = entry.data
# async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# """Set up Afvalwijzer from a config entry."""
# # Store config entry data
# hass.data[DOMAIN][entry.entry_id] = entry.data

# Forward the setup to the sensor platform
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
return True
# # Forward the setup to the sensor platform
# await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
# return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
# Remove stored data
if entry.entry_id in hass.data[DOMAIN]:
hass.data[DOMAIN].pop(entry.entry_id)
# async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# """Unload a config entry."""
# # Remove stored data
# if entry.entry_id in hass.data[DOMAIN]:
# hass.data[DOMAIN].pop(entry.entry_id)

# Unload the sensor platform
await hass.config_entries.async_forward_entry_unload(entry, "sensor")
return True
# # Unload the sensor platform
# await hass.config_entries.async_forward_entry_unload(entry, "sensor")
# return True
7 changes: 5 additions & 2 deletions custom_components/afvalwijzer/collector/ximmio.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def get_waste_data_raw(provider, postal_code, street_number, suffix):
if provider not in SENSOR_COLLECTORS_XIMMIO_IDS:
raise ValueError(f"Invalid provider: {provider} for XIMMIO, please verify")

url = SENSOR_COLLECTORS_XIMMIO.get("ximmio")
if provider in SENSOR_COLLECTORS_XIMMIO.keys():
url = SENSOR_COLLECTORS_XIMMIO[provider]
else:
url = SENSOR_COLLECTORS_XIMMIO["ximmio"]

if not url:
raise ValueError(f"Invalid provider: {provider} for XIMMIO, please verify")
Expand All @@ -34,7 +37,7 @@ def get_waste_data_raw(provider, postal_code, street_number, suffix):

if suffix:
data["HouseLetter"] = suffix

print(data)
response = requests.post(url="{}/api/FetchAdress".format(url), timeout=60, data=data).json()

if not response['dataList']:
Expand Down
7 changes: 6 additions & 1 deletion custom_components/afvalwijzer/const/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@
]

SENSOR_COLLECTORS_XIMMIO = {
"ximmio": "https://wasteprod2api.ximmio.com",
"ximmio": "https://wasteapi.ximmio.com",
"avalex": "https://wasteprod2api.ximmio.com",
"meerlanden": "https://wasteprod2api.ximmio.com",
"rad": "https://wasteprod2api.ximmio.com",
"westland": "https://wasteprod2api.ximmio.com",
"woerden": "https://wasteprod2api.ximmio.com",
}

SENSOR_COLLECTORS_XIMMIO_IDS = {
Expand Down
13 changes: 11 additions & 2 deletions custom_components/afvalwijzer/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@
# street_number = "2"

# Afvalwijzer
# provider = "mijnafvalwijzer"
# postal_code = "5146eg"
# street_number = "1"

provider = "mijnafvalwijzer"
postal_code = "5146eg"
street_number = "1"
postal_code = "5563CM"
street_number = "22"

# ACV
# provider = "acv"
# postal_code = "6714KK"
# street_number = "20"

# iCalendar file
# provider = "veldhoven"
Expand Down

0 comments on commit 0632338

Please sign in to comment.