* add webmin integration 1 * refactor, add memory sensors * Fix docstring * addressed reviews * address reviews * address reviews * use translation strings for sensors * add async_abort_entries_match * apply review comments * address reviews * add async_set_unique_id * add identifiers to device_info * disable all sensors by default * move icons to icons.json * show Faults when given from server in config flow * add test for Fault * Apply review suggestions * Create helper functions for webmin instance and sorted mac addresses * fix tests
30 lines
980 B
Python
30 lines
980 B
Python
"""The Webmin integration."""
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import WebminUpdateCoordinator
|
|
|
|
PLATFORMS = [Platform.SENSOR]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up Webmin from a config entry."""
|
|
|
|
coordinator = WebminUpdateCoordinator(hass, entry)
|
|
await coordinator.async_config_entry_first_refresh()
|
|
await coordinator.async_setup()
|
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
|
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Unload a config entry."""
|
|
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
|
hass.data[DOMAIN].pop(entry.entry_id)
|
|
|
|
return unload_ok
|