From 659d437cac50a6dc1148e48cb843ccc54b4c8598 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 5 Oct 2023 20:07:56 +0200 Subject: [PATCH] Use loader.async_suggest_report_issue in sensor (#101389) --- homeassistant/components/sensor/recorder.py | 17 ++++------------- tests/components/sensor/test_recorder.py | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/sensor/recorder.py b/homeassistant/components/sensor/recorder.py index 2ef1b6854fc..cb5a81d6b84 100644 --- a/homeassistant/components/sensor/recorder.py +++ b/homeassistant/components/sensor/recorder.py @@ -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( diff --git a/tests/components/sensor/test_recorder.py b/tests/components/sensor/test_recorder.py index 1c0200e1b53..34aaeda6740 100644 --- a/tests/components/sensor/test_recorder.py +++ b/tests/components/sensor/test_recorder.py @@ -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", ), ], )