diff --git a/homeassistant/components/smarty/binary_sensor.py b/homeassistant/components/smarty/binary_sensor.py index 0c2999ff2f3..c9fe516a526 100644 --- a/homeassistant/components/smarty/binary_sensor.py +++ b/homeassistant/components/smarty/binary_sensor.py @@ -27,11 +27,11 @@ async def async_setup_entry( """Set up the Smarty Binary Sensor Platform.""" smarty = entry.runtime_data - + entry_id = entry.entry_id sensors = [ - AlarmSensor(entry.title, smarty), - WarningSensor(entry.title, smarty), - BoostSensor(entry.title, smarty), + AlarmSensor(entry.title, smarty, entry_id), + WarningSensor(entry.title, smarty, entry_id), + BoostSensor(entry.title, smarty, entry_id), ] async_add_entities(sensors, True) @@ -66,9 +66,10 @@ class SmartyBinarySensor(BinarySensorEntity): class BoostSensor(SmartyBinarySensor): """Boost State Binary Sensor.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Alarm Sensor Init.""" super().__init__(name=f"{name} Boost State", device_class=None, smarty=smarty) + self._attr_unique_id = f"{entry_id}_boost" def update(self) -> None: """Update state.""" @@ -79,13 +80,14 @@ class BoostSensor(SmartyBinarySensor): class AlarmSensor(SmartyBinarySensor): """Alarm Binary Sensor.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Alarm Sensor Init.""" super().__init__( name=f"{name} Alarm", device_class=BinarySensorDeviceClass.PROBLEM, smarty=smarty, ) + self._attr_unique_id = f"{entry_id}_alarm" def update(self) -> None: """Update state.""" @@ -96,13 +98,14 @@ class AlarmSensor(SmartyBinarySensor): class WarningSensor(SmartyBinarySensor): """Warning Sensor.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Warning Sensor Init.""" super().__init__( name=f"{name} Warning", device_class=BinarySensorDeviceClass.PROBLEM, smarty=smarty, ) + self._attr_unique_id = f"{entry_id}_warning" def update(self) -> None: """Update state.""" diff --git a/homeassistant/components/smarty/fan.py b/homeassistant/components/smarty/fan.py index f80dd90773b..ca6474c05f5 100644 --- a/homeassistant/components/smarty/fan.py +++ b/homeassistant/components/smarty/fan.py @@ -34,7 +34,7 @@ async def async_setup_entry( smarty = entry.runtime_data - async_add_entities([SmartyFan(entry.title, smarty)], True) + async_add_entities([SmartyFan(entry.title, smarty, entry.entry_id)], True) class SmartyFan(FanEntity): @@ -49,11 +49,12 @@ class SmartyFan(FanEntity): ) _enable_turn_on_off_backwards_compatibility = False - def __init__(self, name, smarty): + def __init__(self, name, smarty, entry_id): """Initialize the entity.""" self._attr_name = name self._smarty_fan_speed = 0 self._smarty = smarty + self._attr_unique_id = entry_id @property def is_on(self) -> bool: diff --git a/homeassistant/components/smarty/sensor.py b/homeassistant/components/smarty/sensor.py index 70527039e20..c727dcd4fdd 100644 --- a/homeassistant/components/smarty/sensor.py +++ b/homeassistant/components/smarty/sensor.py @@ -27,13 +27,14 @@ async def async_setup_entry( """Set up the Smarty Sensor Platform.""" smarty = entry.runtime_data + entry_id = entry.entry_id sensors = [ - SupplyAirTemperatureSensor(entry.title, smarty), - ExtractAirTemperatureSensor(entry.title, smarty), - OutdoorAirTemperatureSensor(entry.title, smarty), - SupplyFanSpeedSensor(entry.title, smarty), - ExtractFanSpeedSensor(entry.title, smarty), - FilterDaysLeftSensor(entry.title, smarty), + SupplyAirTemperatureSensor(entry.title, smarty, entry_id), + ExtractAirTemperatureSensor(entry.title, smarty, entry_id), + OutdoorAirTemperatureSensor(entry.title, smarty, entry_id), + SupplyFanSpeedSensor(entry.title, smarty, entry_id), + ExtractFanSpeedSensor(entry.title, smarty, entry_id), + FilterDaysLeftSensor(entry.title, smarty, entry_id), ] async_add_entities(sensors, True) @@ -71,7 +72,7 @@ class SmartySensor(SensorEntity): class SupplyAirTemperatureSensor(SmartySensor): """Supply Air Temperature Sensor.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Supply Air Temperature Init.""" super().__init__( name=f"{name} Supply Air Temperature", @@ -79,6 +80,7 @@ class SupplyAirTemperatureSensor(SmartySensor): unit_of_measurement=UnitOfTemperature.CELSIUS, smarty=smarty, ) + self._attr_unique_id = f"{entry_id}_supply_air_temperature" def update(self) -> None: """Update state.""" @@ -89,7 +91,7 @@ class SupplyAirTemperatureSensor(SmartySensor): class ExtractAirTemperatureSensor(SmartySensor): """Extract Air Temperature Sensor.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Supply Air Temperature Init.""" super().__init__( name=f"{name} Extract Air Temperature", @@ -97,6 +99,7 @@ class ExtractAirTemperatureSensor(SmartySensor): unit_of_measurement=UnitOfTemperature.CELSIUS, smarty=smarty, ) + self._attr_unique_id = f"{entry_id}_extract_air_temperature" def update(self) -> None: """Update state.""" @@ -107,7 +110,7 @@ class ExtractAirTemperatureSensor(SmartySensor): class OutdoorAirTemperatureSensor(SmartySensor): """Extract Air Temperature Sensor.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Outdoor Air Temperature Init.""" super().__init__( name=f"{name} Outdoor Air Temperature", @@ -115,6 +118,7 @@ class OutdoorAirTemperatureSensor(SmartySensor): unit_of_measurement=UnitOfTemperature.CELSIUS, smarty=smarty, ) + self._attr_unique_id = f"{entry_id}_outdoor_air_temperature" def update(self) -> None: """Update state.""" @@ -125,7 +129,7 @@ class OutdoorAirTemperatureSensor(SmartySensor): class SupplyFanSpeedSensor(SmartySensor): """Supply Fan Speed RPM.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Supply Fan Speed RPM Init.""" super().__init__( name=f"{name} Supply Fan Speed", @@ -133,6 +137,7 @@ class SupplyFanSpeedSensor(SmartySensor): unit_of_measurement=None, smarty=smarty, ) + self._attr_unique_id = f"{entry_id}_supply_fan_speed" def update(self) -> None: """Update state.""" @@ -143,7 +148,7 @@ class SupplyFanSpeedSensor(SmartySensor): class ExtractFanSpeedSensor(SmartySensor): """Extract Fan Speed RPM.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Extract Fan Speed RPM Init.""" super().__init__( name=f"{name} Extract Fan Speed", @@ -151,6 +156,7 @@ class ExtractFanSpeedSensor(SmartySensor): unit_of_measurement=None, smarty=smarty, ) + self._attr_unique_id = f"{entry_id}_extract_fan_speed" def update(self) -> None: """Update state.""" @@ -161,7 +167,7 @@ class ExtractFanSpeedSensor(SmartySensor): class FilterDaysLeftSensor(SmartySensor): """Filter Days Left.""" - def __init__(self, name: str, smarty: Smarty) -> None: + def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None: """Filter Days Left Init.""" super().__init__( name=f"{name} Filter Days Left", @@ -170,6 +176,7 @@ class FilterDaysLeftSensor(SmartySensor): smarty=smarty, ) self._days_left = 91 + self._attr_unique_id = f"{entry_id}_filter_days_left" def update(self) -> None: """Update state.""" diff --git a/tests/components/smarty/conftest.py b/tests/components/smarty/conftest.py index f05c7256115..eff76a7994d 100644 --- a/tests/components/smarty/conftest.py +++ b/tests/components/smarty/conftest.py @@ -37,10 +37,24 @@ def mock_smarty() -> Generator[AsyncMock]: ): client = mock_client.return_value client.update.return_value = True + client.fan_speed = 100 + client.warning = False + client.alarm = False + client.boost = False + client.supply_air_temperature = 20 + client.extract_air_temperature = 23 + client.outdoor_air_temperature = 24 + client.supply_fan_speed = 66 + client.extract_fan_speed = 100 + client.filter_timer = 31 yield client @pytest.fixture def mock_config_entry() -> MockConfigEntry: """Return the default mocked config entry.""" - return MockConfigEntry(domain=DOMAIN, data={CONF_HOST: "192.168.0.2"}) + return MockConfigEntry( + domain=DOMAIN, + data={CONF_HOST: "192.168.0.2"}, + entry_id="01JAZ5DPW8C62D620DGYNG2R8H", + ) diff --git a/tests/components/smarty/snapshots/test_binary_sensor.ambr b/tests/components/smarty/snapshots/test_binary_sensor.ambr new file mode 100644 index 00000000000..3d261e607a4 --- /dev/null +++ b/tests/components/smarty/snapshots/test_binary_sensor.ambr @@ -0,0 +1,141 @@ +# serializer version: 1 +# name: test_all_entities[binary_sensor.mock_title_alarm-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.mock_title_alarm', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Mock Title Alarm', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_alarm', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[binary_sensor.mock_title_alarm-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Mock Title Alarm', + }), + 'context': , + 'entity_id': 'binary_sensor.mock_title_alarm', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_all_entities[binary_sensor.mock_title_boost_state-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.mock_title_boost_state', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Mock Title Boost State', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_boost', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[binary_sensor.mock_title_boost_state-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Mock Title Boost State', + }), + 'context': , + 'entity_id': 'binary_sensor.mock_title_boost_state', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_all_entities[binary_sensor.mock_title_warning-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.mock_title_warning', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Mock Title Warning', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_warning', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[binary_sensor.mock_title_warning-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Mock Title Warning', + }), + 'context': , + 'entity_id': 'binary_sensor.mock_title_warning', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/smarty/snapshots/test_fan.ambr b/tests/components/smarty/snapshots/test_fan.ambr new file mode 100644 index 00000000000..fe8743b1970 --- /dev/null +++ b/tests/components/smarty/snapshots/test_fan.ambr @@ -0,0 +1,55 @@ +# serializer version: 1 +# name: test_all_entities[fan.mock_title-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'preset_modes': None, + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'fan', + 'entity_category': None, + 'entity_id': 'fan.mock_title', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': 'mdi:air-conditioner', + 'original_name': 'Mock Title', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[fan.mock_title-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Mock Title', + 'icon': 'mdi:air-conditioner', + 'percentage': 0, + 'percentage_step': 33.333333333333336, + 'preset_mode': None, + 'preset_modes': None, + 'supported_features': , + }), + 'context': , + 'entity_id': 'fan.mock_title', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/smarty/snapshots/test_sensor.ambr b/tests/components/smarty/snapshots/test_sensor.ambr new file mode 100644 index 00000000000..1fb8d79571c --- /dev/null +++ b/tests/components/smarty/snapshots/test_sensor.ambr @@ -0,0 +1,284 @@ +# serializer version: 1 +# name: test_all_entities[sensor.mock_title_extract_air_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_extract_air_temperature', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Mock Title Extract Air Temperature', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_extract_air_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities[sensor.mock_title_extract_air_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Mock Title Extract Air Temperature', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.mock_title_extract_air_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '23', + }) +# --- +# name: test_all_entities[sensor.mock_title_extract_fan_speed-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_extract_fan_speed', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Mock Title Extract Fan Speed', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_extract_fan_speed', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[sensor.mock_title_extract_fan_speed-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Mock Title Extract Fan Speed', + }), + 'context': , + 'entity_id': 'sensor.mock_title_extract_fan_speed', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '100', + }) +# --- +# name: test_all_entities[sensor.mock_title_filter_days_left-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_filter_days_left', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Mock Title Filter Days Left', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_filter_days_left', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[sensor.mock_title_filter_days_left-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'timestamp', + 'friendly_name': 'Mock Title Filter Days Left', + }), + 'context': , + 'entity_id': 'sensor.mock_title_filter_days_left', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2023-11-21T01:00:00+00:00', + }) +# --- +# name: test_all_entities[sensor.mock_title_outdoor_air_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_outdoor_air_temperature', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Mock Title Outdoor Air Temperature', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_outdoor_air_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities[sensor.mock_title_outdoor_air_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Mock Title Outdoor Air Temperature', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.mock_title_outdoor_air_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '24', + }) +# --- +# name: test_all_entities[sensor.mock_title_supply_air_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_supply_air_temperature', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Mock Title Supply Air Temperature', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_supply_air_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities[sensor.mock_title_supply_air_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Mock Title Supply Air Temperature', + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.mock_title_supply_air_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '20', + }) +# --- +# name: test_all_entities[sensor.mock_title_supply_fan_speed-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_supply_fan_speed', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Mock Title Supply Fan Speed', + 'platform': 'smarty', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_supply_fan_speed', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[sensor.mock_title_supply_fan_speed-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Mock Title Supply Fan Speed', + }), + 'context': , + 'entity_id': 'sensor.mock_title_supply_fan_speed', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '66', + }) +# --- diff --git a/tests/components/smarty/test_binary_sensor.py b/tests/components/smarty/test_binary_sensor.py new file mode 100644 index 00000000000..d28fb44e1ce --- /dev/null +++ b/tests/components/smarty/test_binary_sensor.py @@ -0,0 +1,27 @@ +"""Tests for the Smarty binary sensor platform.""" + +from unittest.mock import AsyncMock, patch + +from syrupy import SnapshotAssertion + +from homeassistant.const import Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import setup_integration + +from tests.common import MockConfigEntry, snapshot_platform + + +async def test_all_entities( + hass: HomeAssistant, + snapshot: SnapshotAssertion, + mock_smarty: AsyncMock, + mock_config_entry: MockConfigEntry, + entity_registry: er.EntityRegistry, +) -> None: + """Test all entities.""" + with patch("homeassistant.components.smarty.PLATFORMS", [Platform.BINARY_SENSOR]): + await setup_integration(hass, mock_config_entry) + + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) diff --git a/tests/components/smarty/test_fan.py b/tests/components/smarty/test_fan.py new file mode 100644 index 00000000000..2c0135b7aa2 --- /dev/null +++ b/tests/components/smarty/test_fan.py @@ -0,0 +1,27 @@ +"""Tests for the Smarty fan platform.""" + +from unittest.mock import AsyncMock, patch + +from syrupy import SnapshotAssertion + +from homeassistant.const import Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import setup_integration + +from tests.common import MockConfigEntry, snapshot_platform + + +async def test_all_entities( + hass: HomeAssistant, + snapshot: SnapshotAssertion, + mock_smarty: AsyncMock, + mock_config_entry: MockConfigEntry, + entity_registry: er.EntityRegistry, +) -> None: + """Test all entities.""" + with patch("homeassistant.components.smarty.PLATFORMS", [Platform.FAN]): + await setup_integration(hass, mock_config_entry) + + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) diff --git a/tests/components/smarty/test_sensor.py b/tests/components/smarty/test_sensor.py new file mode 100644 index 00000000000..a534a2ebb0f --- /dev/null +++ b/tests/components/smarty/test_sensor.py @@ -0,0 +1,29 @@ +"""Tests for the Smarty sensor platform.""" + +from unittest.mock import AsyncMock, patch + +import pytest +from syrupy import SnapshotAssertion + +from homeassistant.const import Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import setup_integration + +from tests.common import MockConfigEntry, snapshot_platform + + +@pytest.mark.freeze_time("2023-10-21") +async def test_all_entities( + hass: HomeAssistant, + snapshot: SnapshotAssertion, + mock_smarty: AsyncMock, + mock_config_entry: MockConfigEntry, + entity_registry: er.EntityRegistry, +) -> None: + """Test all entities.""" + with patch("homeassistant.components.smarty.PLATFORMS", [Platform.SENSOR]): + await setup_integration(hass, mock_config_entry) + + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)