1414from typing import Tuple , Dict , List
1515from pathlib import Path
1616
17- from PIL import Image , ImageDraw
17+ from PIL import Image , ImageDraw , UnidentifiedImageError
18+ import voluptuous as vol
1819
1920import codeprojectai .core as cpai
2021
2122import homeassistant .helpers .config_validation as cv
2223import homeassistant .util .dt as dt_util
23- import voluptuous as vol
2424from homeassistant .util .pil import draw_box
2525from homeassistant .components .image_processing import (
2626 ATTR_CONFIDENCE ,
6363OBJECT_TYPES = [ANIMAL , OTHER , PERSON , VEHICLE ]
6464
6565
66- CONF_API_KEY = "api_key"
6766CONF_TARGET = "target"
6867CONF_TARGETS = "targets"
6968CONF_TIMEOUT = "timeout"
8180CONF_CROP_ROI = "crop_to_roi"
8281
8382DATETIME_FORMAT = "%Y-%m-%d_%H-%M-%S-%f"
84- DEFAULT_API_KEY = ""
8583DEFAULT_TARGETS = [{CONF_TARGET : PERSON }]
8684DEFAULT_TIMEOUT = 10
8785DEFAULT_ROI_Y_MIN = 0.0
122120 {
123121 vol .Required (CONF_IP_ADDRESS ): cv .string ,
124122 vol .Required (CONF_PORT ): cv .port ,
125- vol .Optional (CONF_API_KEY , default = DEFAULT_API_KEY ): cv .string ,
123+ // vol .Optional (CONF_API_KEY , default = DEFAULT_API_KEY ): cv .string ,
126124 vol .Optional (CONF_TIMEOUT , default = DEFAULT_TIMEOUT ): cv .positive_int ,
127125 vol .Optional (CONF_CUSTOM_MODEL , default = "" ): cv .string ,
128126 vol .Optional (CONF_TARGETS , default = DEFAULT_TARGETS ): vol .All (
@@ -225,7 +223,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
225223 object_entity = ObjectClassifyEntity (
226224 ip_address = config .get (CONF_IP_ADDRESS ),
227225 port = config .get (CONF_PORT ),
228- api_key = config .get (CONF_API_KEY ),
229226 timeout = config .get (CONF_TIMEOUT ),
230227 custom_model = config .get (CONF_CUSTOM_MODEL ),
231228 targets = config .get (CONF_TARGETS ),
@@ -255,7 +252,6 @@ def __init__(
255252 self ,
256253 ip_address ,
257254 port ,
258- api_key ,
259255 timeout ,
260256 custom_model ,
261257 targets ,
@@ -279,7 +275,6 @@ def __init__(
279275 self ._cpai_object = cpai .CodeProjectAIObject (
280276 ip = ip_address ,
281277 port = port ,
282- api_key = api_key ,
283278 timeout = timeout ,
284279 min_confidence = MIN_CONFIDENCE ,
285280 custom_model = custom_model ,
0 commit comments