Add unique id and tests for Smarty (#129078)
parent
bf7d292884
commit
92e1fa4d3a
|
@ -27,11 +27,11 @@ async def async_setup_entry(
|
||||||
"""Set up the Smarty Binary Sensor Platform."""
|
"""Set up the Smarty Binary Sensor Platform."""
|
||||||
|
|
||||||
smarty = entry.runtime_data
|
smarty = entry.runtime_data
|
||||||
|
entry_id = entry.entry_id
|
||||||
sensors = [
|
sensors = [
|
||||||
AlarmSensor(entry.title, smarty),
|
AlarmSensor(entry.title, smarty, entry_id),
|
||||||
WarningSensor(entry.title, smarty),
|
WarningSensor(entry.title, smarty, entry_id),
|
||||||
BoostSensor(entry.title, smarty),
|
BoostSensor(entry.title, smarty, entry_id),
|
||||||
]
|
]
|
||||||
|
|
||||||
async_add_entities(sensors, True)
|
async_add_entities(sensors, True)
|
||||||
|
@ -66,9 +66,10 @@ class SmartyBinarySensor(BinarySensorEntity):
|
||||||
class BoostSensor(SmartyBinarySensor):
|
class BoostSensor(SmartyBinarySensor):
|
||||||
"""Boost State Binary Sensor."""
|
"""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."""
|
"""Alarm Sensor Init."""
|
||||||
super().__init__(name=f"{name} Boost State", device_class=None, smarty=smarty)
|
super().__init__(name=f"{name} Boost State", device_class=None, smarty=smarty)
|
||||||
|
self._attr_unique_id = f"{entry_id}_boost"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -79,13 +80,14 @@ class BoostSensor(SmartyBinarySensor):
|
||||||
class AlarmSensor(SmartyBinarySensor):
|
class AlarmSensor(SmartyBinarySensor):
|
||||||
"""Alarm Binary Sensor."""
|
"""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."""
|
"""Alarm Sensor Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Alarm",
|
name=f"{name} Alarm",
|
||||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
|
self._attr_unique_id = f"{entry_id}_alarm"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -96,13 +98,14 @@ class AlarmSensor(SmartyBinarySensor):
|
||||||
class WarningSensor(SmartyBinarySensor):
|
class WarningSensor(SmartyBinarySensor):
|
||||||
"""Warning Sensor."""
|
"""Warning Sensor."""
|
||||||
|
|
||||||
def __init__(self, name: str, smarty: Smarty) -> None:
|
def __init__(self, name: str, smarty: Smarty, entry_id: str) -> None:
|
||||||
"""Warning Sensor Init."""
|
"""Warning Sensor Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Warning",
|
name=f"{name} Warning",
|
||||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
|
self._attr_unique_id = f"{entry_id}_warning"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
|
|
@ -34,7 +34,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
smarty = entry.runtime_data
|
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):
|
class SmartyFan(FanEntity):
|
||||||
|
@ -49,11 +49,12 @@ class SmartyFan(FanEntity):
|
||||||
)
|
)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
|
|
||||||
def __init__(self, name, smarty):
|
def __init__(self, name, smarty, entry_id):
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
self._attr_name = name
|
self._attr_name = name
|
||||||
self._smarty_fan_speed = 0
|
self._smarty_fan_speed = 0
|
||||||
self._smarty = smarty
|
self._smarty = smarty
|
||||||
|
self._attr_unique_id = entry_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
|
|
@ -27,13 +27,14 @@ async def async_setup_entry(
|
||||||
"""Set up the Smarty Sensor Platform."""
|
"""Set up the Smarty Sensor Platform."""
|
||||||
|
|
||||||
smarty = entry.runtime_data
|
smarty = entry.runtime_data
|
||||||
|
entry_id = entry.entry_id
|
||||||
sensors = [
|
sensors = [
|
||||||
SupplyAirTemperatureSensor(entry.title, smarty),
|
SupplyAirTemperatureSensor(entry.title, smarty, entry_id),
|
||||||
ExtractAirTemperatureSensor(entry.title, smarty),
|
ExtractAirTemperatureSensor(entry.title, smarty, entry_id),
|
||||||
OutdoorAirTemperatureSensor(entry.title, smarty),
|
OutdoorAirTemperatureSensor(entry.title, smarty, entry_id),
|
||||||
SupplyFanSpeedSensor(entry.title, smarty),
|
SupplyFanSpeedSensor(entry.title, smarty, entry_id),
|
||||||
ExtractFanSpeedSensor(entry.title, smarty),
|
ExtractFanSpeedSensor(entry.title, smarty, entry_id),
|
||||||
FilterDaysLeftSensor(entry.title, smarty),
|
FilterDaysLeftSensor(entry.title, smarty, entry_id),
|
||||||
]
|
]
|
||||||
|
|
||||||
async_add_entities(sensors, True)
|
async_add_entities(sensors, True)
|
||||||
|
@ -71,7 +72,7 @@ class SmartySensor(SensorEntity):
|
||||||
class SupplyAirTemperatureSensor(SmartySensor):
|
class SupplyAirTemperatureSensor(SmartySensor):
|
||||||
"""Supply Air Temperature Sensor."""
|
"""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."""
|
"""Supply Air Temperature Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Supply Air Temperature",
|
name=f"{name} Supply Air Temperature",
|
||||||
|
@ -79,6 +80,7 @@ class SupplyAirTemperatureSensor(SmartySensor):
|
||||||
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
|
self._attr_unique_id = f"{entry_id}_supply_air_temperature"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -89,7 +91,7 @@ class SupplyAirTemperatureSensor(SmartySensor):
|
||||||
class ExtractAirTemperatureSensor(SmartySensor):
|
class ExtractAirTemperatureSensor(SmartySensor):
|
||||||
"""Extract Air Temperature Sensor."""
|
"""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."""
|
"""Supply Air Temperature Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Extract Air Temperature",
|
name=f"{name} Extract Air Temperature",
|
||||||
|
@ -97,6 +99,7 @@ class ExtractAirTemperatureSensor(SmartySensor):
|
||||||
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
|
self._attr_unique_id = f"{entry_id}_extract_air_temperature"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -107,7 +110,7 @@ class ExtractAirTemperatureSensor(SmartySensor):
|
||||||
class OutdoorAirTemperatureSensor(SmartySensor):
|
class OutdoorAirTemperatureSensor(SmartySensor):
|
||||||
"""Extract Air Temperature Sensor."""
|
"""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."""
|
"""Outdoor Air Temperature Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Outdoor Air Temperature",
|
name=f"{name} Outdoor Air Temperature",
|
||||||
|
@ -115,6 +118,7 @@ class OutdoorAirTemperatureSensor(SmartySensor):
|
||||||
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
|
self._attr_unique_id = f"{entry_id}_outdoor_air_temperature"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -125,7 +129,7 @@ class OutdoorAirTemperatureSensor(SmartySensor):
|
||||||
class SupplyFanSpeedSensor(SmartySensor):
|
class SupplyFanSpeedSensor(SmartySensor):
|
||||||
"""Supply Fan Speed RPM."""
|
"""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."""
|
"""Supply Fan Speed RPM Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Supply Fan Speed",
|
name=f"{name} Supply Fan Speed",
|
||||||
|
@ -133,6 +137,7 @@ class SupplyFanSpeedSensor(SmartySensor):
|
||||||
unit_of_measurement=None,
|
unit_of_measurement=None,
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
|
self._attr_unique_id = f"{entry_id}_supply_fan_speed"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -143,7 +148,7 @@ class SupplyFanSpeedSensor(SmartySensor):
|
||||||
class ExtractFanSpeedSensor(SmartySensor):
|
class ExtractFanSpeedSensor(SmartySensor):
|
||||||
"""Extract Fan Speed RPM."""
|
"""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."""
|
"""Extract Fan Speed RPM Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Extract Fan Speed",
|
name=f"{name} Extract Fan Speed",
|
||||||
|
@ -151,6 +156,7 @@ class ExtractFanSpeedSensor(SmartySensor):
|
||||||
unit_of_measurement=None,
|
unit_of_measurement=None,
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
|
self._attr_unique_id = f"{entry_id}_extract_fan_speed"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -161,7 +167,7 @@ class ExtractFanSpeedSensor(SmartySensor):
|
||||||
class FilterDaysLeftSensor(SmartySensor):
|
class FilterDaysLeftSensor(SmartySensor):
|
||||||
"""Filter Days Left."""
|
"""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."""
|
"""Filter Days Left Init."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
name=f"{name} Filter Days Left",
|
name=f"{name} Filter Days Left",
|
||||||
|
@ -170,6 +176,7 @@ class FilterDaysLeftSensor(SmartySensor):
|
||||||
smarty=smarty,
|
smarty=smarty,
|
||||||
)
|
)
|
||||||
self._days_left = 91
|
self._days_left = 91
|
||||||
|
self._attr_unique_id = f"{entry_id}_filter_days_left"
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
|
|
@ -37,10 +37,24 @@ def mock_smarty() -> Generator[AsyncMock]:
|
||||||
):
|
):
|
||||||
client = mock_client.return_value
|
client = mock_client.return_value
|
||||||
client.update.return_value = True
|
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
|
yield client
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_config_entry() -> MockConfigEntry:
|
def mock_config_entry() -> MockConfigEntry:
|
||||||
"""Return the default mocked config entry."""
|
"""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",
|
||||||
|
)
|
||||||
|
|
|
@ -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': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'entity_id': 'binary_sensor.mock_title_alarm',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'off',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[binary_sensor.mock_title_boost_state-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'entity_id': 'binary_sensor.mock_title_boost_state',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'off',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[binary_sensor.mock_title_warning-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'entity_id': 'binary_sensor.mock_title_warning',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'off',
|
||||||
|
})
|
||||||
|
# ---
|
|
@ -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': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'fan',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'fan.mock_title',
|
||||||
|
'has_entity_name': False,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'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': <FanEntityFeature: 49>,
|
||||||
|
'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': <FanEntityFeature: 49>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'fan.mock_title',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'off',
|
||||||
|
})
|
||||||
|
# ---
|
|
@ -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': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||||
|
'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': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# 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': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.mock_title_extract_air_temperature',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '23',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.mock_title_extract_fan_speed-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'entity_id': 'sensor.mock_title_extract_fan_speed',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '100',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.mock_title_filter_days_left-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.TIMESTAMP: 'timestamp'>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'entity_id': 'sensor.mock_title_filter_days_left',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||||
|
'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': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# 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': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.mock_title_outdoor_air_temperature',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '24',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.mock_title_supply_air_temperature-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||||
|
'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': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# 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': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.mock_title_supply_air_temperature',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '20',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.mock_title_supply_fan_speed-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'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': <ANY>,
|
||||||
|
'entity_id': 'sensor.mock_title_supply_fan_speed',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '66',
|
||||||
|
})
|
||||||
|
# ---
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
Loading…
Reference in New Issue