Files
homeassistant-jackery/custom_components/JackeryHome/__init__.py
不求圣剑 ad4105af5e refactor: rename JackeryHome component directory and update references
- Renamed the `custom_components/jackery_home/` directory to `custom_components/JackeryHome/` for consistency with naming conventions.
- Updated all relevant documentation and scripts to reflect the new directory name.
- Removed obsolete files related to the previous directory structure.
2025-11-18 15:45:27 +08:00

40 lines
1.1 KiB
Python

"""Energy Monitor MQTT Integration for Home Assistant."""
import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.const import Platform
_LOGGER = logging.getLogger(__name__)
DOMAIN = "jackery_home"
PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up JackeryHome from a config entry."""
_LOGGER.info("Setting up JackeryHome integration")
# 存储配置数据
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = entry.data
# 加载传感器平台
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."""
_LOGGER.info("Unloading JackeryHome integration")
# 卸载传感器平台
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok