Add repair abort flow to demo integration (#82614)

This commit is contained in:
Joakim Sørensen 2022-11-24 14:54:41 +01:00 committed by GitHub
parent a856abf47f
commit d0390860fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 0 deletions

View File

@ -230,6 +230,15 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
translation_key="bad_psu", translation_key="bad_psu",
) )
async_create_issue(
hass,
DOMAIN,
"cold_tea",
is_fixable=True,
severity=IssueSeverity.WARNING,
translation_key="cold_tea",
)
return True return True

View File

@ -29,6 +29,16 @@ class DemoFixFlow(RepairsFlow):
return self.async_show_form(step_id="confirm", data_schema=vol.Schema({})) return self.async_show_form(step_id="confirm", data_schema=vol.Schema({}))
class DemoColdTeaFixFlow(RepairsFlow):
"""Handler for cold tea."""
async def async_step_init(
self, user_input: dict[str, str] | None = None
) -> data_entry_flow.FlowResult:
"""Handle the first step of a fix flow."""
return self.async_abort(reason="not_tea_time")
async def async_create_fix_flow( async def async_create_fix_flow(
hass: HomeAssistant, hass: HomeAssistant,
issue_id: str, issue_id: str,
@ -39,5 +49,9 @@ async def async_create_fix_flow(
# The bad_psu issue doesn't have its own flow # The bad_psu issue doesn't have its own flow
return ConfirmRepairFlow() return ConfirmRepairFlow()
if issue_id == "cold_tea":
# The cold_tea issue have it's own flow
return DemoColdTeaFixFlow()
# Other issues have a custom flow # Other issues have a custom flow
return DemoFixFlow() return DemoFixFlow()

View File

@ -23,6 +23,15 @@
} }
} }
}, },
"cold_tea": {
"title": "The tea is cold",
"fix_flow": {
"step": {},
"abort": {
"not_tea_time": "Can not re-heat the tea at this time"
}
}
},
"transmogrifier_deprecated": { "transmogrifier_deprecated": {
"title": "The transmogrifier component is deprecated", "title": "The transmogrifier component is deprecated",
"description": "The transmogrifier component is now deprecated due to the lack of local control available in the new API" "description": "The transmogrifier component is now deprecated due to the lack of local control available in the new API"

View File

@ -11,6 +11,15 @@
}, },
"title": "The power supply is not stable" "title": "The power supply is not stable"
}, },
"cold_tea": {
"fix_flow": {
"abort": {
"not_tea_time": "Can not re-heat the tea at this time"
},
"step": {}
},
"title": "The tea is cold"
},
"out_of_blinker_fluid": { "out_of_blinker_fluid": {
"fix_flow": { "fix_flow": {
"step": { "step": {
@ -33,6 +42,9 @@
}, },
"options": { "options": {
"step": { "step": {
"init": {
"data": {}
},
"options_1": { "options_1": {
"data": { "data": {
"bool": "Optional boolean", "bool": "Optional boolean",

View File

@ -192,6 +192,20 @@ async def test_issues_created(mock_history, hass, hass_client, hass_ws_client):
"translation_key": "bad_psu", "translation_key": "bad_psu",
"translation_placeholders": None, "translation_placeholders": None,
}, },
{
"breaks_in_ha_version": None,
"created": ANY,
"dismissed_version": None,
"domain": "demo",
"is_fixable": True,
"issue_domain": None,
"issue_id": "cold_tea",
"learn_more_url": None,
"severity": "warning",
"translation_key": "cold_tea",
"translation_placeholders": None,
"ignored": False,
},
] ]
} }
@ -280,5 +294,19 @@ async def test_issues_created(mock_history, hass, hass_client, hass_ws_client):
"translation_key": "bad_psu", "translation_key": "bad_psu",
"translation_placeholders": None, "translation_placeholders": None,
}, },
{
"breaks_in_ha_version": None,
"created": ANY,
"dismissed_version": None,
"domain": "demo",
"is_fixable": True,
"issue_domain": None,
"issue_id": "cold_tea",
"learn_more_url": None,
"severity": "warning",
"translation_key": "cold_tea",
"translation_placeholders": None,
"ignored": False,
},
] ]
} }