mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Migrate Smarty to has entity name (#129145)
This commit is contained in:
parent
5dd4b77270
commit
1bb32a05a9
@ -32,19 +32,19 @@ class SmartyBinarySensorEntityDescription(BinarySensorEntityDescription):
|
|||||||
ENTITIES: tuple[SmartyBinarySensorEntityDescription, ...] = (
|
ENTITIES: tuple[SmartyBinarySensorEntityDescription, ...] = (
|
||||||
SmartyBinarySensorEntityDescription(
|
SmartyBinarySensorEntityDescription(
|
||||||
key="alarm",
|
key="alarm",
|
||||||
name="Alarm",
|
translation_key="alarm",
|
||||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
value_fn=lambda smarty: smarty.alarm,
|
value_fn=lambda smarty: smarty.alarm,
|
||||||
),
|
),
|
||||||
SmartyBinarySensorEntityDescription(
|
SmartyBinarySensorEntityDescription(
|
||||||
key="warning",
|
key="warning",
|
||||||
name="Warning",
|
translation_key="warning",
|
||||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
value_fn=lambda smarty: smarty.warning,
|
value_fn=lambda smarty: smarty.warning,
|
||||||
),
|
),
|
||||||
SmartyBinarySensorEntityDescription(
|
SmartyBinarySensorEntityDescription(
|
||||||
key="boost",
|
key="boost",
|
||||||
name="Boost State",
|
translation_key="boost_state",
|
||||||
value_fn=lambda smarty: smarty.boost,
|
value_fn=lambda smarty: smarty.boost,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -77,7 +77,6 @@ class SmartyBinarySensor(SmartyEntity, BinarySensorEntity):
|
|||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
self._attr_name = f"{coordinator.config_entry.title} {entity_description.name}"
|
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{coordinator.config_entry.entry_id}_{entity_description.key}"
|
f"{coordinator.config_entry.entry_id}_{entity_description.key}"
|
||||||
)
|
)
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
"""Smarty Entity class."""
|
"""Smarty Entity class."""
|
||||||
|
|
||||||
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
|
from . import DOMAIN
|
||||||
from .coordinator import SmartyCoordinator
|
from .coordinator import SmartyCoordinator
|
||||||
|
|
||||||
|
|
||||||
class SmartyEntity(CoordinatorEntity[SmartyCoordinator]):
|
class SmartyEntity(CoordinatorEntity[SmartyCoordinator]):
|
||||||
"""Representation of a Smarty Entity."""
|
"""Representation of a Smarty Entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
|
def __init__(self, coordinator: SmartyCoordinator) -> None:
|
||||||
|
"""Initialize the entity."""
|
||||||
|
super().__init__(coordinator)
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, coordinator.config_entry.entry_id)},
|
||||||
|
manufacturer="Salda",
|
||||||
|
)
|
||||||
|
@ -41,7 +41,8 @@ async def async_setup_entry(
|
|||||||
class SmartyFan(SmartyEntity, FanEntity):
|
class SmartyFan(SmartyEntity, FanEntity):
|
||||||
"""Representation of a Smarty Fan."""
|
"""Representation of a Smarty Fan."""
|
||||||
|
|
||||||
_attr_icon = "mdi:air-conditioner"
|
_attr_name = None
|
||||||
|
_attr_translation_key = "fan"
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
FanEntityFeature.SET_SPEED
|
FanEntityFeature.SET_SPEED
|
||||||
| FanEntityFeature.TURN_OFF
|
| FanEntityFeature.TURN_OFF
|
||||||
@ -52,7 +53,6 @@ class SmartyFan(SmartyEntity, FanEntity):
|
|||||||
def __init__(self, coordinator: SmartyCoordinator) -> None:
|
def __init__(self, coordinator: SmartyCoordinator) -> None:
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._attr_name = coordinator.config_entry.title
|
|
||||||
self._smarty_fan_speed = 0
|
self._smarty_fan_speed = 0
|
||||||
self._smarty = coordinator.client
|
self._smarty = coordinator.client
|
||||||
self._attr_unique_id = coordinator.config_entry.entry_id
|
self._attr_unique_id = coordinator.config_entry.entry_id
|
||||||
|
9
homeassistant/components/smarty/icons.json
Normal file
9
homeassistant/components/smarty/icons.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"entity": {
|
||||||
|
"fan": {
|
||||||
|
"fan": {
|
||||||
|
"default": "mdi:air-conditioner"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -42,38 +42,38 @@ class SmartySensorDescription(SensorEntityDescription):
|
|||||||
ENTITIES: tuple[SmartySensorDescription, ...] = (
|
ENTITIES: tuple[SmartySensorDescription, ...] = (
|
||||||
SmartySensorDescription(
|
SmartySensorDescription(
|
||||||
key="supply_air_temperature",
|
key="supply_air_temperature",
|
||||||
name="Supply Air Temperature",
|
translation_key="supply_air_temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
value_fn=lambda smarty: smarty.supply_air_temperature,
|
value_fn=lambda smarty: smarty.supply_air_temperature,
|
||||||
),
|
),
|
||||||
SmartySensorDescription(
|
SmartySensorDescription(
|
||||||
key="extract_air_temperature",
|
key="extract_air_temperature",
|
||||||
name="Extract Air Temperature",
|
translation_key="extract_air_temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
value_fn=lambda smarty: smarty.extract_air_temperature,
|
value_fn=lambda smarty: smarty.extract_air_temperature,
|
||||||
),
|
),
|
||||||
SmartySensorDescription(
|
SmartySensorDescription(
|
||||||
key="outdoor_air_temperature",
|
key="outdoor_air_temperature",
|
||||||
name="Outdoor Air Temperature",
|
translation_key="outdoor_air_temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
value_fn=lambda smarty: smarty.outdoor_air_temperature,
|
value_fn=lambda smarty: smarty.outdoor_air_temperature,
|
||||||
),
|
),
|
||||||
SmartySensorDescription(
|
SmartySensorDescription(
|
||||||
key="supply_fan_speed",
|
key="supply_fan_speed",
|
||||||
name="Supply Fan Speed",
|
translation_key="supply_fan_speed",
|
||||||
value_fn=lambda smarty: smarty.supply_fan_speed,
|
value_fn=lambda smarty: smarty.supply_fan_speed,
|
||||||
),
|
),
|
||||||
SmartySensorDescription(
|
SmartySensorDescription(
|
||||||
key="extract_fan_speed",
|
key="extract_fan_speed",
|
||||||
name="Extract Fan Speed",
|
translation_key="extract_fan_speed",
|
||||||
value_fn=lambda smarty: smarty.extract_fan_speed,
|
value_fn=lambda smarty: smarty.extract_fan_speed,
|
||||||
),
|
),
|
||||||
SmartySensorDescription(
|
SmartySensorDescription(
|
||||||
key="filter_days_left",
|
key="filter_days_left",
|
||||||
name="Filter Days Left",
|
translation_key="filter_days_left",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value_fn=get_filter_days_left,
|
value_fn=get_filter_days_left,
|
||||||
),
|
),
|
||||||
@ -107,7 +107,6 @@ class SmartySensor(SmartyEntity, SensorEntity):
|
|||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
self._attr_name = f"{coordinator.config_entry.title} {entity_description.name}"
|
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{coordinator.config_entry.entry_id}_{entity_description.key}"
|
f"{coordinator.config_entry.entry_id}_{entity_description.key}"
|
||||||
)
|
)
|
||||||
|
@ -29,5 +29,38 @@
|
|||||||
"title": "YAML import failed due to an authentication error",
|
"title": "YAML import failed due to an authentication error",
|
||||||
"description": "Configuring {integration_title} using YAML is being removed but there was an authentication error while importing your existing configuration.\nSetup will not proceed.\n\nVerify that your {integration_title} is operating correctly and restart Home Assistant to attempt the import again.\n\nAlternatively, you may remove the `{domain}` configuration from your configuration.yaml entirely, restart Home Assistant, and add the {integration_title} integration manually."
|
"description": "Configuring {integration_title} using YAML is being removed but there was an authentication error while importing your existing configuration.\nSetup will not proceed.\n\nVerify that your {integration_title} is operating correctly and restart Home Assistant to attempt the import again.\n\nAlternatively, you may remove the `{domain}` configuration from your configuration.yaml entirely, restart Home Assistant, and add the {integration_title} integration manually."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"binary_sensor": {
|
||||||
|
"alarm": {
|
||||||
|
"name": "Alarm"
|
||||||
|
},
|
||||||
|
"warning": {
|
||||||
|
"name": "Warning"
|
||||||
|
},
|
||||||
|
"boost_state": {
|
||||||
|
"name": "Boost state"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"supply_air_temperature": {
|
||||||
|
"name": "Supply air temperature"
|
||||||
|
},
|
||||||
|
"extract_air_temperature": {
|
||||||
|
"name": "Extract air temperature"
|
||||||
|
},
|
||||||
|
"outdoor_air_temperature": {
|
||||||
|
"name": "Outdoor air temperature"
|
||||||
|
},
|
||||||
|
"supply_fan_speed": {
|
||||||
|
"name": "Supply fan speed"
|
||||||
|
},
|
||||||
|
"extract_fan_speed": {
|
||||||
|
"name": "Extract fan speed"
|
||||||
|
},
|
||||||
|
"filter_days_left": {
|
||||||
|
"name": "Filter days left"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
'domain': 'binary_sensor',
|
'domain': 'binary_sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'binary_sensor.mock_title_alarm',
|
'entity_id': 'binary_sensor.mock_title_alarm',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -23,11 +23,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
|
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Alarm',
|
'original_name': 'Alarm',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'alarm',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_alarm',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_alarm',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -59,7 +59,7 @@
|
|||||||
'domain': 'binary_sensor',
|
'domain': 'binary_sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'binary_sensor.mock_title_boost_state',
|
'entity_id': 'binary_sensor.mock_title_boost_state',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -70,11 +70,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Boost State',
|
'original_name': 'Boost state',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'boost_state',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_boost',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_boost',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -82,7 +82,7 @@
|
|||||||
# name: test_all_entities[binary_sensor.mock_title_boost_state-state]
|
# name: test_all_entities[binary_sensor.mock_title_boost_state-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'Mock Title Boost State',
|
'friendly_name': 'Mock Title Boost state',
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'binary_sensor.mock_title_boost_state',
|
'entity_id': 'binary_sensor.mock_title_boost_state',
|
||||||
@ -105,7 +105,7 @@
|
|||||||
'domain': 'binary_sensor',
|
'domain': 'binary_sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'binary_sensor.mock_title_warning',
|
'entity_id': 'binary_sensor.mock_title_warning',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -116,11 +116,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
|
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Warning',
|
'original_name': 'Warning',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'warning',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_warning',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_warning',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
'domain': 'fan',
|
'domain': 'fan',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'fan.mock_title',
|
'entity_id': 'fan.mock_title',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -24,12 +24,12 @@
|
|||||||
'options': dict({
|
'options': dict({
|
||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': 'mdi:air-conditioner',
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title',
|
'original_name': None,
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': <FanEntityFeature: 49>,
|
'supported_features': <FanEntityFeature: 49>,
|
||||||
'translation_key': None,
|
'translation_key': 'fan',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -38,7 +38,6 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'Mock Title',
|
'friendly_name': 'Mock Title',
|
||||||
'icon': 'mdi:air-conditioner',
|
|
||||||
'percentage': 0,
|
'percentage': 0,
|
||||||
'percentage_step': 33.333333333333336,
|
'percentage_step': 33.333333333333336,
|
||||||
'preset_mode': None,
|
'preset_mode': None,
|
||||||
|
33
tests/components/smarty/snapshots/test_init.ambr
Normal file
33
tests/components/smarty/snapshots/test_init.ambr
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_device
|
||||||
|
DeviceRegistryEntrySnapshot({
|
||||||
|
'area_id': None,
|
||||||
|
'config_entries': <ANY>,
|
||||||
|
'configuration_url': None,
|
||||||
|
'connections': set({
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'entry_type': None,
|
||||||
|
'hw_version': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'identifiers': set({
|
||||||
|
tuple(
|
||||||
|
'smarty',
|
||||||
|
'01JAZ5DPW8C62D620DGYNG2R8H',
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
'is_new': False,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'manufacturer': 'Salda',
|
||||||
|
'model': None,
|
||||||
|
'model_id': None,
|
||||||
|
'name': 'Mock Title',
|
||||||
|
'name_by_user': None,
|
||||||
|
'primary_config_entry': <ANY>,
|
||||||
|
'serial_number': None,
|
||||||
|
'suggested_area': None,
|
||||||
|
'sw_version': None,
|
||||||
|
'via_device_id': None,
|
||||||
|
})
|
||||||
|
# ---
|
@ -12,7 +12,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.mock_title_extract_air_temperature',
|
'entity_id': 'sensor.mock_title_extract_air_temperature',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -23,11 +23,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Extract Air Temperature',
|
'original_name': 'Extract air temperature',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'extract_air_temperature',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_extract_air_temperature',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_extract_air_temperature',
|
||||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
})
|
})
|
||||||
@ -36,7 +36,7 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'device_class': 'temperature',
|
'device_class': 'temperature',
|
||||||
'friendly_name': 'Mock Title Extract Air Temperature',
|
'friendly_name': 'Mock Title Extract air temperature',
|
||||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
@ -60,7 +60,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.mock_title_extract_fan_speed',
|
'entity_id': 'sensor.mock_title_extract_fan_speed',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -71,11 +71,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Extract Fan Speed',
|
'original_name': 'Extract fan speed',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'extract_fan_speed',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_extract_fan_speed',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_extract_fan_speed',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -83,7 +83,7 @@
|
|||||||
# name: test_all_entities[sensor.mock_title_extract_fan_speed-state]
|
# name: test_all_entities[sensor.mock_title_extract_fan_speed-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'Mock Title Extract Fan Speed',
|
'friendly_name': 'Mock Title Extract fan speed',
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'sensor.mock_title_extract_fan_speed',
|
'entity_id': 'sensor.mock_title_extract_fan_speed',
|
||||||
@ -106,7 +106,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.mock_title_filter_days_left',
|
'entity_id': 'sensor.mock_title_filter_days_left',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -117,11 +117,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.TIMESTAMP: 'timestamp'>,
|
'original_device_class': <SensorDeviceClass.TIMESTAMP: 'timestamp'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Filter Days Left',
|
'original_name': 'Filter days left',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'filter_days_left',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_filter_days_left',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_filter_days_left',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -130,7 +130,7 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'device_class': 'timestamp',
|
'device_class': 'timestamp',
|
||||||
'friendly_name': 'Mock Title Filter Days Left',
|
'friendly_name': 'Mock Title Filter days left',
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'sensor.mock_title_filter_days_left',
|
'entity_id': 'sensor.mock_title_filter_days_left',
|
||||||
@ -153,7 +153,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.mock_title_outdoor_air_temperature',
|
'entity_id': 'sensor.mock_title_outdoor_air_temperature',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -164,11 +164,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Outdoor Air Temperature',
|
'original_name': 'Outdoor air temperature',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'outdoor_air_temperature',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_outdoor_air_temperature',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_outdoor_air_temperature',
|
||||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
})
|
})
|
||||||
@ -177,7 +177,7 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'device_class': 'temperature',
|
'device_class': 'temperature',
|
||||||
'friendly_name': 'Mock Title Outdoor Air Temperature',
|
'friendly_name': 'Mock Title Outdoor air temperature',
|
||||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
@ -201,7 +201,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.mock_title_supply_air_temperature',
|
'entity_id': 'sensor.mock_title_supply_air_temperature',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -212,11 +212,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Supply Air Temperature',
|
'original_name': 'Supply air temperature',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'supply_air_temperature',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_supply_air_temperature',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_supply_air_temperature',
|
||||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
})
|
})
|
||||||
@ -225,7 +225,7 @@
|
|||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'device_class': 'temperature',
|
'device_class': 'temperature',
|
||||||
'friendly_name': 'Mock Title Supply Air Temperature',
|
'friendly_name': 'Mock Title Supply air temperature',
|
||||||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
@ -249,7 +249,7 @@
|
|||||||
'domain': 'sensor',
|
'domain': 'sensor',
|
||||||
'entity_category': None,
|
'entity_category': None,
|
||||||
'entity_id': 'sensor.mock_title_supply_fan_speed',
|
'entity_id': 'sensor.mock_title_supply_fan_speed',
|
||||||
'has_entity_name': False,
|
'has_entity_name': True,
|
||||||
'hidden_by': None,
|
'hidden_by': None,
|
||||||
'icon': None,
|
'icon': None,
|
||||||
'id': <ANY>,
|
'id': <ANY>,
|
||||||
@ -260,11 +260,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Mock Title Supply Fan Speed',
|
'original_name': 'Supply fan speed',
|
||||||
'platform': 'smarty',
|
'platform': 'smarty',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'supply_fan_speed',
|
||||||
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_supply_fan_speed',
|
'unique_id': '01JAZ5DPW8C62D620DGYNG2R8H_supply_fan_speed',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -272,7 +272,7 @@
|
|||||||
# name: test_all_entities[sensor.mock_title_supply_fan_speed-state]
|
# name: test_all_entities[sensor.mock_title_supply_fan_speed-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'Mock Title Supply Fan Speed',
|
'friendly_name': 'Mock Title Supply fan speed',
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'sensor.mock_title_supply_fan_speed',
|
'entity_id': 'sensor.mock_title_supply_fan_speed',
|
||||||
|
@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.smarty import DOMAIN
|
from homeassistant.components.smarty import DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.helpers import issue_registry as ir
|
from homeassistant.helpers import device_registry as dr, issue_registry as ir
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
from . import setup_integration
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
@ -60,3 +64,19 @@ async def test_import_flow_error(
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
"deprecated_yaml_import_issue_cannot_connect",
|
"deprecated_yaml_import_issue_cannot_connect",
|
||||||
) in issue_registry.issues
|
) in issue_registry.issues
|
||||||
|
|
||||||
|
|
||||||
|
async def test_device(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
mock_smarty: AsyncMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
) -> None:
|
||||||
|
"""Test device."""
|
||||||
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
device = device_registry.async_get_device(
|
||||||
|
identifiers={(DOMAIN, mock_config_entry.entry_id)}
|
||||||
|
)
|
||||||
|
assert device
|
||||||
|
assert device == snapshot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user