Use loader.async_suggest_report_issue in sensor (#101389)

This commit is contained in:
Erik Montnemery 2023-10-05 20:07:56 +02:00 committed by GitHub
parent 716a10e556
commit 659d437cac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 14 deletions

View File

@ -33,6 +33,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant, State, split_entity_id
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity import entity_sources
from homeassistant.loader import async_suggest_report_issue
from homeassistant.util import dt as dt_util
from homeassistant.util.enum import try_parse_enum
@ -257,20 +258,10 @@ def _normalize_states(
def _suggest_report_issue(hass: HomeAssistant, entity_id: str) -> str:
"""Suggest to report an issue."""
entity_info = entity_sources(hass).get(entity_id)
domain = entity_info["domain"] if entity_info else None
custom_component = entity_info["custom_component"] if entity_info else None
report_issue = ""
if custom_component:
report_issue = "report it to the custom integration author."
else:
report_issue = (
"create a bug report at "
"https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue"
)
if domain:
report_issue += f"+label%3A%22integration%3A+{domain}%22"
return report_issue
return async_suggest_report_issue(
hass, integration_domain=entity_info["domain"] if entity_info else None
)
def warn_dip(

View File

@ -1337,7 +1337,7 @@ def test_compile_hourly_sum_statistics_nan_inf_state(
"energy",
0,
"from integration test ",
"report it to the custom integration author",
"report it to the author of the 'test' custom integration",
),
],
)