Place the vision.py file in your HA config directory.
Now add the following to your HA config:
Config:
- platform: command_line
name: Important Mail
command: python3.6 /PATH_TO_CONFIG/vision.py
scan_interval: 14400
Replace PATH_TO_CONFIG with the absolute path to your config directory.
I have the scan interval set to every 4 hours, the Google Vision API only allows for 1000 images analyzed. So we want to try and keep our total requests under that value. The informed delivery service can provide up to 7 images per day, and you will always get zero on sunday. The solution is just to check for important mail once per day
I thought this idea was pretty awesome so I want ahead and made the changes needed on the hass side to make this part of the standard usps component without any extra work from the end user.
I’ve done some testing and it seems to be working well, but i’ll give it a couple days to flush out any errors before I submit it as a PR to the main repo. Feedback is welcome.
Just tested this and it seems to be working. I’m also working on building my google vision API into a component that can digest camera entities and return a string of OCR text.
EDIT: I’d be nice if the camera showed a “no mail” image instead of it just having an error loading when zero mail items are found via myusps
I tried deleting my mail.gif because it was 3 days old and Informed delivery showed new mail now getting Mail(Error loading image). Tried deleting usps.pickle and still getting the error
I made some tweaks, including adding in a no mail image, but I rarely have no mail so it’s difficult for me to test. I’d appreciate it if someone could test that has that condition.
Also improved the camera image rotation delay and added an interval parameter to the config to make it customize-able. All changes are in my repo linked above.
It’s just the amount of time to show each piece of mail. So if you set it at 30s the camera will show each piece of mail for 30s before switching to the next one. Anything less than 10s won’t reflect in the dashboard, only in the pop-up view, due to hass limitations with refreshing the main camera cards.
I did it that way on my first test run, but there isn’t necessarily a precedent for packaging in another file like that. I know the demo images are there, but they kinda serve a different purpose.
Since it is the cleaner solution i’ll probably give it a shot and can always switch back during the PR process if someone doesn’t like it.
Now I have the following error messages - all files are in the right folder and configuration.yaml adjusted!
2017-07-25 22:32:00 ERROR (MainThread) [homeassistant.setup] Error during setup of component usps
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", line 190, in _async_setup_component
component.setup, hass, processed_config)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/usps.py", line 43, in setup
conf = config[DOMAIN]
KeyError: 'usps'
2017-07-25 22:32:00 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.usps. Setup failed for dependencies: usps
2017-07-25 22:32:00 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.usps: Could not setup all dependencies.
Ok, lets figure out a few things… What version of HASS are you running and what version of python (looks like 3.4)? Did you have the usps component working before giving my changes a try?