mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use EntityCategory enum in Onewire (#60907)
* Use EntityCategory enum in Onewire * Add checks for the entity_category * Fix typo Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
0a2ca1f7d5
commit
adf2fa5664
@ -9,8 +9,9 @@ from typing import TYPE_CHECKING, Any
|
||||
from homeassistant.components.onewire.model import OWServerDeviceDescription
|
||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_TYPE, ENTITY_CATEGORY_CONFIG
|
||||
from homeassistant.const import CONF_TYPE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import (
|
||||
@ -62,7 +63,7 @@ DEVICE_SWITCHES: dict[str, tuple[OneWireEntityDescription, ...]] = {
|
||||
OneWireSwitchEntityDescription(
|
||||
key="IAD",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
name="IAD",
|
||||
read_mode=READ_MODE_BOOL,
|
||||
),
|
||||
|
@ -24,6 +24,7 @@ from homeassistant.helpers.entity_registry import EntityRegistry
|
||||
from .const import (
|
||||
ATTR_DEFAULT_DISABLED,
|
||||
ATTR_DEVICE_FILE,
|
||||
ATTR_ENTITY_CATEGORY,
|
||||
ATTR_INJECT_READS,
|
||||
ATTR_UNIQUE_ID,
|
||||
FIXED_ATTRIBUTES,
|
||||
@ -77,6 +78,9 @@ def check_entities(
|
||||
entity_id = expected_entity[ATTR_ENTITY_ID]
|
||||
registry_entry = entity_registry.entities.get(entity_id)
|
||||
assert registry_entry is not None
|
||||
assert registry_entry.entity_category == expected_entity.get(
|
||||
ATTR_ENTITY_CATEGORY
|
||||
)
|
||||
assert registry_entry.unique_id == expected_entity[ATTR_UNIQUE_ID]
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.state == expected_entity[ATTR_STATE]
|
||||
|
@ -36,10 +36,12 @@ from homeassistant.const import (
|
||||
STATE_UNKNOWN,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
||||
ATTR_DEFAULT_DISABLED = "default_disabled"
|
||||
ATTR_DEVICE_FILE = "device_file"
|
||||
ATTR_DEVICE_INFO = "device_info"
|
||||
ATTR_ENTITY_CATEGORY = "entity_category"
|
||||
ATTR_INJECT_READS = "inject_reads"
|
||||
ATTR_UNIQUE_ID = "unique_id"
|
||||
ATTR_UNKNOWN_DEVICE = "unknown_device"
|
||||
@ -404,6 +406,7 @@ MOCK_OWPROXY_DEVICES = {
|
||||
SWITCH_DOMAIN: [
|
||||
{
|
||||
ATTR_DEFAULT_DISABLED: True,
|
||||
ATTR_ENTITY_CATEGORY: EntityCategory.CONFIG,
|
||||
ATTR_ENTITY_ID: "switch.26_111111111111_iad",
|
||||
ATTR_INJECT_READS: b" 1",
|
||||
ATTR_STATE: STATE_ON,
|
||||
|
Loading…
x
Reference in New Issue
Block a user