Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IceBotYT committed Nov 28, 2023
1 parent 38c051f commit 7eaa7f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
6 changes: 0 additions & 6 deletions homeassistant/components/peco/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Config flow for PECO Outage Counter integration."""
from __future__ import annotations

import asyncio
import logging
from typing import Any

Expand Down Expand Up @@ -63,11 +62,6 @@ async def async_step_user(
) -> FlowResult:
"""Handle the initial step."""
if self.meter_verification is True:
if "phone_number" in self.meter_error:
if self.meter_error["phone_number"] == "invalid_phone_number":
await asyncio.sleep(
0.1
) # If I don't have this here, it will be stuck on the loading symbol
return self.async_show_progress_done(next_step_id="finish_smart_meter")

if user_input is None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/peco/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"data_description": {
"county": "County used for outage number retrieval",
"phone_number": "Phone number associated with the PECO account"
"phone_number": "Phone number associated with the PECO account (optional). Adding a phone number adds a binary sensor confirming if your power is out or not, and not an issue with a breaker or an issue on your end."
}
}
},
Expand Down
16 changes: 7 additions & 9 deletions tests/components/peco/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from unittest.mock import patch

from peco import HttpError, IncompatibleMeterError, UnresponsiveMeterError
import pytest
from voluptuous.error import MultipleInvalid

from homeassistant import config_entries
from homeassistant.components.peco.const import DOMAIN
Expand Down Expand Up @@ -35,6 +37,7 @@ async def test_form(hass: HomeAssistant) -> None:
assert result2["data"] == {
"county": "PHILADELPHIA",
}
assert result2["context"]["unique_id"] == "PHILADELPHIA"


async def test_invalid_county(hass: HomeAssistant) -> None:
Expand All @@ -48,21 +51,15 @@ async def test_invalid_county(hass: HomeAssistant) -> None:
with patch(
"homeassistant.components.peco.async_setup_entry",
return_value=True,
):
result2 = await hass.config_entries.flow.async_configure(
), pytest.raises(MultipleInvalid):
await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"county": "PHILADELPHIA",
"county": "INVALID_COUNTY_THAT_SHOULDNT_EXIST",
},
)
await hass.async_block_till_done()

assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["title"] == "Philadelphia Outage Count"
assert result2["data"] == {
"county": "PHILADELPHIA",
}


async def test_meter_value_error(hass: HomeAssistant) -> None:
"""Test if the MeterValueError error works."""
Expand Down Expand Up @@ -205,3 +202,4 @@ async def test_smart_meter(hass: HomeAssistant) -> None:
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["title"] == "Philadelphia - 1234567890"
assert result["data"]["phone_number"] == "1234567890"
assert result["context"]["unique_id"] == "PHILADELPHIA-1234567890"

0 comments on commit 7eaa7f9

Please sign in to comment.