1 """The P1 Monitor integration."""
3 from __future__
import annotations
10 from .const
import LOGGER
11 from .coordinator
import P1MonitorDataUpdateCoordinator
13 PLATFORMS: list[Platform] = [Platform.SENSOR]
15 type P1MonitorConfigEntry = ConfigEntry[P1MonitorDataUpdateCoordinator]
19 """Set up P1 Monitor from a config entry."""
23 await coordinator.async_config_entry_first_refresh()
24 except ConfigEntryNotReady:
25 await coordinator.p1monitor.close()
28 entry.runtime_data = coordinator
30 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
35 """Migrate old entry."""
36 LOGGER.debug(
"Migrating from version %s", config_entry.version)
38 if config_entry.version == 1:
40 host = config_entry.data[CONF_HOST]
42 host, port = host.split(
":")
52 hass.config_entries.async_update_entry(config_entry, data=new_data, version=2)
53 LOGGER.debug(
"Migration to version %s successful", config_entry.version)
58 """Unload P1 Monitor config entry."""
59 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_migrate_entry(HomeAssistant hass, ConfigEntry config_entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)