Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset filter alarm feature #103

Merged
merged 8 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading