Implement local discovery of Smappee legacy devices (#37812)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
1 parent
65f1e0c71a
commit
07de9deab6
14 files changed
+708
-60
No files matched your search
@@ -0,0 +1,32 @@
|
||||
"""Tests for the Smappee component init module."""
|
||||
from homeassistant.components.smappee.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_ZEROCONF
|
||||
|
||||
from tests.async_mock import patch
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_unload_config_entry(hass):
|
||||
"""Test unload config entry flow."""
|
||||
with patch("pysmappee.api.SmappeeLocalApi.logon", return_value={}), patch(
|
||||
"pysmappee.api.SmappeeLocalApi.load_advanced_config",
|
||||
return_value=[{"key": "mdnsHostName", "value": "Smappee1006000212"}],
|
||||
), patch(
|
||||
"pysmappee.api.SmappeeLocalApi.load_command_control_config", return_value=[]
|
||||
), patch(
|
||||
"pysmappee.api.SmappeeLocalApi.load_instantaneous",
|
||||
return_value=[{"key": "phase0ActivePower", "value": 0}],
|
||||
):
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={"host": "1.2.3.4"},
|
||||
unique_id="smappee1006000212",
|
||||
source=SOURCE_ZEROCONF,
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
|
||||
entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert not hass.data.get(DOMAIN)
|
||||
Reference in new issue
Block a user