mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Switch screenlogic discovery to use async version (#49650)
This commit is contained in:
parent
3fa8ffa731
commit
0862212942
@ -89,7 +89,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
|
|||||||
@property
|
@property
|
||||||
def temperature_unit(self) -> str:
|
def temperature_unit(self) -> str:
|
||||||
"""Return the unit of measurement."""
|
"""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_CELSIUS
|
||||||
return TEMP_FAHRENHEIT
|
return TEMP_FAHRENHEIT
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Config flow for ScreenLogic."""
|
"""Config flow for ScreenLogic."""
|
||||||
import logging
|
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.const import SL_GATEWAY_IP, SL_GATEWAY_NAME, SL_GATEWAY_PORT
|
||||||
from screenlogicpy.requests import login
|
from screenlogicpy.requests import login
|
||||||
import voluptuous as vol
|
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."""
|
"""Discover gateways and return a dict of them by unique id."""
|
||||||
discovered_gateways = {}
|
discovered_gateways = {}
|
||||||
try:
|
try:
|
||||||
hosts = await hass.async_add_executor_job(discover)
|
hosts = await discovery.async_discover()
|
||||||
_LOGGER.debug("Discovered hosts: %s", hosts)
|
_LOGGER.debug("Discovered hosts: %s", hosts)
|
||||||
except ScreenLogicError as ex:
|
except ScreenLogicError as ex:
|
||||||
_LOGGER.debug(ex)
|
_LOGGER.debug(ex)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Pentair ScreenLogic",
|
"name": "Pentair ScreenLogic",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/screenlogic",
|
"documentation": "https://www.home-assistant.io/integrations/screenlogic",
|
||||||
"requirements": ["screenlogicpy==0.3.0"],
|
"requirements": ["screenlogicpy==0.4.1"],
|
||||||
"codeowners": ["@dieselrabbit"],
|
"codeowners": ["@dieselrabbit"],
|
||||||
"dhcp": [
|
"dhcp": [
|
||||||
{
|
{
|
||||||
|
@ -2033,7 +2033,7 @@ scapy==2.4.5
|
|||||||
schiene==0.23
|
schiene==0.23
|
||||||
|
|
||||||
# homeassistant.components.screenlogic
|
# homeassistant.components.screenlogic
|
||||||
screenlogicpy==0.3.0
|
screenlogicpy==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.scsgate
|
# homeassistant.components.scsgate
|
||||||
scsgate==0.1.0
|
scsgate==0.1.0
|
||||||
|
@ -1082,7 +1082,7 @@ samsungtvws==1.6.0
|
|||||||
scapy==2.4.5
|
scapy==2.4.5
|
||||||
|
|
||||||
# homeassistant.components.screenlogic
|
# homeassistant.components.screenlogic
|
||||||
screenlogicpy==0.3.0
|
screenlogicpy==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.emulated_kasa
|
# homeassistant.components.emulated_kasa
|
||||||
# homeassistant.components.sense
|
# homeassistant.components.sense
|
||||||
|
@ -30,7 +30,7 @@ async def test_flow_discovery(hass):
|
|||||||
"""Test the flow works with basic discovery."""
|
"""Test the flow works with basic discovery."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.screenlogic.config_flow.discover",
|
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
|
||||||
return_value=[
|
return_value=[
|
||||||
{
|
{
|
||||||
SL_GATEWAY_IP: "1.1.1.1",
|
SL_GATEWAY_IP: "1.1.1.1",
|
||||||
@ -74,7 +74,7 @@ async def test_flow_discover_none(hass):
|
|||||||
"""Test when nothing is discovered."""
|
"""Test when nothing is discovered."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.screenlogic.config_flow.discover",
|
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
|
||||||
return_value=[],
|
return_value=[],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -90,7 +90,7 @@ async def test_flow_discover_error(hass):
|
|||||||
"""Test when discovery errors."""
|
"""Test when discovery errors."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.screenlogic.config_flow.discover",
|
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
|
||||||
side_effect=ScreenLogicError("Fake error"),
|
side_effect=ScreenLogicError("Fake error"),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -182,7 +182,7 @@ async def test_form_manual_entry(hass):
|
|||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.screenlogic.config_flow.discover",
|
"homeassistant.components.screenlogic.config_flow.discovery.async_discover",
|
||||||
return_value=[
|
return_value=[
|
||||||
{
|
{
|
||||||
SL_GATEWAY_IP: "1.1.1.1",
|
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):
|
async def test_form_cannot_connect(hass):
|
||||||
"""Test we handle cannot connect error."""
|
"""Test we handle cannot connect error."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
with patch(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
"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(
|
with patch(
|
||||||
"homeassistant.components.screenlogic.config_flow.login.create_socket",
|
"homeassistant.components.screenlogic.config_flow.login.create_socket",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user