Add support for Microsoft Vision API services

This request is to add support for the Microsoft Computer Vision API

It is similar to the current Microsoft Face API component, but instead it can describe an still image taken from a camera

I tried to create my own custom components, but having problems getting the image content, and async calls…here is my code as reference

import asyncio

import logging
import requests
import json
import voluptuous as vol
import homeassistant.helpers.config_validation as cv

from homeassistant.exceptions import HomeAssistantError
from homeassistant.const import CONF_API_KEY, CONF_TIMEOUT, ATTR_NAME
from homeassistant.components.microsoft_face import CONF_AZURE_REGION, ATTR_CAMERA_ENTITY

_LOGGER = logging.getLogger(name)

DOMAIN = ‘microsoft_vision’
VISION_URL = “,Description
DEPENDENCIES = [‘camera’]

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_AZURE_REGION, default=“eastus2”): cv.string,
}, extra=vol.ALLOW_EXTRA)

vol.Required(ATTR_CAMERA_ENTITY): cv.string,

async def async_setup(hass, config):
azure_region = config[DOMAIN].get(CONF_AZURE_REGION)
api_key = config[DOMAIN].get(CONF_API_KEY)

async def call_api(service):
    entity_id =[ATTR_CAMERA_ENTITY]
    #component ='camera')
    component =

    if component is None:
        _LOGGER.error('Camera component not set up')

    #camera = component.get_entity(entity_id)
    #if camera is None:
    #    _LOGGER.error('Camera not found')
    #if not camera.is_on:
    #    _LOGGER.error('Camera is off')

        image = await component.async_get_image(hass, entity_id)

    except HomeAssistantError as err:
        _LOGGER.error("Failed to get image from %s, with error: %s", entity_id, err)        

        headers = {"Ocp-Apim-Subscription-Key": api_key,
                   "Content-Type": "application/octet-stream"}
        response =, headers=headers, data=image.content)
    except HomeAssistantError as err:
        _LOGGER.error("Failed to call Microsoft API with error: %s", err), 'call_api', call_api,

return True