Switch screenlogic discovery to use async version (#49650)

pull/49655/head
J. Nick Koston 2021-04-25 00:41:40 -10:00 committed by GitHub
parent 3fa8ffa731
commit 0862212942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 13 deletions

View File

@ -89,7 +89,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
@property
def temperature_unit(self) -> str:
"""Return the unit of measurement."""
if self.config_data["is_celcius"]["value"] == 1:
if self.config_data["is_celsius"]["value"] == 1:
return TEMP_CELSIUS
return TEMP_FAHRENHEIT

View File

@ -1,7 +1,7 @@
"""Config flow for ScreenLogic."""
import logging
from screenlogicpy import ScreenLogicError, discover
from screenlogicpy import ScreenLogicError, discovery
from screenlogicpy.const import SL_GATEWAY_IP, SL_GATEWAY_NAME, SL_GATEWAY_PORT
from screenlogicpy.requests import login
import voluptuous as vol
@ -27,7 +27,7 @@ async def async_discover_gateways_by_unique_id(hass):
"""Discover gateways and return a dict of them by unique id."""
discovered_gateways = {}
try:
hosts = await hass.async_add_executor_job(discover)
hosts = await discovery.async_discover()
_LOGGER.debug("Discovered hosts: %s", hosts)
except ScreenLogicError as ex:
_LOGGER.debug(ex)

View File

@ -3,7 +3,7 @@
"name": "Pentair ScreenLogic",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/screenlogic",
"requirements": ["screenlogicpy==0.3.0"],
"requirements": ["screenlogicpy==0.4.1"],
"codeowners": ["@dieselrabbit"],
"dhcp": [
{

View File

@ -2033,7 +2033,7 @@ scapy==2.4.5
schiene==0.23
# homeassistant.components.screenlogic
screenlogicpy==0.3.0
screenlogicpy==0.4.1
# homeassistant.components.scsgate
scsgate==0.1.0

View File

@ -1082,7 +1082,7 @@ samsungtvws==1.6.0
scapy==2.4.5
# homeassistant.components.screenlogic
screenlogicpy==0.3.0
screenlogicpy==0.4.1
# homeassistant.components.emulated_kasa
# homeassistant.components.sense

View File

@ -30,7 +30,7 @@ async def test_flow_discovery(hass):
"""Test the flow works with basic discovery."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.screenlogic.config_flow.discover",
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[
{
SL_GATEWAY_IP: "1.1.1.1",
@ -74,7 +74,7 @@ async def test_flow_discover_none(hass):
"""Test when nothing is discovered."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.screenlogic.config_flow.discover",
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[],
):
result = await hass.config_entries.flow.async_init(
@ -90,7 +90,7 @@ async def test_flow_discover_error(hass):
"""Test when discovery errors."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.screenlogic.config_flow.discover",
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
side_effect=ScreenLogicError("Fake error"),
):
result = await hass.config_entries.flow.async_init(
@ -182,7 +182,7 @@ async def test_form_manual_entry(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.screenlogic.config_flow.discover",
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[
{
SL_GATEWAY_IP: "1.1.1.1",
@ -241,9 +241,13 @@ async def test_form_manual_entry(hass):
async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
return_value=[],
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.screenlogic.config_flow.login.create_socket",