mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Upgrade wled 0.4.1 (#36091)
This commit is contained in:
parent
94a9b364b0
commit
d2e6b863b7
@ -3,7 +3,7 @@
|
|||||||
"name": "WLED",
|
"name": "WLED",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/wled",
|
"documentation": "https://www.home-assistant.io/integrations/wled",
|
||||||
"requirements": ["wled==0.3.0"],
|
"requirements": ["wled==0.4.1"],
|
||||||
"zeroconf": ["_wled._tcp.local."],
|
"zeroconf": ["_wled._tcp.local."],
|
||||||
"codeowners": ["@frenck"],
|
"codeowners": ["@frenck"],
|
||||||
"quality_scale": "platinum"
|
"quality_scale": "platinum"
|
||||||
|
@ -2195,7 +2195,7 @@ wirelesstagpy==0.4.0
|
|||||||
withings-api==2.1.3
|
withings-api==2.1.3
|
||||||
|
|
||||||
# homeassistant.components.wled
|
# homeassistant.components.wled
|
||||||
wled==0.3.0
|
wled==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.xbee
|
# homeassistant.components.xbee
|
||||||
xbee-helper==0.0.7
|
xbee-helper==0.0.7
|
||||||
|
@ -898,7 +898,7 @@ wiffi==1.0.0
|
|||||||
withings-api==2.1.3
|
withings-api==2.1.3
|
||||||
|
|
||||||
# homeassistant.components.wled
|
# homeassistant.components.wled
|
||||||
wled==0.3.0
|
wled==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.bluesound
|
# homeassistant.components.bluesound
|
||||||
# homeassistant.components.rest
|
# homeassistant.components.rest
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""Tests for the WLED integration."""
|
"""Tests for the WLED integration."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
from homeassistant.components.wled.const import DOMAIN
|
from homeassistant.components.wled.const import DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC
|
from homeassistant.const import CONF_HOST, CONF_MAC
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -17,27 +19,29 @@ async def init_integration(
|
|||||||
"""Set up the WLED integration in Home Assistant."""
|
"""Set up the WLED integration in Home Assistant."""
|
||||||
|
|
||||||
fixture = "wled/rgb.json" if not rgbw else "wled/rgbw.json"
|
fixture = "wled/rgb.json" if not rgbw else "wled/rgbw.json"
|
||||||
|
data = json.loads(load_fixture(fixture))
|
||||||
|
|
||||||
aioclient_mock.get(
|
aioclient_mock.get(
|
||||||
"http://192.168.1.123:80/json/",
|
"http://192.168.1.123:80/json/",
|
||||||
text=load_fixture(fixture),
|
json=data,
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
)
|
)
|
||||||
|
|
||||||
aioclient_mock.post(
|
aioclient_mock.post(
|
||||||
"http://192.168.1.123:80/json/state",
|
"http://192.168.1.123:80/json/state",
|
||||||
json={},
|
json=data["state"],
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
)
|
)
|
||||||
|
|
||||||
aioclient_mock.get(
|
aioclient_mock.get(
|
||||||
"http://192.168.1.123:80/json/info",
|
"http://192.168.1.123:80/json/info",
|
||||||
json={},
|
json=data["info"],
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
)
|
)
|
||||||
|
|
||||||
aioclient_mock.get(
|
aioclient_mock.get(
|
||||||
"http://192.168.1.123:80/json/state",
|
"http://192.168.1.123:80/json/state",
|
||||||
json={},
|
json=data["state"],
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Tests for the WLED config flow."""
|
"""Tests for the WLED config flow."""
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
from wled import WLEDConnectionError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.wled import config_flow
|
from homeassistant.components.wled import config_flow
|
||||||
@ -9,6 +10,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
|
|
||||||
from . import init_integration
|
from . import init_integration
|
||||||
|
|
||||||
|
from tests.async_mock import MagicMock, patch
|
||||||
from tests.common import load_fixture
|
from tests.common import load_fixture
|
||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
|
|
||||||
@ -59,8 +61,9 @@ async def test_show_zerconf_form(
|
|||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
|
||||||
|
@patch("homeassistant.components.wled.WLED.update", side_effect=WLEDConnectionError)
|
||||||
async def test_connection_error(
|
async def test_connection_error(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we show user form on WLED connection error."""
|
"""Test we show user form on WLED connection error."""
|
||||||
aioclient_mock.get("http://example.com/json/", exc=aiohttp.ClientError)
|
aioclient_mock.get("http://example.com/json/", exc=aiohttp.ClientError)
|
||||||
@ -76,8 +79,9 @@ async def test_connection_error(
|
|||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
|
||||||
|
@patch("homeassistant.components.wled.WLED.update", side_effect=WLEDConnectionError)
|
||||||
async def test_zeroconf_connection_error(
|
async def test_zeroconf_connection_error(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we abort zeroconf flow on WLED connection error."""
|
"""Test we abort zeroconf flow on WLED connection error."""
|
||||||
aioclient_mock.get("http://192.168.1.123/json/", exc=aiohttp.ClientError)
|
aioclient_mock.get("http://192.168.1.123/json/", exc=aiohttp.ClientError)
|
||||||
@ -92,8 +96,9 @@ async def test_zeroconf_connection_error(
|
|||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
||||||
|
|
||||||
|
@patch("homeassistant.components.wled.WLED.update", side_effect=WLEDConnectionError)
|
||||||
async def test_zeroconf_confirm_connection_error(
|
async def test_zeroconf_confirm_connection_error(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we abort zeroconf flow on WLED connection error."""
|
"""Test we abort zeroconf flow on WLED connection error."""
|
||||||
aioclient_mock.get("http://192.168.1.123:80/json/", exc=aiohttp.ClientError)
|
aioclient_mock.get("http://192.168.1.123:80/json/", exc=aiohttp.ClientError)
|
||||||
@ -112,8 +117,9 @@ async def test_zeroconf_confirm_connection_error(
|
|||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
||||||
|
|
||||||
|
@patch("homeassistant.components.wled.WLED.update", side_effect=WLEDConnectionError)
|
||||||
async def test_zeroconf_no_data(
|
async def test_zeroconf_no_data(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
update_mock: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we abort if zeroconf provides no data."""
|
"""Test we abort if zeroconf provides no data."""
|
||||||
flow = config_flow.WLEDFlowHandler()
|
flow = config_flow.WLEDFlowHandler()
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
"""Tests for the WLED integration."""
|
"""Tests for the WLED integration."""
|
||||||
import aiohttp
|
from wled import WLEDConnectionError
|
||||||
|
|
||||||
from homeassistant.components.wled.const import DOMAIN
|
from homeassistant.components.wled.const import DOMAIN
|
||||||
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY
|
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from tests.async_mock import MagicMock, patch
|
||||||
from tests.components.wled import init_integration
|
from tests.components.wled import init_integration
|
||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
|
|
||||||
|
|
||||||
|
@patch("homeassistant.components.wled.WLED.update", side_effect=WLEDConnectionError)
|
||||||
async def test_config_entry_not_ready(
|
async def test_config_entry_not_ready(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
mock_update: MagicMock, hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the WLED configuration entry not ready."""
|
"""Test the WLED configuration entry not ready."""
|
||||||
aioclient_mock.get("http://192.168.1.123:80/json/", exc=aiohttp.ClientError)
|
|
||||||
|
|
||||||
entry = await init_integration(hass, aioclient_mock)
|
entry = await init_integration(hass, aioclient_mock)
|
||||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Tests for the WLED light platform."""
|
"""Tests for the WLED light platform."""
|
||||||
import aiohttp
|
from wled import WLEDConnectionError
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
@ -144,7 +144,7 @@ async def test_light_error(
|
|||||||
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
|
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
|
||||||
await init_integration(hass, aioclient_mock)
|
await init_integration(hass, aioclient_mock)
|
||||||
|
|
||||||
with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
|
with patch("homeassistant.components.wled.WLED.update"):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
LIGHT_DOMAIN,
|
LIGHT_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
@ -162,10 +162,11 @@ async def test_light_connection_error(
|
|||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error handling of the WLED switches."""
|
"""Test error handling of the WLED switches."""
|
||||||
aioclient_mock.post("http://192.168.1.123:80/json/state", exc=aiohttp.ClientError)
|
|
||||||
await init_integration(hass, aioclient_mock)
|
await init_integration(hass, aioclient_mock)
|
||||||
|
|
||||||
with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
|
with patch("homeassistant.components.wled.WLED.update"), patch(
|
||||||
|
"homeassistant.components.wled.WLED.light", side_effect=WLEDConnectionError
|
||||||
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
LIGHT_DOMAIN,
|
LIGHT_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
@ -342,7 +343,7 @@ async def test_effect_service_error(
|
|||||||
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
|
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
|
||||||
await init_integration(hass, aioclient_mock)
|
await init_integration(hass, aioclient_mock)
|
||||||
|
|
||||||
with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
|
with patch("homeassistant.components.wled.WLED.update"):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_EFFECT,
|
SERVICE_EFFECT,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Tests for the WLED switch platform."""
|
"""Tests for the WLED switch platform."""
|
||||||
import aiohttp
|
from wled import WLEDConnectionError
|
||||||
|
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
from homeassistant.components.wled.const import (
|
from homeassistant.components.wled.const import (
|
||||||
@ -142,7 +142,7 @@ async def test_switch_error(
|
|||||||
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
|
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
|
||||||
await init_integration(hass, aioclient_mock)
|
await init_integration(hass, aioclient_mock)
|
||||||
|
|
||||||
with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
|
with patch("homeassistant.components.wled.WLED.update"):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH_DOMAIN,
|
SWITCH_DOMAIN,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
@ -160,10 +160,11 @@ async def test_switch_connection_error(
|
|||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test error handling of the WLED switches."""
|
"""Test error handling of the WLED switches."""
|
||||||
aioclient_mock.post("http://192.168.1.123:80/json/state", exc=aiohttp.ClientError)
|
|
||||||
await init_integration(hass, aioclient_mock)
|
await init_integration(hass, aioclient_mock)
|
||||||
|
|
||||||
with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
|
with patch("homeassistant.components.wled.WLED.update"), patch(
|
||||||
|
"homeassistant.components.wled.WLED.nightlight", side_effect=WLEDConnectionError
|
||||||
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH_DOMAIN,
|
SWITCH_DOMAIN,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user