diff --git a/homeassistant/components/homee/sensor.py b/homeassistant/components/homee/sensor.py index 71508c5d669..5fc19e9bfdf 100644 --- a/homeassistant/components/homee/sensor.py +++ b/homeassistant/components/homee/sensor.py @@ -6,10 +6,7 @@ from dataclasses import dataclass from pyHomee.const import AttributeType, NodeState from pyHomee.model import HomeeAttribute, HomeeNode -from homeassistant.components.automation import automations_with_entity -from homeassistant.components.script import scripts_with_entity from homeassistant.components.sensor import ( - DOMAIN as SENSOR_DOMAIN, SensorDeviceClass, SensorEntity, SensorEntityDescription, @@ -17,17 +14,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.const import EntityCategory from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback -from homeassistant.helpers.issue_registry import ( - IssueSeverity, - async_create_issue, - async_delete_issue, -) from . import HomeeConfigEntry from .const import ( - DOMAIN, HOMEE_UNIT_TO_HA_UNIT, OPEN_CLOSE_MAP, OPEN_CLOSE_MAP_REVERSED, @@ -109,11 +99,6 @@ SENSOR_DESCRIPTIONS: dict[AttributeType, HomeeSensorEntityDescription] = { device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, ), - AttributeType.CURRENT_VALVE_POSITION: HomeeSensorEntityDescription( - key="valve_position", - entity_category=EntityCategory.DIAGNOSTIC, - state_class=SensorStateClass.MEASUREMENT, - ), AttributeType.DAWN: HomeeSensorEntityDescription( key="dawn", device_class=SensorDeviceClass.ILLUMINANCE, @@ -294,57 +279,12 @@ NODE_SENSOR_DESCRIPTIONS: tuple[HomeeNodeSensorEntityDescription, ...] = ( ) -def entity_used_in(hass: HomeAssistant, entity_id: str) -> list[str]: - """Get list of related automations and scripts.""" - used_in = automations_with_entity(hass, entity_id) - used_in += scripts_with_entity(hass, entity_id) - return used_in - - async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Add the homee platform for the sensor components.""" - ent_reg = er.async_get(hass) - - def add_deprecated_entity( - attribute: HomeeAttribute, description: HomeeSensorEntityDescription - ) -> list[HomeeSensor]: - """Add deprecated entities.""" - deprecated_entities: list[HomeeSensor] = [] - entity_uid = f"{config_entry.runtime_data.settings.uid}-{attribute.node_id}-{attribute.id}" - if entity_id := ent_reg.async_get_entity_id(SENSOR_DOMAIN, DOMAIN, entity_uid): - entity_entry = ent_reg.async_get(entity_id) - if entity_entry and entity_entry.disabled: - ent_reg.async_remove(entity_id) - async_delete_issue( - hass, - DOMAIN, - f"deprecated_entity_{entity_uid}", - ) - elif entity_entry: - deprecated_entities.append( - HomeeSensor(attribute, config_entry, description) - ) - if entity_used_in(hass, entity_id): - async_create_issue( - hass, - DOMAIN, - f"deprecated_entity_{entity_uid}", - breaks_in_ha_version="2025.12.0", - is_fixable=False, - severity=IssueSeverity.WARNING, - translation_key="deprecated_entity", - translation_placeholders={ - "name": str( - entity_entry.name or entity_entry.original_name - ), - "entity": entity_id, - }, - ) - return deprecated_entities async def add_sensor_entities( config_entry: HomeeConfigEntry, @@ -362,19 +302,13 @@ async def async_setup_entry( ) # Node attributes that are sensors. - for attribute in node.attributes: - if attribute.type == AttributeType.CURRENT_VALVE_POSITION: - entities.extend( - add_deprecated_entity( - attribute, SENSOR_DESCRIPTIONS[attribute.type] - ) - ) - elif attribute.type in SENSOR_DESCRIPTIONS and not attribute.editable: - entities.append( - HomeeSensor( - attribute, config_entry, SENSOR_DESCRIPTIONS[attribute.type] - ) - ) + entities.extend( + HomeeSensor( + attribute, config_entry, SENSOR_DESCRIPTIONS[attribute.type] + ) + for attribute in node.attributes + if attribute.type in SENSOR_DESCRIPTIONS and not attribute.editable + ) if entities: async_add_entities(entities) diff --git a/homeassistant/components/homee/strings.json b/homeassistant/components/homee/strings.json index 535c5b9628a..9187c9956c7 100644 --- a/homeassistant/components/homee/strings.json +++ b/homeassistant/components/homee/strings.json @@ -495,11 +495,5 @@ "invalid_preset_mode": { "message": "Invalid preset mode: {preset_mode}. Turning on is only supported with preset mode 'Manual'." } - }, - "issues": { - "deprecated_entity": { - "description": "The Homee entity `{entity}` is deprecated and will be removed in release 2025.12.\nThe valve is available directly in the respective climate entity.\nPlease update your automations and scripts, disable `{entity}` and reload the integration/restart Home Assistant to fix this issue.", - "title": "The Homee {name} entity is deprecated" - } } } diff --git a/tests/components/homee/test_sensor.py b/tests/components/homee/test_sensor.py index b51b3a23b75..0e7bde2e76b 100644 --- a/tests/components/homee/test_sensor.py +++ b/tests/components/homee/test_sensor.py @@ -10,20 +10,17 @@ from homeassistant.components.homeassistant import ( SERVICE_UPDATE_ENTITY, ) from homeassistant.components.homee.const import ( - DOMAIN, OPEN_CLOSE_MAP, OPEN_CLOSE_MAP_REVERSED, WINDOW_MAP, WINDOW_MAP_REVERSED, ) -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity_registry as er, issue_registry as ir +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from . import async_update_attribute_value, build_mock_node, setup_integration -from .conftest import HOMEE_ID from tests.common import MockConfigEntry, snapshot_platform @@ -100,79 +97,6 @@ async def test_window_position( ) -@pytest.mark.parametrize( - ("disabler", "expected_entity", "expected_issue"), - [ - (None, False, False), - (er.RegistryEntryDisabler.USER, True, True), - ], -) -async def test_sensor_deprecation( - hass: HomeAssistant, - mock_homee: MagicMock, - mock_config_entry: MockConfigEntry, - issue_registry: ir.IssueRegistry, - entity_registry: er.EntityRegistry, - disabler: er.RegistryEntryDisabler, - expected_entity: bool, - expected_issue: bool, -) -> None: - """Test sensor deprecation issue.""" - entity_uid = f"{HOMEE_ID}-1-9" - entity_id = "test_multisensor_valve_position" - entity_registry.async_get_or_create( - SENSOR_DOMAIN, - DOMAIN, - entity_uid, - suggested_object_id=entity_id, - disabled_by=disabler, - ) - - with patch( - "homeassistant.components.homee.sensor.entity_used_in", return_value=True - ): - await setup_sensor(hass, mock_homee, mock_config_entry) - - assert (entity_registry.async_get(f"sensor.{entity_id}") is None) is expected_entity - assert ( - issue_registry.async_get_issue( - domain=DOMAIN, - issue_id=f"deprecated_entity_{entity_uid}", - ) - is None - ) is expected_issue - - -async def test_sensor_deprecation_unused_entity( - hass: HomeAssistant, - mock_homee: MagicMock, - mock_config_entry: MockConfigEntry, - issue_registry: ir.IssueRegistry, - entity_registry: er.EntityRegistry, -) -> None: - """Test sensor deprecation issue.""" - entity_uid = f"{HOMEE_ID}-1-9" - entity_id = "test_multisensor_valve_position" - entity_registry.async_get_or_create( - SENSOR_DOMAIN, - DOMAIN, - entity_uid, - suggested_object_id=entity_id, - disabled_by=None, - ) - - await setup_sensor(hass, mock_homee, mock_config_entry) - - assert entity_registry.async_get(f"sensor.{entity_id}") is not None - assert ( - issue_registry.async_get_issue( - domain=DOMAIN, - issue_id=f"deprecated_entity_{entity_uid}", - ) - is None - ) - - async def test_entity_connection_listener( hass: HomeAssistant, mock_homee: MagicMock,