Skip to content

Add Gryfsmart integration #137753

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

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions homeassistant/components/gryfsmart/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""The Gryf Smart integration."""

from __future__ import annotations

from pygryfsmart.api import GryfApi

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady

from .const import CONF_API, CONF_COMMUNICATION, CONF_DEVICE_DATA, CONF_PORT, DOMAIN

_PLATFORMS: list[Platform] = [
Platform.LIGHT,
]


async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
) -> bool:
"""Config flow for Gryf Smart Integration."""

try:
api = GryfApi(entry.data[CONF_COMMUNICATION][CONF_PORT])
await api.start_connection()
api.start_update_interval(1)
except ConnectionError:
raise ConfigEntryNotReady("Unable to connect with device") from ConnectionError

entry.runtime_data = {}
entry.runtime_data[CONF_API] = api
entry.runtime_data[CONF_DEVICE_DATA] = {
"identifiers": {(DOMAIN, "Gryf Smart", entry.unique_id)},
"name": f"Gryf Smart {entry.unique_id}",
"manufacturer": "Gryf Smart",
"model": "serial",
"sw_version": "1.0.0",
"hw_version": "1.0.0",
}

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."""

return await hass.config_entries.async_unload_platforms(entry, _PLATFORMS)
Loading