diff --git a/tests/components/homekit/test_accessories.py b/tests/components/homekit/test_accessories.py index 799a831b745..f12b80632b6 100644 --- a/tests/components/homekit/test_accessories.py +++ b/tests/components/homekit/test_accessories.py @@ -56,7 +56,11 @@ async def test_debounce(hass): async def test_home_accessory(hass): """Test HomeAccessory class.""" - acc = HomeAccessory(hass, 'Home Accessory', 'homekit.accessory', 2, None) + entity_id = 'homekit.accessory' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() + + acc = HomeAccessory(hass, 'Home Accessory', entity_id, 2, None) assert acc.hass == hass assert acc.display_name == 'Home Accessory' assert acc.aid == 2 @@ -76,7 +80,11 @@ async def test_home_accessory(hass): hass.states.async_set('homekit.accessory', 'off') await hass.async_block_till_done() - acc = HomeAccessory('hass', 'test_name', 'test_model.demo', 2, None) + entity_id = 'test_model.demo' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() + + acc = HomeAccessory('hass', 'test_name', entity_id, 2, None) assert acc.display_name == 'test_name' assert acc.aid == 2 assert len(acc.services) == 1 diff --git a/tests/components/homekit/test_get_accessories.py b/tests/components/homekit/test_get_accessories.py index a6827300862..cdfb858b727 100644 --- a/tests/components/homekit/test_get_accessories.py +++ b/tests/components/homekit/test_get_accessories.py @@ -1,5 +1,4 @@ """Package to test the get_accessory method.""" -import logging from unittest.mock import patch, Mock import pytest @@ -13,8 +12,6 @@ from homeassistant.const import ( ATTR_CODE, ATTR_DEVICE_CLASS, ATTR_SUPPORTED_FEATURES, ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, TEMP_FAHRENHEIT, CONF_NAME) -_LOGGER = logging.getLogger(__name__) - def test_not_supported(caplog): """Test if none is returned if entity isn't supported.""" diff --git a/tests/components/homekit/test_type_covers.py b/tests/components/homekit/test_type_covers.py index fcc807338a9..dc4caeb35a6 100644 --- a/tests/components/homekit/test_type_covers.py +++ b/tests/components/homekit/test_type_covers.py @@ -32,6 +32,8 @@ async def test_garage_door_open_close(hass, cls): """Test if accessory and HA are updated accordingly.""" entity_id = 'cover.garage_door' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = cls.garage(hass, 'Garage Door', entity_id, 2, None) await hass.async_add_job(acc.run) @@ -87,6 +89,8 @@ async def test_window_set_cover_position(hass, cls): """Test if accessory and HA are updated accordingly.""" entity_id = 'cover.window' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = cls.window(hass, 'Cover', entity_id, 2, None) await hass.async_add_job(acc.run) diff --git a/tests/components/homekit/test_type_locks.py b/tests/components/homekit/test_type_locks.py index 343fce288ac..984d032a1d9 100644 --- a/tests/components/homekit/test_type_locks.py +++ b/tests/components/homekit/test_type_locks.py @@ -11,6 +11,8 @@ async def test_lock_unlock(hass): """Test if accessory and HA are updated accordingly.""" entity_id = 'lock.kitchen_door' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = Lock(hass, 'Lock', entity_id, 2, None) await hass.async_add_job(acc.run) diff --git a/tests/components/homekit/test_type_security_systems.py b/tests/components/homekit/test_type_security_systems.py index 59a700f73ee..da5dac2d81b 100644 --- a/tests/components/homekit/test_type_security_systems.py +++ b/tests/components/homekit/test_type_security_systems.py @@ -18,6 +18,8 @@ async def test_switch_set_state(hass): config = {ATTR_CODE: code} entity_id = 'alarm_control_panel.test' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = SecuritySystem(hass, 'SecuritySystem', entity_id, 2, config) await hass.async_add_job(acc.run) @@ -97,6 +99,8 @@ async def test_no_alarm_code(hass, config): """Test accessory if security_system doesn't require a alarm_code.""" entity_id = 'alarm_control_panel.test' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = SecuritySystem(hass, 'SecuritySystem', entity_id, 2, config) # Set from HomeKit diff --git a/tests/components/homekit/test_type_sensors.py b/tests/components/homekit/test_type_sensors.py index a422116014d..56742bada92 100644 --- a/tests/components/homekit/test_type_sensors.py +++ b/tests/components/homekit/test_type_sensors.py @@ -12,6 +12,8 @@ async def test_temperature(hass): """Test if accessory is updated after state change.""" entity_id = 'sensor.temperature' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = TemperatureSensor(hass, 'Temperature', entity_id, 2, None) await hass.async_add_job(acc.run) @@ -42,6 +44,8 @@ async def test_humidity(hass): """Test if accessory is updated after state change.""" entity_id = 'sensor.humidity' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = HumiditySensor(hass, 'Humidity', entity_id, 2, None) await hass.async_add_job(acc.run) @@ -63,6 +67,8 @@ async def test_air_quality(hass): """Test if accessory is updated after state change.""" entity_id = 'sensor.air_quality' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = AirQualitySensor(hass, 'Air Quality', entity_id, 2, None) await hass.async_add_job(acc.run) @@ -92,6 +98,8 @@ async def test_co2(hass): """Test if accessory is updated after state change.""" entity_id = 'sensor.co2' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = CarbonDioxideSensor(hass, 'CO2', entity_id, 2, None) await hass.async_add_job(acc.run) @@ -125,6 +133,8 @@ async def test_light(hass): """Test if accessory is updated after state change.""" entity_id = 'sensor.light' + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = LightSensor(hass, 'Light', entity_id, 2, None) await hass.async_add_job(acc.run) diff --git a/tests/components/homekit/test_type_switches.py b/tests/components/homekit/test_type_switches.py index 00c1966305f..399a8bd84c8 100644 --- a/tests/components/homekit/test_type_switches.py +++ b/tests/components/homekit/test_type_switches.py @@ -14,6 +14,8 @@ async def test_switch_set_state(hass, entity_id): """Test if accessory and HA are updated accordingly.""" domain = split_entity_id(entity_id)[0] + hass.states.async_set(entity_id, None) + await hass.async_block_till_done() acc = Switch(hass, 'Switch', entity_id, 2, None) await hass.async_add_job(acc.run)