Skip to content

Commit

Permalink
Update project setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kvj committed Nov 23, 2024
1 parent 856fbc5 commit ac4f65a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions custom_components/openwrt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
from .constants import DOMAIN, PLATFORMS

from homeassistant.core import HomeAssistant, SupportsResponse
from homeassistant.helpers.typing import ConfigType
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers import service
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
)
import homeassistant.helpers.config_validation as cv

import voluptuous as vol
import homeassistant.helpers.config_validation as cv
import logging

from .coordinator import new_coordinator

_LOGGER = logging.getLogger(__name__)


CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
}),
Expand All @@ -28,19 +28,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):

device = new_coordinator(hass, data, hass.data[DOMAIN]['devices'])

hass.data[DOMAIN]['devices'][entry.entry_id] = device # Backward compatibility
entry.runtime_data = device # New style

await device.coordinator.async_config_entry_first_refresh()
hass.data[DOMAIN]['devices'][entry.entry_id] = device
for p in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, p)
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
for p in PLATFORMS:
await hass.config_entries.async_forward_entry_unload(entry, p)
await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

entry.runtime_data = None
hass.data[DOMAIN]['devices'].pop(entry.entry_id)

return True


Expand Down
2 changes: 1 addition & 1 deletion custom_components/openwrt/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"requirements": [],
"iot_class": "local_polling",
"config_flow": true,
"version": "0.1.0"
"version": "0.2.0"
}

0 comments on commit ac4f65a

Please sign in to comment.