New image_processing custom component - HASS-Google-Vision

Hi all
I have just published an image processing component using Google Vision. This implements similar functionality to my deepstack custom component, but is using Googles cloud service, so no Docker fiddling or need for local hardware. It is a refinement of the approach from deepstack, aiming for simplicity to setup and use. You get 1000 images processing per month, which is fine for processing motion triggered captures in my home. Once you go over 1000 images per month the cost is something like 0.2 cents per image, so pretty reasonable.
Any feedback let me know here.
Cheers


11 Likes

Is the __init__.py file correct?

"""The amazon_rekognition component."""

I admit to asking this question from a position of ignorance in the way custom components are created but it looks wrong to me…

Also… The docs say…

Be sure that you understand how the image processing scan_interval works, or risk running up bills.

Which I am sure I do but can I just confirm that scan_interval in the image_processing platform config works exactly as it does for sensors, i.e.,

image_processing:
  - platform: google_vision
    api_key_file: /Users/robin/.homeassistant/Google_API_key.json
    source:
      - entity_id: camera.local_file
    scan_interval: 86400

Will call the service once every 24 hours.

I just want to make sure I’m clear :slight_smile:

As a slight aside is there a way to say ‘never’, maybe for example ‘scan_interval: 0’?

1 Like

That is correct. The scan_interval is once a year for this integration, so never in practice.

1 Like

Awesome! Am I right to assume that this solution does not require as many “horsepowers”, because the processing is done externally?

Processing is done on google servers yes, this integration should have no impact on your system

One more thing about scan_interval. If I execute service image_processing.scan only when motion detected how does it interact with what is set in scan_interval?

They are independent

1 Like

OK. So If I set scan_interval: 86400 it will send image to goolge once every 86400 seconds and each time when I fire service image_processing.scan? Sorry form…dummy questions :slight_smile:

Thats correct. Its not a dumb question, its the implementation of image processing that is a bit confusing and needs fixing

Just installed custom component but don’t get any image_processing objects and no errors in logs (even added homeassistant.components.google_vision: debug).

@Gluek ensure you follow the readme instructions to the letter, and also restart home assistant, and if on docker the container also.

Got it working on Hass.io but few more steps needed in case it helps anyone

For Hass.io installed on Debian (for Pi SSD boot), at first it won’t pass config check so needed to run this inside homeassistant docker:
sudo pip install google-cloud-vision

Changed key file location folder:
api_key_file: /config/key.json

And enabled API in Google Coud Vision API page

It’s working and pretty accurate for first try:
Capture

For manual trigger response time about 2 seconds

2 Likes

Sure, after adding all to config, installing manually all requirement via pip and restart i got:

WARNING (MainThread) [homeassistant.loader] You are using a custom integration for google_vision which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

but still no image processing in States.

Running quite old version with old python (can’t compile new on Rpi), may it matter?

arch	armv7l
dev	false
docker	false
hassio	false
os_name	Linux
python_version	3.5.6
timezone	Europe/Moscow
version	0.96.5
virtualenv	true

Well if everything is working as intended there is no need for pip installing anything.
@LbDab I think response time will depend on your location - in London response time is 1 sec.
@Gluek is the image_processing.goole_vision.. entity present? It has no state until you have performed processing calling the scan service. Another thing is to check the Google Vision service is available in Russia?

No. And image_processing.scan doesn’t have any entity_id objects to scan with.

Looks like it is available, enabled Cloud Vision API in google console, but can’t see any requests there.

Check your logs for more error messages (enable debug mode for loggin). HA has attempted to setup the integration but been unable to complete it

No more errors related to image_processing or google vision, even tried to grep home-assistant.log - no luck.

If I check configuration after HA restart I get error:
Platform not found: image_processing.google_vision

Well that error suggests the files are not in the custom_components directory.

Sure it’s right there, I even have warning at start:

WARNING (MainThread) [homeassistant.loader] You are using a custom integration for google_vision which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

and it’s created __pycache__ in component folder:

Just tried to download newer version, got error:

2019-10-21 13:16:14 ERROR (Thread-13) [homeassistant.util.package] Unable to install package simple-google-vision==0.2: ERROR: Could not find a version that satisfie
s the requirement simple-google-vision==0.2 (from versions: none)
ERROR: No matching distribution found for simple-google-vision==0.2
2019-10-21 13:16:14 ERROR (MainThread) [homeassistant.requirements] Not initializing google_vision because could not install requirement simple-google-vision==0.2

Got a clue on pypi site:
Requires: Python >=3.6
If it true now I get why it doesn’t work.