Skip to content

Commit

Permalink
Merge pull request #103 from hmn/reset-filter-alarm
Browse files Browse the repository at this point in the history
reset filter alarm feature
  • Loading branch information
hmn authored Nov 9, 2024
2 parents 381935d + 9bdb3e3 commit 6bacec6
Show file tree
Hide file tree
Showing 13 changed files with 902 additions and 166 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ Integration for https://www.siku.at/produkte/ wifi fans

The fan is sold under different brands, for instance :

- [SIKU RV/Twinfresh](https://www.siku.at/produkte/)
- [SIKU RV](https://www.siku.at/produkte/)
- [Blauberg Group](https://blauberg-group.com)
- [Blauberg Ventilatoren](https://blaubergventilatoren.de/en/catalog/single-room-reversible-units-vento/functions/2899)
- [VENTS Twinfresh](https://ventilation-system.com/catalog/decentralized-hru-for-residential-use/)
- [DUKA One](https://dukaventilation.dk/produkter/1-rums-ventilationsloesninger)
- [Oxxify](https://raumluft-shop.de/lueftung/dezentrale-lueftungsanlage-mit-waermerueckgewinnung/oxxify.html)
- [Twinfresh](https://foris.no/produktkategori/miniventilasjon/miniventilasjon-miniventilasjon/)
Expand Down
55 changes: 53 additions & 2 deletions custom_components/siku/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
"""The Siku Fan integration."""

from __future__ import annotations
import logging

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import DOMAIN
from .const import DOMAIN, DEFAULT_NAME
from .coordinator import SikuDataUpdateCoordinator

PLATFORMS: list[Platform] = [Platform.FAN, Platform.SENSOR]
_LOGGER = logging.getLogger(__name__)

PLATFORMS: list[Platform] = [Platform.FAN, Platform.SENSOR, Platform.BUTTON]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand All @@ -33,5 +37,52 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return unload_ok


async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Migrate old entry."""
_LOGGER.debug(
"Migrating configuration from version %s.%s",
config_entry.version,
config_entry.minor_version,
)

if config_entry.version > 1:
# This means the user has downgraded from a future version
return False

if config_entry.version == 1:
new_data = {**config_entry.data}

if config_entry.minor_version < 1:
host = config_entry.data[CONF_IP_ADDRESS]
port = config_entry.data[CONF_PORT]
unique_id = f"{host}:{port}"
fix_names = [
f"{DOMAIN} {host}:{port}",
f"{DEFAULT_NAME} {host}:{port}",
f"{DOMAIN} {host}",
f"{host}:{port}",
]
if config_entry.title in fix_names:
title = f"{DEFAULT_NAME} {host}"
else:
title = config_entry.title
hass.config_entries.async_update_entry(
config_entry,
data=new_data,
unique_id=unique_id,
title=title,
version=1,
minor_version=1,
)

_LOGGER.debug(
"Migration to configuration version %s.%s successful",
config_entry.version,
config_entry.minor_version,
)

return True


class SikuEntity(CoordinatorEntity[SikuDataUpdateCoordinator]):
"""Representation of a siku entity."""
Loading

0 comments on commit 6bacec6

Please sign in to comment.