added sensors for HPE switch

This commit is contained in:
Gorden Mende
2026-07-15 10:28:33 +02:00
parent 87275eb7c3
commit 33b85dd32e
75 changed files with 10272 additions and 4001 deletions
+25 -19
View File
@@ -1,17 +1,21 @@
"""Omnik Inverter platform configuration."""
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from .const import CONFIGFLOW_VERSION, DOMAIN, LOGGER
from .const import CONFIGFLOW_VERSION, LOGGER
from .coordinator import OmnikInverterDataUpdateCoordinator
type OmnikInverterConfigEntry = ConfigEntry[OmnikInverterDataUpdateCoordinator]
PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""
Set up OmnikInverter as config entry.
async def async_setup_entry(
hass: HomeAssistant, entry: OmnikInverterConfigEntry
) -> bool:
"""Set up OmnikInverter as config entry.
Args:
hass: The HomeAssistant instance.
@@ -19,21 +23,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Returns:
Return true after setting up.
"""
hass.data.setdefault(DOMAIN, {})
"""
coordinator = OmnikInverterDataUpdateCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh()
hass.data[DOMAIN][entry.entry_id] = coordinator
entry.runtime_data = 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.
async def async_unload_entry(
hass: HomeAssistant, entry: OmnikInverterConfigEntry
) -> bool:
"""Unload a config entry.
Args:
hass: The HomeAssistant instance.
@@ -41,29 +45,31 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Returns:
Return true if unload was successful, false otherwise.
"""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
async def async_migrate_entry(
hass: HomeAssistant, config_entry: ConfigEntry # pylint: disable=unused-argument
):
"""
Migrate an old entry.
_hass: HomeAssistant,
config_entry: ConfigEntry,
) -> bool:
"""Migrate an old entry.
Args:
hass: The HomeAssistant instance.
_hass: The HomeAssistant instance.
config_entry: The ConfigEntry containing the user input.
Returns:
Return false, not possible.
"""
if config_entry.version <= 2:
LOGGER.warning(
"Impossible to migrate config version from version %s to version %s.\r\nPlease consider to delete and re-add the integration.", # noqa: E501
"Impossible to migrate config version from version %s to version %s."
"\r\nPlease consider to delete and re-add the integration.",
config_entry.version,
CONFIGFLOW_VERSION,
)
return False
return False