Add zwave_js select entity category (#59157)
* Set zwave_js select entity as category config * Update testspull/59175/head
parent
6a0c1a78aa
commit
30cba6ee8b
|
@ -9,6 +9,7 @@ from zwave_js_server.const.command_class.sound_switch import ToneID
|
|||
|
||||
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN, SelectEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENTITY_CATEGORY_CONFIG
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -52,6 +53,8 @@ async def async_setup_entry(
|
|||
class ZwaveSelectEntity(ZWaveBaseEntity, SelectEntity):
|
||||
"""Representation of a Z-Wave select entity."""
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_CONFIG
|
||||
|
||||
def __init__(
|
||||
self, config_entry: ConfigEntry, client: ZwaveClient, info: ZwaveDiscoveryInfo
|
||||
) -> None:
|
||||
|
@ -86,6 +89,8 @@ class ZwaveSelectEntity(ZWaveBaseEntity, SelectEntity):
|
|||
class ZwaveDefaultToneSelectEntity(ZWaveBaseEntity, SelectEntity):
|
||||
"""Representation of a Z-Wave default tone select entity."""
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_CONFIG
|
||||
|
||||
def __init__(
|
||||
self, config_entry: ConfigEntry, client: ZwaveClient, info: ZwaveDiscoveryInfo
|
||||
) -> None:
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
"""Test the Z-Wave JS number platform."""
|
||||
from zwave_js_server.event import Event
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from zwave_js_server.event import Event
|
||||
from zwave_js_server.model.node import Node
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENTITY_CATEGORY_CONFIG, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.entity_registry as er
|
||||
|
||||
DEFAULT_TONE_SELECT_ENTITY = "select.indoor_siren_6_default_tone_2"
|
||||
PROTECTION_SELECT_ENTITY = "select.family_room_combo_local_protection_state"
|
||||
MULTILEVEL_SWITCH_SELECT_ENTITY = "select.front_door_siren"
|
||||
|
||||
|
||||
async def test_default_tone_select(hass, client, aeotec_zw164_siren, integration):
|
||||
async def test_default_tone_select(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
aeotec_zw164_siren: Node,
|
||||
integration: ConfigEntry,
|
||||
) -> None:
|
||||
"""Test the default tone select entity."""
|
||||
node = aeotec_zw164_siren
|
||||
state = hass.states.get(DEFAULT_TONE_SELECT_ENTITY)
|
||||
|
@ -48,6 +59,12 @@ async def test_default_tone_select(hass, client, aeotec_zw164_siren, integration
|
|||
"30DOOR~1 (27 sec)",
|
||||
]
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
entity_entry = entity_registry.async_get(DEFAULT_TONE_SELECT_ENTITY)
|
||||
|
||||
assert entity_entry
|
||||
assert entity_entry.entity_category == ENTITY_CATEGORY_CONFIG
|
||||
|
||||
# Test select option with string value
|
||||
await hass.services.async_call(
|
||||
"select",
|
||||
|
@ -102,10 +119,16 @@ async def test_default_tone_select(hass, client, aeotec_zw164_siren, integration
|
|||
node.receive_event(event)
|
||||
|
||||
state = hass.states.get(DEFAULT_TONE_SELECT_ENTITY)
|
||||
assert state
|
||||
assert state.state == "30DOOR~1 (27 sec)"
|
||||
|
||||
|
||||
async def test_protection_select(hass, client, inovelli_lzw36, integration):
|
||||
async def test_protection_select(
|
||||
hass: HomeAssistant,
|
||||
client: MagicMock,
|
||||
inovelli_lzw36: Node,
|
||||
integration: ConfigEntry,
|
||||
) -> None:
|
||||
"""Test the default tone select entity."""
|
||||
node = inovelli_lzw36
|
||||
state = hass.states.get(PROTECTION_SELECT_ENTITY)
|
||||
|
@ -119,6 +142,12 @@ async def test_protection_select(hass, client, inovelli_lzw36, integration):
|
|||
"NoOperationPossible",
|
||||
]
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
entity_entry = entity_registry.async_get(PROTECTION_SELECT_ENTITY)
|
||||
|
||||
assert entity_entry
|
||||
assert entity_entry.entity_category == ENTITY_CATEGORY_CONFIG
|
||||
|
||||
# Test select option with string value
|
||||
await hass.services.async_call(
|
||||
"select",
|
||||
|
@ -176,6 +205,7 @@ async def test_protection_select(hass, client, inovelli_lzw36, integration):
|
|||
node.receive_event(event)
|
||||
|
||||
state = hass.states.get(PROTECTION_SELECT_ENTITY)
|
||||
assert state
|
||||
assert state.state == "ProtectedBySequence"
|
||||
|
||||
# Test null value
|
||||
|
@ -199,6 +229,7 @@ async def test_protection_select(hass, client, inovelli_lzw36, integration):
|
|||
node.receive_event(event)
|
||||
|
||||
state = hass.states.get(PROTECTION_SELECT_ENTITY)
|
||||
assert state
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue