Allow MS face detection to handle updating entities when no face is detected (#17593)

* Allow Microsoft face detection to handle updating entities when no face is detected

* Remove microsoft_face_detect_no_face_detected.json and hard code in simple empty list into the tests
This commit is contained in:
Neil Crosby authored and Pascal Vizeli committed 2018-11-02 10:50:43 +01:00
1 parent a4c0c34028
commit cb7ae5cdf2
4 files changed
+47 -10

No files matched your search

@@ -102,7 +102,7 @@ class MicrosoftFaceDetectEntity(ImageProcessingFaceEntity):
return
if not face_data:
return
face_data = []
faces = []
for face in face_data:
@@ -83,18 +83,16 @@ class MicrosoftFaceIdentifyEntity(ImageProcessingFaceEntity):
This method is a coroutine.
"""
detect = None
detect = []
try:
face_data = await self._api.call_api(
'post', 'detect', image, binary=True)
if not face_data:
return
face_ids = [data['faceId'] for data in face_data]
detect = await self._api.call_api(
'post', 'identify',
{'faceIds': face_ids, 'personGroupId': self._face_group})
if face_data:
face_ids = [data['faceId'] for data in face_data]
detect = await self._api.call_api(
'post', 'identify',
{'faceIds': face_ids, 'personGroupId': self._face_group})
except HomeAssistantError as err:
_LOGGER.error("Can't process image on Microsoft face: %s", err)