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

Fix autodiscovery bug #1053

Merged
merged 1 commit into from
Aug 28, 2022
Merged
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
21 changes: 10 additions & 11 deletions custom_components/powercalc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,36 +257,35 @@ async def autodiscover_entities(config: dict, domain_config: dict, hass: HomeAss
if not await has_manufacturer_and_model_information(hass, entity_entry):
continue

has_user_config = is_user_configured(config, entity_entry.entity_id)

source_entity = await create_source_entity(entity_entry.entity_id, hass)
try:
power_profile = await get_power_profile(
hass, {}, source_entity.entity_entry
)
if power_profile.is_additional_configuration_required:
if not has_user_config:
_LOGGER.warning(
f"{entity_entry.entity_id}: Model found in database, but needs additional manual configuration to be loaded"
)
continue
if not power_profile:
continue
except ModelNotSupported:
_LOGGER.debug(
"%s: Model not found in library, skipping auto configuration",
entity_entry.entity_id,
)
continue

has_user_config = is_user_configured(config, entity_entry.entity_id)

if power_profile.is_additional_configuration_required and not has_user_config:
_LOGGER.warning(
f"{entity_entry.entity_id}: Model found in database, but needs additional manual configuration to be loaded"
)
continue

if has_user_config:
_LOGGER.debug(
"%s: Entity is manually configured, skipping auto configuration",
entity_entry.entity_id,
)
continue

if not power_profile:
continue

if not power_profile.is_entity_domain_supported(source_entity.domain):
continue

Expand Down