Use DeviceClass Enums in homekit (#62218)
This commit is contained in:
parent
6cf9f1a0cc
commit
168fefad88
6 changed files with 54 additions and 53 deletions
|
@ -11,10 +11,7 @@ import pytest
|
|||
|
||||
from homeassistant import config as hass_config
|
||||
from homeassistant.components import homekit as homekit_base, zeroconf
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_BATTERY_CHARGING,
|
||||
DEVICE_CLASS_MOTION,
|
||||
)
|
||||
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||
from homeassistant.components.homekit import (
|
||||
MAX_DEVICES,
|
||||
STATUS_READY,
|
||||
|
@ -37,6 +34,7 @@ from homeassistant.components.homekit.const import (
|
|||
)
|
||||
from homeassistant.components.homekit.type_triggers import DeviceTriggerAccessory
|
||||
from homeassistant.components.homekit.util import get_persist_fullpath_for_entry_id
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
|
@ -45,8 +43,6 @@ from homeassistant.const import (
|
|||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONF_NAME,
|
||||
CONF_PORT,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
EVENT_HOMEASSISTANT_STARTED,
|
||||
PERCENTAGE,
|
||||
SERVICE_RELOAD,
|
||||
|
@ -1118,14 +1114,14 @@ async def test_homekit_finds_linked_batteries(
|
|||
"powerwall",
|
||||
"battery_charging",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_BATTERY_CHARGING,
|
||||
original_device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||
)
|
||||
battery_sensor = entity_reg.async_get_or_create(
|
||||
"sensor",
|
||||
"powerwall",
|
||||
"battery",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_BATTERY,
|
||||
original_device_class=SensorDeviceClass.BATTERY,
|
||||
)
|
||||
light = entity_reg.async_get_or_create(
|
||||
"light", "powerwall", "demo", device_id=device_entry.id
|
||||
|
@ -1134,10 +1130,10 @@ async def test_homekit_finds_linked_batteries(
|
|||
hass.states.async_set(
|
||||
binary_charging_sensor.entity_id,
|
||||
STATE_ON,
|
||||
{ATTR_DEVICE_CLASS: DEVICE_CLASS_BATTERY_CHARGING},
|
||||
{ATTR_DEVICE_CLASS: BinarySensorDeviceClass.BATTERY_CHARGING},
|
||||
)
|
||||
hass.states.async_set(
|
||||
battery_sensor.entity_id, 30, {ATTR_DEVICE_CLASS: DEVICE_CLASS_BATTERY}
|
||||
battery_sensor.entity_id, 30, {ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY}
|
||||
)
|
||||
hass.states.async_set(light.entity_id, STATE_ON)
|
||||
|
||||
|
@ -1187,14 +1183,14 @@ async def test_homekit_async_get_integration_fails(
|
|||
"invalid_integration_does_not_exist",
|
||||
"battery_charging",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_BATTERY_CHARGING,
|
||||
original_device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||
)
|
||||
battery_sensor = entity_reg.async_get_or_create(
|
||||
"sensor",
|
||||
"invalid_integration_does_not_exist",
|
||||
"battery",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_BATTERY,
|
||||
original_device_class=SensorDeviceClass.BATTERY,
|
||||
)
|
||||
light = entity_reg.async_get_or_create(
|
||||
"light", "invalid_integration_does_not_exist", "demo", device_id=device_entry.id
|
||||
|
@ -1203,10 +1199,10 @@ async def test_homekit_async_get_integration_fails(
|
|||
hass.states.async_set(
|
||||
binary_charging_sensor.entity_id,
|
||||
STATE_ON,
|
||||
{ATTR_DEVICE_CLASS: DEVICE_CLASS_BATTERY_CHARGING},
|
||||
{ATTR_DEVICE_CLASS: BinarySensorDeviceClass.BATTERY_CHARGING},
|
||||
)
|
||||
hass.states.async_set(
|
||||
battery_sensor.entity_id, 30, {ATTR_DEVICE_CLASS: DEVICE_CLASS_BATTERY}
|
||||
battery_sensor.entity_id, 30, {ATTR_DEVICE_CLASS: SensorDeviceClass.BATTERY}
|
||||
)
|
||||
hass.states.async_set(light.entity_id, STATE_ON)
|
||||
|
||||
|
@ -1334,14 +1330,14 @@ async def test_homekit_ignored_missing_devices(
|
|||
"powerwall",
|
||||
"battery_charging",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_BATTERY_CHARGING,
|
||||
original_device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||
)
|
||||
entity_reg.async_get_or_create(
|
||||
"sensor",
|
||||
"powerwall",
|
||||
"battery",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_BATTERY,
|
||||
original_device_class=SensorDeviceClass.BATTERY,
|
||||
)
|
||||
light = entity_reg.async_get_or_create(
|
||||
"light", "powerwall", "demo", device_id=device_entry.id
|
||||
|
@ -1404,7 +1400,7 @@ async def test_homekit_finds_linked_motion_sensors(
|
|||
"camera",
|
||||
"motion_sensor",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_MOTION,
|
||||
original_device_class=BinarySensorDeviceClass.MOTION,
|
||||
)
|
||||
camera = entity_reg.async_get_or_create(
|
||||
"camera", "camera", "demo", device_id=device_entry.id
|
||||
|
@ -1413,7 +1409,7 @@ async def test_homekit_finds_linked_motion_sensors(
|
|||
hass.states.async_set(
|
||||
binary_motion_sensor.entity_id,
|
||||
STATE_ON,
|
||||
{ATTR_DEVICE_CLASS: DEVICE_CLASS_MOTION},
|
||||
{ATTR_DEVICE_CLASS: BinarySensorDeviceClass.MOTION},
|
||||
)
|
||||
hass.states.async_set(camera.entity_id, STATE_ON)
|
||||
|
||||
|
@ -1466,7 +1462,7 @@ async def test_homekit_finds_linked_humidity_sensors(
|
|||
"humidifier",
|
||||
"humidity_sensor",
|
||||
device_id=device_entry.id,
|
||||
original_device_class=DEVICE_CLASS_HUMIDITY,
|
||||
original_device_class=SensorDeviceClass.HUMIDITY,
|
||||
)
|
||||
humidifier = entity_reg.async_get_or_create(
|
||||
"humidifier", "humidifier", "demo", device_id=device_entry.id
|
||||
|
@ -1476,7 +1472,7 @@ async def test_homekit_finds_linked_humidity_sensors(
|
|||
humidity_sensor.entity_id,
|
||||
"42",
|
||||
{
|
||||
ATTR_DEVICE_CLASS: DEVICE_CLASS_HUMIDITY,
|
||||
ATTR_DEVICE_CLASS: SensorDeviceClass.HUMIDITY,
|
||||
ATTR_UNIT_OF_MEASUREMENT: PERCENTAGE,
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue