Add suggested area for zwave_js devices (#47250)
parent
c6cfcc2abb
commit
3e34bb3e89
|
@ -67,14 +67,17 @@ def register_node_in_dev_reg(
|
||||||
node: ZwaveNode,
|
node: ZwaveNode,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Register node in dev reg."""
|
"""Register node in dev reg."""
|
||||||
device = dev_reg.async_get_or_create(
|
params = {
|
||||||
config_entry_id=entry.entry_id,
|
"config_entry_id": entry.entry_id,
|
||||||
identifiers={get_device_id(client, node)},
|
"identifiers": {get_device_id(client, node)},
|
||||||
sw_version=node.firmware_version,
|
"sw_version": node.firmware_version,
|
||||||
name=node.name or node.device_config.description or f"Node {node.node_id}",
|
"name": node.name or node.device_config.description or f"Node {node.node_id}",
|
||||||
model=node.device_config.label,
|
"model": node.device_config.label,
|
||||||
manufacturer=node.device_config.manufacturer,
|
"manufacturer": node.device_config.manufacturer,
|
||||||
)
|
}
|
||||||
|
if node.location:
|
||||||
|
params["suggested_area"] = node.location
|
||||||
|
device = dev_reg.async_get_or_create(**params)
|
||||||
|
|
||||||
async_dispatcher_send(hass, EVENT_DEVICE_ADDED_TO_REGISTRY, device)
|
async_dispatcher_send(hass, EVENT_DEVICE_ADDED_TO_REGISTRY, device)
|
||||||
|
|
||||||
|
|
|
@ -16,3 +16,6 @@ PROPERTY_DOOR_STATUS_BINARY_SENSOR = (
|
||||||
CLIMATE_RADIO_THERMOSTAT_ENTITY = "climate.z_wave_thermostat"
|
CLIMATE_RADIO_THERMOSTAT_ENTITY = "climate.z_wave_thermostat"
|
||||||
CLIMATE_DANFOSS_LC13_ENTITY = "climate.living_connect_z_thermostat"
|
CLIMATE_DANFOSS_LC13_ENTITY = "climate.living_connect_z_thermostat"
|
||||||
CLIMATE_FLOOR_THERMOSTAT_ENTITY = "climate.floor_thermostat"
|
CLIMATE_FLOOR_THERMOSTAT_ENTITY = "climate.floor_thermostat"
|
||||||
|
BULB_6_MULTI_COLOR_LIGHT_ENTITY = "light.bulb_6_multi_color"
|
||||||
|
EATON_RF9640_ENTITY = "light.allloaddimmer"
|
||||||
|
AEON_SMART_SWITCH_LIGHT_ENTITY = "light.smart_switch_6"
|
||||||
|
|
|
@ -10,9 +10,7 @@ from zwave_js_server.model.driver import Driver
|
||||||
from zwave_js_server.model.node import Node
|
from zwave_js_server.model.node import Node
|
||||||
from zwave_js_server.version import VersionInfo
|
from zwave_js_server.version import VersionInfo
|
||||||
|
|
||||||
from homeassistant.helpers.device_registry import (
|
from homeassistant.helpers.device_registry import async_get as async_get_device_registry
|
||||||
async_get_registry as async_get_device_registry,
|
|
||||||
)
|
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, load_fixture
|
from tests.common import MockConfigEntry, load_fixture
|
||||||
|
|
||||||
|
@ -20,7 +18,7 @@ from tests.common import MockConfigEntry, load_fixture
|
||||||
@pytest.fixture(name="device_registry")
|
@pytest.fixture(name="device_registry")
|
||||||
async def device_registry_fixture(hass):
|
async def device_registry_fixture(hass):
|
||||||
"""Return the device registry."""
|
"""Return the device registry."""
|
||||||
return await async_get_device_registry(hass)
|
return async_get_device_registry(hass)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="controller_state", scope="session")
|
@pytest.fixture(name="controller_state", scope="session")
|
||||||
|
|
|
@ -18,7 +18,11 @@ from homeassistant.config_entries import (
|
||||||
from homeassistant.const import STATE_UNAVAILABLE
|
from homeassistant.const import STATE_UNAVAILABLE
|
||||||
from homeassistant.helpers import device_registry, entity_registry
|
from homeassistant.helpers import device_registry, entity_registry
|
||||||
|
|
||||||
from .common import AIR_TEMPERATURE_SENSOR, NOTIFICATION_MOTION_BINARY_SENSOR
|
from .common import (
|
||||||
|
AIR_TEMPERATURE_SENSOR,
|
||||||
|
EATON_RF9640_ENTITY,
|
||||||
|
NOTIFICATION_MOTION_BINARY_SENSOR,
|
||||||
|
)
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -467,3 +471,17 @@ async def test_removed_device(hass, client, multiple_devices, integration):
|
||||||
)
|
)
|
||||||
assert len(entity_entries) == 15
|
assert len(entity_entries) == 15
|
||||||
assert dev_reg.async_get_device({get_device_id(client, old_node)}) is None
|
assert dev_reg.async_get_device({get_device_id(client, old_node)}) is None
|
||||||
|
|
||||||
|
|
||||||
|
async def test_suggested_area(hass, client, eaton_rf9640_dimmer):
|
||||||
|
"""Test that suggested area works."""
|
||||||
|
dev_reg = device_registry.async_get(hass)
|
||||||
|
ent_reg = entity_registry.async_get(hass)
|
||||||
|
|
||||||
|
entry = MockConfigEntry(domain="zwave_js", data={"url": "ws://test.org"})
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
entity = ent_reg.async_get(EATON_RF9640_ENTITY)
|
||||||
|
assert dev_reg.async_get(entity.device_id).area_id is not None
|
||||||
|
|
|
@ -12,9 +12,11 @@ from homeassistant.components.light import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON
|
from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON
|
||||||
|
|
||||||
BULB_6_MULTI_COLOR_LIGHT_ENTITY = "light.bulb_6_multi_color"
|
from .common import (
|
||||||
EATON_RF9640_ENTITY = "light.allloaddimmer"
|
AEON_SMART_SWITCH_LIGHT_ENTITY,
|
||||||
AEON_SMART_SWITCH_LIGHT_ENTITY = "light.smart_switch_6"
|
BULB_6_MULTI_COLOR_LIGHT_ENTITY,
|
||||||
|
EATON_RF9640_ENTITY,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_light(hass, client, bulb_6_multi_color, integration):
|
async def test_light(hass, client, bulb_6_multi_color, integration):
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"nodeType": 0,
|
"nodeType": 0,
|
||||||
"roleType": 5,
|
"roleType": 5,
|
||||||
"name": "AllLoadDimmer",
|
"name": "AllLoadDimmer",
|
||||||
"location": "",
|
"location": "LivingRoom",
|
||||||
"deviceConfig": {
|
"deviceConfig": {
|
||||||
"manufacturerId": 26,
|
"manufacturerId": 26,
|
||||||
"manufacturer": "Eaton",
|
"manufacturer": "Eaton",
|
||||||
|
|
Loading…
Reference in New Issue