Skip to content

Commit

Permalink
Fix wrong error message on adding a new HomematicIP Cloud AP (home-as…
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Sep 3, 2020
1 parent aecd74c commit f2f6885
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions homeassistant/components/homematicip_cloud/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ async def async_step_init(self, user_input=None) -> Dict[str, Any]:
_LOGGER.info("Connection to HomematicIP Cloud established")
return await self.async_step_link()

_LOGGER.info("Connection to HomematicIP Cloud failed")
errors["base"] = "invalid_sgtin_or_pin"

return self.async_show_form(
step_id="init",
data_schema=vol.Schema(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/homematicip_cloud/hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def async_setup(self) -> bool:
self.auth = await self.get_auth(
self.hass, self.config.get(HMIPC_HAPID), self.config.get(HMIPC_PIN)
)
return True
return self.auth is not None
except HmipcConnectionError:
return False

Expand Down Expand Up @@ -63,7 +63,7 @@ async def get_auth(self, hass: HomeAssistantType, hapid, pin):
auth.pin = pin
await auth.connectionRequest("HomeAssistant")
except HmipConnectionError:
return False
return None
return auth


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homematicip_cloud/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"error": {
"register_failed": "Failed to register, please try again.",
"invalid_pin": "Invalid PIN, please try again.",
"invalid_sgtin_or_pin": "Invalid SGTIN or PIN, please try again.",
"press_the_button": "Please press the blue button.",
"timeout_button": "Blue button press timeout, please try again."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"unknown": "Unknown error occurred."
},
"error": {
"invalid_pin": "Invalid PIN, please try again.",
"invalid_sgtin_or_pin": "Invalid SGTIN or PIN, please try again.",
"press_the_button": "Please press the blue button.",
"register_failed": "Failed to register, please try again.",
"timeout_button": "Blue button press timeout, please try again."
Expand Down
4 changes: 1 addition & 3 deletions tests/components/homematicip_cloud/test_hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ async def test_auth_create_exception(hass, simple_mock_auth):
"homeassistant.components.homematicip_cloud.hap.AsyncAuth",
return_value=simple_mock_auth,
):
assert await hmip_auth.async_setup()
await hass.async_block_till_done()
assert not hmip_auth.auth
assert not await hmip_auth.async_setup()

with patch(
"homeassistant.components.homematicip_cloud.hap.AsyncAuth",
Expand Down

0 comments on commit f2f6885

Please sign in to comment.