mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Simplify endpoint naming
This commit is contained in:
@@ -655,18 +655,10 @@ def get_device_info(
|
||||
suggested_area=node.location or None,
|
||||
)
|
||||
|
||||
if endpoint.endpoint_label:
|
||||
endpoint_name = endpoint.endpoint_label
|
||||
elif endpoint.device_class:
|
||||
endpoint_name = f"{endpoint.device_class.specific.label} ({endpoint.index})"
|
||||
else:
|
||||
endpoint_name = f"Endpoint {endpoint.index}"
|
||||
# Prefix the child device name with the node name so it's clear which node the
|
||||
# endpoint child device belongs to.
|
||||
assert parent_device_id is not None
|
||||
return ChildDeviceInfo(
|
||||
identifiers={get_device_id(driver, node, endpoint.index)},
|
||||
name=f"{node_name} {endpoint_name}",
|
||||
name=endpoint.endpoint_label or f"Endpoint {endpoint.index}",
|
||||
parent_device_id=parent_device_id,
|
||||
)
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ BULB_6_MULTI_COLOR_LIGHT_ENTITY = "light.bulb_6_multi_color"
|
||||
EATON_RF9640_ENTITY = "light.livingroom_allloaddimmer"
|
||||
AEON_SMART_SWITCH_LIGHT_ENTITY = "light.smart_switch_6"
|
||||
SCHLAGE_BE469_LOCK_ENTITY = "lock.touchscreen_deadbolt"
|
||||
ZEN_31_ENTITY = "light.kitchen_kitchen_under_cabinet_lights_tunable_color_switch_1"
|
||||
ZEN_31_ENTITY = "light.kitchen_endpoint_1"
|
||||
METER_VOLTAGE_SENSOR = "sensor.smart_switch_6_electric_consumed_v"
|
||||
HUMIDIFIER_ADC_T3000_ENTITY = "humidifier.adc_t3000_humidifier"
|
||||
DEHUMIDIFIER_ADC_T3000_ENTITY = "humidifier.adc_t3000_dehumidifier"
|
||||
|
||||
@@ -975,7 +975,7 @@ async def test_temp_unit_fix(
|
||||
integration,
|
||||
) -> None:
|
||||
"""Test temperaturee unit fix."""
|
||||
state = hass.states.get("climate.thermostat_endpoint_1")
|
||||
state = hass.states.get("climate.endpoint_1")
|
||||
assert state
|
||||
assert state.attributes["current_temperature"] == 18.3
|
||||
|
||||
|
||||
@@ -54,12 +54,8 @@ BLIND_COVER_ENTITY = "cover.window_blind_controller"
|
||||
SHUTTER_COVER_ENTITY = "cover.flush_shutter"
|
||||
AEOTEC_SHUTTER_COVER_ENTITY = "cover.nano_shutter_v_3"
|
||||
FIBARO_FGR_222_SHUTTER_COVER_ENTITY = "cover.test_location_fgr_222_test_cover"
|
||||
FIBARO_FGR_223_SHUTTER_COVER_ENTITY = (
|
||||
"cover.test_location_fgr_223_test_cover_motor_control_class_b_1"
|
||||
)
|
||||
SHELLY_WAVE_SHUTTER_COVER_ENTITY = (
|
||||
"cover.shelly_fw_14_2_0_test_cover_motor_control_class_b_1"
|
||||
)
|
||||
FIBARO_FGR_223_SHUTTER_COVER_ENTITY = "cover.test_location_endpoint_1"
|
||||
SHELLY_WAVE_SHUTTER_COVER_ENTITY = "cover.endpoint_1"
|
||||
LOGGER.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
|
||||
@@ -716,9 +716,7 @@ async def test_refresh_value_action_endpoint_child_device(
|
||||
device = get_device(device_registry, driver, node, integration.entry_id)
|
||||
assert device
|
||||
|
||||
switch_entity = entity_registry.async_get(
|
||||
"switch.in_wall_dual_relay_switch_binary_power_switch_1"
|
||||
)
|
||||
switch_entity = entity_registry.async_get("switch.endpoint_1")
|
||||
assert switch_entity
|
||||
|
||||
assert await async_setup_component(
|
||||
|
||||
@@ -83,7 +83,7 @@ async def test_touchwand_glass9(
|
||||
|
||||
assert not hass.states.async_entity_ids_count("light")
|
||||
assert hass.states.async_entity_ids_count("cover") == 3
|
||||
state = hass.states.get("cover.gp9_motor_control_class_c_8")
|
||||
state = hass.states.get("cover.endpoint_8")
|
||||
assert state
|
||||
|
||||
|
||||
@@ -132,10 +132,10 @@ async def test_inovelli_lzw36(
|
||||
node = inovelli_lzw36
|
||||
assert node.device_class.specific.label == "Unused"
|
||||
|
||||
state = hass.states.get("light.family_room_combo_endpoint_1")
|
||||
state = hass.states.get("light.endpoint_1")
|
||||
assert state.state == "off"
|
||||
|
||||
state = hass.states.get("fan.family_room_combo_endpoint_2")
|
||||
state = hass.states.get("fan.endpoint_2")
|
||||
assert state
|
||||
|
||||
|
||||
@@ -144,8 +144,8 @@ async def test_vision_security_zl7432(
|
||||
) -> None:
|
||||
"""Test Vision Security ZL7432 is caught by the device specific discovery."""
|
||||
for entity_id in (
|
||||
"switch.in_wall_dual_relay_switch_binary_power_switch_1",
|
||||
"switch.in_wall_dual_relay_switch_binary_power_switch_2",
|
||||
"switch.endpoint_1",
|
||||
"switch.endpoint_2",
|
||||
):
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
@@ -212,7 +212,7 @@ async def test_merten_507801(
|
||||
state = hass.states.get("light.connect_roller_shutter")
|
||||
assert not state
|
||||
|
||||
state = hass.states.get("cover.connect_roller_shutter_unused_1")
|
||||
state = hass.states.get("cover.endpoint_1")
|
||||
assert state
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ async def test_shelly_001p10_disabled_entities(
|
||||
) -> None:
|
||||
"""Test that Shelly 001P10 entity created by endpoint 2 is disabled."""
|
||||
entity_ids = [
|
||||
"cover.wave_shutter_motor_control_class_b_2",
|
||||
"cover.endpoint_2",
|
||||
]
|
||||
for entity_id in entity_ids:
|
||||
state = hass.states.get(entity_id)
|
||||
@@ -243,7 +243,7 @@ async def test_shelly_001p10_disabled_entities(
|
||||
assert updated_entry.disabled is False
|
||||
|
||||
# Test if the main entity from endpoint 1 was created.
|
||||
state = hass.states.get("cover.wave_shutter_motor_control_class_b_1")
|
||||
state = hass.states.get("cover.endpoint_1")
|
||||
assert state
|
||||
|
||||
|
||||
@@ -256,9 +256,9 @@ async def test_merten_507801_disabled_enitites(
|
||||
) -> None:
|
||||
"""Test that Merten 507801 entities created by endpoint 2 are disabled."""
|
||||
entity_ids = [
|
||||
"cover.connect_roller_shutter_unused_2",
|
||||
"select.connect_roller_shutter_unused_2_local_protection_state",
|
||||
"select.connect_roller_shutter_unused_2_rf_protection_state",
|
||||
"cover.endpoint_2",
|
||||
"select.endpoint_2_local_protection_state",
|
||||
"select.endpoint_2_rf_protection_state",
|
||||
]
|
||||
for entity_id in entity_ids:
|
||||
state = hass.states.get(entity_id)
|
||||
|
||||
@@ -326,10 +326,7 @@ async def test_value_updated(
|
||||
)
|
||||
assert child_device
|
||||
assert events[0].data["device_id"] == child_device.id
|
||||
assert (
|
||||
events[0].data["entity_id"]
|
||||
== "switch.in_wall_dual_relay_switch_binary_power_switch_1"
|
||||
)
|
||||
assert events[0].data["entity_id"] == "switch.endpoint_1"
|
||||
assert events[0].data["command_class"] == CommandClass.SWITCH_BINARY
|
||||
assert events[0].data["command_class_name"] == "Switch Binary"
|
||||
assert events[0].data["endpoint"] == 1
|
||||
|
||||
@@ -546,7 +546,7 @@ async def test_inovelli_lzw36(
|
||||
"""Test an LZW36."""
|
||||
node = inovelli_lzw36
|
||||
node_id = 19
|
||||
entity_id = "fan.family_room_combo_endpoint_2"
|
||||
entity_id = "fan.endpoint_2"
|
||||
|
||||
async def get_zwave_speed_from_percentage(percentage):
|
||||
"""Set the fan to a particular percentage and get the resulting Zwave speed."""
|
||||
|
||||
@@ -1557,7 +1557,7 @@ async def test_endpoint_child_device(
|
||||
assert endpoint_1_device
|
||||
assert isinstance(endpoint_1_device, dr.ChildDeviceEntry)
|
||||
assert endpoint_1_device.parent_device_id == node_device.id
|
||||
assert endpoint_1_device.name == "In Wall Dual Relay Switch Binary Power Switch (1)"
|
||||
assert endpoint_1_device.name == "Endpoint 1"
|
||||
|
||||
endpoint_2_device = device_registry.async_get_child_device_by_identifier(
|
||||
get_device_id(driver, node, 2), integration.entry_id
|
||||
@@ -1565,7 +1565,7 @@ async def test_endpoint_child_device(
|
||||
assert endpoint_2_device
|
||||
assert isinstance(endpoint_2_device, dr.ChildDeviceEntry)
|
||||
assert endpoint_2_device.parent_device_id == node_device.id
|
||||
assert endpoint_2_device.name == "In Wall Dual Relay Switch Binary Power Switch (2)"
|
||||
assert endpoint_2_device.name == "Endpoint 2"
|
||||
|
||||
# Both child devices appear in the parent's children list.
|
||||
children = dr.async_entries_for_parent_device(device_registry, node_device.id)
|
||||
@@ -1575,14 +1575,10 @@ async def test_endpoint_child_device(
|
||||
}
|
||||
|
||||
# Each relay lives on its endpoint child device, not on the node device.
|
||||
entity_1 = entity_registry.async_get(
|
||||
"switch.in_wall_dual_relay_switch_binary_power_switch_1"
|
||||
)
|
||||
entity_1 = entity_registry.async_get("switch.endpoint_1")
|
||||
assert entity_1
|
||||
assert entity_1.device_id == endpoint_1_device.id
|
||||
entity_2 = entity_registry.async_get(
|
||||
"switch.in_wall_dual_relay_switch_binary_power_switch_2"
|
||||
)
|
||||
entity_2 = entity_registry.async_get("switch.endpoint_2")
|
||||
assert entity_2
|
||||
assert entity_2.device_id == endpoint_2_device.id
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ from .common import (
|
||||
ZEN_31_ENTITY,
|
||||
)
|
||||
|
||||
ZDB5100_ENTITY = "light.matrix_office_basic_wall_controller_1"
|
||||
ZDB5100_ENTITY = "light.endpoint_1"
|
||||
HSM200_V1_ENTITY = "light.basement_hsm200"
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from homeassistant.helpers import entity_registry as er
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
NUMBER_ENTITY = "number.thermostat_hvac_valve_control"
|
||||
VOLUME_NUMBER_ENTITY = "number.indoor_siren_6_sound_switch_2_default_volume"
|
||||
VOLUME_NUMBER_ENTITY = "number.endpoint_2_default_volume"
|
||||
|
||||
|
||||
async def test_number(
|
||||
|
||||
@@ -14,7 +14,7 @@ from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import replace_value_of_zwave_value
|
||||
|
||||
DEFAULT_TONE_SELECT_ENTITY = "select.indoor_siren_6_sound_switch_2_default_tone"
|
||||
DEFAULT_TONE_SELECT_ENTITY = "select.endpoint_2_default_tone"
|
||||
PROTECTION_SELECT_ENTITY = "select.family_room_combo_local_protection_state"
|
||||
MULTILEVEL_SWITCH_SELECT_ENTITY = "select.outside_front_door_siren"
|
||||
|
||||
|
||||
@@ -750,14 +750,12 @@ async def test_special_meters(
|
||||
client.driver.controller.emit("node added", event)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.smart_switch_6_endpoint_10_electric_consumed_kvah")
|
||||
state = hass.states.get("sensor.endpoint_10_electric_consumed_kvah")
|
||||
assert state
|
||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||
assert state.attributes[ATTR_STATE_CLASS] is SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
state = hass.states.get(
|
||||
"sensor.smart_switch_6_endpoint_11_electric_consumed_kva_reactive"
|
||||
)
|
||||
state = hass.states.get("sensor.endpoint_11_electric_consumed_kva_reactive")
|
||||
assert state
|
||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||
assert state.attributes[ATTR_STATE_CLASS] is SensorStateClass.MEASUREMENT
|
||||
|
||||
@@ -269,7 +269,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ATTR_ENTITY_ID: [
|
||||
AIR_TEMPERATURE_SENSOR,
|
||||
"siren.indoor_siren_6_sound_switch_1_tone_id",
|
||||
"siren.endpoint_1_tone_id",
|
||||
],
|
||||
ATTR_ENDPOINT: 1,
|
||||
ATTR_CONFIG_PARAMETER: 32,
|
||||
@@ -509,7 +509,7 @@ async def test_set_config_parameter(
|
||||
DOMAIN,
|
||||
SERVICE_SET_CONFIG_PARAMETER,
|
||||
{
|
||||
ATTR_ENTITY_ID: ["siren.indoor_siren_6_sound_switch_1_tone_id"],
|
||||
ATTR_ENTITY_ID: ["siren.endpoint_1_tone_id"],
|
||||
ATTR_ENDPOINT: 0,
|
||||
ATTR_CONFIG_PARAMETER: 32,
|
||||
ATTR_VALUE_SIZE: 2,
|
||||
@@ -540,7 +540,7 @@ async def test_set_config_parameter(
|
||||
DOMAIN,
|
||||
SERVICE_SET_CONFIG_PARAMETER,
|
||||
{
|
||||
ATTR_ENTITY_ID: ["siren.indoor_siren_6_sound_switch_1_tone_id"],
|
||||
ATTR_ENTITY_ID: ["siren.endpoint_1_tone_id"],
|
||||
ATTR_ENDPOINT: 0,
|
||||
ATTR_CONFIG_PARAMETER: 32,
|
||||
ATTR_VALUE_SIZE: 2,
|
||||
|
||||
@@ -11,7 +11,7 @@ from homeassistant.components.siren import (
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
SIREN_ENTITY = "siren.indoor_siren_6_sound_switch_2_play_tone"
|
||||
SIREN_ENTITY = "siren.endpoint_2_play_tone"
|
||||
|
||||
TONE_ID_VALUE_ID = {
|
||||
"endpoint": 2,
|
||||
|
||||
Reference in New Issue
Block a user