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

Blocking call in group #200

Merged
merged 4 commits into from
Oct 8, 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
50 changes: 27 additions & 23 deletions custom_components/plant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from . import group

import logging

import voluptuous as vol
Expand Down Expand Up @@ -81,29 +83,31 @@
SETUP_DUMMY_SENSORS = False
USE_DUMMY_SENSORS = False


async def async_setup(hass: HomeAssistant, config: dict):
"""
Set up the plant component

Configuration.yaml is no longer used.
This function only tries to migrate the legacy config.
"""
if config.get(DOMAIN):
# Only import if we haven't before.
config_entry = _async_find_matching_config_entry(hass)
if not config_entry:
_LOGGER.debug("Old setup - with config: %s", config[DOMAIN])
for plant in config[DOMAIN]:
if plant != DOMAIN_PLANTBOOK:
_LOGGER.info("Migrating plant: %s", plant)
await async_migrate_plant(hass, plant, config[DOMAIN][plant])
else:
_LOGGER.warning(
"Config already imported. Please delete all your %s related config from configuration.yaml",
DOMAIN,
)
return True
# Removed.
# Have not been used for a long time
#
# async def async_setup(hass: HomeAssistant, config: dict):
# """
# Set up the plant component
#
# Configuration.yaml is no longer used.
# This function only tries to migrate the legacy config.
# """
# if config.get(DOMAIN):
# # Only import if we haven't before.
# config_entry = _async_find_matching_config_entry(hass)
# if not config_entry:
# _LOGGER.debug("Old setup - with config: %s", config[DOMAIN])
# for plant in config[DOMAIN]:
# if plant != DOMAIN_PLANTBOOK:
# _LOGGER.info("Migrating plant: %s", plant)
# await async_migrate_plant(hass, plant, config[DOMAIN][plant])
# else:
# _LOGGER.warning(
# "Config already imported. Please delete all your %s related config from configuration.yaml",
# DOMAIN,
# )
# return True


@callback
Expand Down
8 changes: 5 additions & 3 deletions custom_components/plant/group.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
"""Describe group states."""

from __future__ import annotations
from typing import TYPE_CHECKING

from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_OK, STATE_PROBLEM
from homeassistant.core import HomeAssistant, callback

if TYPE_CHECKING:
from homeassistant.components.group import GroupIntegrationRegistry

from .const import DOMAIN


@callback
def async_describe_on_off_states(
hass: HomeAssistant, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: "GroupIntegrationRegistry"
) -> None:
"""Describe group on off states."""
registry.on_off_states(
Expand Down
Loading