diff --git a/homeassistant/components/hassio/issues.py b/homeassistant/components/hassio/issues.py index c460731ad391a4..09e70a1e9fdb3b 100644 --- a/homeassistant/components/hassio/issues.py +++ b/homeassistant/components/hassio/issues.py @@ -115,8 +115,8 @@ def key(self) -> str: """Get key for suggestion (combination of context and type).""" return f"{self.context}_{self.type_}" - @staticmethod - def from_dict(data: SuggestionDataType) -> Suggestion: + @classmethod + def from_dict(cls, data: SuggestionDataType) -> Suggestion: """Convert from dictionary representation.""" return Suggestion( uuid=data["uuid"], @@ -151,8 +151,8 @@ def key(self) -> str: """Get key for issue (combination of context and type).""" return f"issue_{self.context}_{self.type_}" - @staticmethod - def from_dict(data: IssueDataType) -> Issue: + @classmethod + def from_dict(cls, data: IssueDataType) -> Issue: """Convert from dictionary representation.""" suggestions: list[SuggestionDataType] = data.get("suggestions", []) return Issue( @@ -244,6 +244,9 @@ def unsupported_reasons(self, reasons: set[str]) -> None: def add_issue(self, issue: Issue) -> None: """Add or update an issue in the list. Create or update a repair if necessary.""" if issue.key in ISSUE_KEYS_FOR_REPAIRS: + placeholders: dict[str, str] | None = None + if issue.reference: + placeholders = {PLACEHOLDER_KEY_REFERENCE: issue.reference} async_create_issue( self._hass, DOMAIN, @@ -251,9 +254,7 @@ def add_issue(self, issue: Issue) -> None: is_fixable=bool(issue.suggestions), severity=IssueSeverity.WARNING, translation_key=issue.key, - translation_placeholders={PLACEHOLDER_KEY_REFERENCE: issue.reference} - if issue.reference - else None, + translation_placeholders=placeholders, ) self._issues[issue.uuid] = issue diff --git a/homeassistant/components/hassio/repairs.py b/homeassistant/components/hassio/repairs.py index 5040243cc8de08..50a9b087a7cde5 100644 --- a/homeassistant/components/hassio/repairs.py +++ b/homeassistant/components/hassio/repairs.py @@ -59,12 +59,13 @@ def _async_form_for_suggestion(self, suggestion: Suggestion) -> FlowResult: async def async_step_init(self, _: None = None) -> FlowResult: """Handle the first step of a fix flow.""" - # Got out of sync with supervisor, issue is resolved or isn't fixable. Either way, resolve the repair + # Out of sync with supervisor, issue is resolved or not fixable. Remove it if not self.issue or not self.issue.suggestions: return self.async_create_entry(data={}) - # All suggestions do the same thing: apply them in supervisor, optionally with a confirmation step. - # Generating the required handler for each allows for shared logic but screens can still be translated per step id. + # All suggestions have the same logic: Apply them in supervisor, + # optionally with a confirmation step. Generating the required handler for each + # allows for shared logic but screens can still be translated per step id. for suggestion in self.issue.suggestions: setattr( self, @@ -79,7 +80,7 @@ async def async_step_init(self, _: None = None) -> FlowResult: description_placeholders=self.description_placeholders, ) - # Always show a form if there's only one suggestion so we can explain to the user what's happening + # Always show a form for one suggestion to explain to user what's happening return self._async_form_for_suggestion(self.issue.suggestions[0]) async def _async_step_apply_suggestion(