diff --git a/homeassistant/components/tensorflow/__init__.py b/homeassistant/components/tensorflow/__init__.py index 00a695d6aa8..7ed20cbe4b6 100644 --- a/homeassistant/components/tensorflow/__init__.py +++ b/homeassistant/components/tensorflow/__init__.py @@ -1 +1,4 @@ """The tensorflow component.""" + +DOMAIN = "tensorflow" +CONF_GRAPH = "graph" diff --git a/homeassistant/components/tensorflow/image_processing.py b/homeassistant/components/tensorflow/image_processing.py index 0fb069e8da8..05be56d444d 100644 --- a/homeassistant/components/tensorflow/image_processing.py +++ b/homeassistant/components/tensorflow/image_processing.py @@ -26,15 +26,21 @@ from homeassistant.const import ( CONF_SOURCE, EVENT_HOMEASSISTANT_START, ) -from homeassistant.core import HomeAssistant, split_entity_id +from homeassistant.core import ( + DOMAIN as HOMEASSISTANT_DOMAIN, + HomeAssistant, + split_entity_id, +) from homeassistant.helpers import config_validation as cv, template from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.issue_registry import IssueSeverity, create_issue from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util.pil import draw_box +from . import CONF_GRAPH, DOMAIN + os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" -DOMAIN = "tensorflow" _LOGGER = logging.getLogger(__name__) ATTR_MATCHES = "matches" @@ -47,7 +53,6 @@ CONF_BOTTOM = "bottom" CONF_CATEGORIES = "categories" CONF_CATEGORY = "category" CONF_FILE_OUT = "file_out" -CONF_GRAPH = "graph" CONF_LABELS = "labels" CONF_LABEL_OFFSET = "label_offset" CONF_LEFT = "left" @@ -110,6 +115,21 @@ def setup_platform( discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the TensorFlow image processing platform.""" + create_issue( + hass, + HOMEASSISTANT_DOMAIN, + f"deprecated_system_packages_yaml_integration_{DOMAIN}", + breaks_in_ha_version="2025.12.0", + is_fixable=False, + issue_domain=DOMAIN, + severity=IssueSeverity.WARNING, + translation_key="deprecated_system_packages_yaml_integration", + translation_placeholders={ + "domain": DOMAIN, + "integration_title": "Tensorflow", + }, + ) + model_config = config[CONF_MODEL] model_dir = model_config.get(CONF_MODEL_DIR) or hass.config.path("tensorflow") labels = model_config.get(CONF_LABELS) or hass.config.path( diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 12c71e72920..0681504d858 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1566,6 +1566,9 @@ pybravia==0.3.4 # homeassistant.components.cloudflare pycfdns==3.0.0 +# homeassistant.components.tensorflow +# pycocotools==2.0.6 + # homeassistant.components.comfoconnect pycomfoconnect==0.5.1 @@ -2371,6 +2374,9 @@ temescal==0.5 # homeassistant.components.temper temperusb==1.6.1 +# homeassistant.components.tensorflow +# tensorflow==2.5.0 + # homeassistant.components.tesla_fleet # homeassistant.components.teslemetry # homeassistant.components.tessie @@ -2388,6 +2394,9 @@ teslemetry-stream==0.7.9 # homeassistant.components.tessie tessie-api==0.1.1 +# homeassistant.components.tensorflow +# tf-models-official==2.5.0 + # homeassistant.components.thermobeacon thermobeacon-ble==0.10.0 diff --git a/tests/components/tensorflow/__init__.py b/tests/components/tensorflow/__init__.py new file mode 100644 index 00000000000..458de30c9fa --- /dev/null +++ b/tests/components/tensorflow/__init__.py @@ -0,0 +1 @@ +"""TensorFlow component tests.""" diff --git a/tests/components/tensorflow/test_image_processing.py b/tests/components/tensorflow/test_image_processing.py new file mode 100644 index 00000000000..06199b9c60c --- /dev/null +++ b/tests/components/tensorflow/test_image_processing.py @@ -0,0 +1,40 @@ +"""Tensorflow test.""" + +from unittest.mock import Mock, patch + +from homeassistant.components.image_processing import DOMAIN as IMAGE_PROCESSING_DOMAINN +from homeassistant.components.tensorflow import CONF_GRAPH, DOMAIN as TENSORFLOW_DOMAIN +from homeassistant.const import CONF_ENTITY_ID, CONF_MODEL, CONF_PLATFORM, CONF_SOURCE +from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant +from homeassistant.helpers import issue_registry as ir +from homeassistant.setup import async_setup_component + + +@patch.dict("sys.modules", tensorflow=Mock()) +async def test_repair_issue_is_created( + hass: HomeAssistant, + issue_registry: ir.IssueRegistry, +) -> None: + """Test repair issue is created.""" + assert await async_setup_component( + hass, + IMAGE_PROCESSING_DOMAINN, + { + IMAGE_PROCESSING_DOMAINN: [ + { + CONF_PLATFORM: TENSORFLOW_DOMAIN, + CONF_SOURCE: [ + {CONF_ENTITY_ID: "camera.test_camera"}, + ], + CONF_MODEL: { + CONF_GRAPH: ".", + }, + } + ], + }, + ) + await hass.async_block_till_done() + assert ( + HOMEASSISTANT_DOMAIN, + f"deprecated_system_packages_yaml_integration_{TENSORFLOW_DOMAIN}", + ) in issue_registry.issues