robmarkcole / pan-tilt-hat-HASS

Custom component adding the pimoroni pan-tilt-hat to Home-assistant: tested in HA 0.94 ok
7 stars 0 forks source link

raspistill not found and errors setting up platform #1

Open dfranssen opened 6 years ago

dfranssen commented 6 years ago

Hi,

I tried this addon, but I get following errors in http://hassio.local:8123/dev-info:

2017-09-03 21:35:26 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=4 from 2017-09-03 19:27:53.304554) 2017-09-03 21:35:28 ERROR (SyncWorker_13) [homeassistant.components.camera.rpi_camera] 'raspistill' was not found 2017-09-03 21:35:36 WARNING (MainThread) [homeassistant.setup] Setup of sensor is taking over 10 seconds. 2017-09-03 21:35:39 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform pan_tilt_phat Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform SLOW_SETUP_MAX_WAIT, loop=self.hass.loop) File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for return fut.result() File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result raise self._exception File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/sensor/pan_tilt_phat.py", line 46, in setup_platform add_devices([PanTiltPhat(pantilthat)], True) File "/config/custom_components/sensor/pan_tilt_phat.py", line 60, in __init__ self._pan = self._pantilthat.get_pan() File "/config/deps/lib/python3.6/site-packages/pantilthat/pantilt.py", line 415, in get_servo_one return self._servo_us_to_degrees(us, us_min, us_max) File "/config/deps/lib/python3.6/site-packages/pantilthat/pantilt.py", line 131, in _servo_us_to_degrees self._check_range(us, us_min, us_max) File "/config/deps/lib/python3.6/site-packages/pantilthat/pantilt.py", line 120, in _check_range max=value_max)) ValueError: Value 51200 should be between 575 and 2325

robmarkcole commented 6 years ago

There is an open issue for the camera not found on the Hassio repo. I haven't tested the hat on Hassio, only on a pi running rasbian. I understand there is more work to get some components working with Hassio but I don't have experience in that aspect unfortunately

dfranssen commented 6 years ago

Hi @robmarkcole,

thanks for the quick answer! I added the symlinks manually for the missing raspistill (https://github.com/home-assistant/hassio-build/pull/26/commits/240a038ae63c24cc248dc0e67bce7ad295a4eaa8), but unfortunately the destination files /opt/vc/... don't exist in the hassio distro :-(

Are the other errors (Value 51200 should be between 575 and 2325) of any importance?

Cheers, Dirk

robmarkcole commented 6 years ago

How did you get that error? If I pass an out of range angle I don't get any response or error. Cheers

dfranssen commented 6 years ago

I think by playing with the pan/tilt sliders (min/max) in HASS

robmarkcole commented 6 years ago

I tested over the whole range and don't see those errors, not sure what to suggest..

dfranssen commented 6 years ago

It seems the hass.io is not working out of the box, so I switched over to Raspbian Stretch Lite. But now it seems to be "stuck" on Setting up sensor.pan_tilt_phat. Any ideas?

2017-09-03 22:35:25 INFO (MainThread) [homeassistant.setup] Setup of domain automation took 0.1 seconds. 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=automation> 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.setup] Setting up updater 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.setup] Setup of domain updater took 0.0 seconds. 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=updater> 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.setup] Setting up conversation 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=conversation, service=process> 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.setup] Setup of domain conversation took 0.0 seconds. 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=conversation> 2017-09-03 22:35:25 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.pan_tilt_phat

robmarkcole commented 6 years ago

My guess is that the pantiltphat module which is a dependency has not yet been updated to support Stretch and/or python 3.5. I'm on Jessie version 8 and python 3.4.2. Could you check with that OS? I will also check against Stretch

robmarkcole commented 6 years ago

OK seeing the same issue with Stretch and have raised an issue: https://github.com/pimoroni/pantilt-hat/issues/12

robmarkcole commented 6 years ago

I also get errors installing other modules under Stretch, including phue as used by the Hue component

dfranssen commented 6 years ago

thanks for also trying out Stretch and logging the issue at pimoroni.

I flashed a Jessie Lite (performed an apt-get upgrade, perhaps I shouldn't have?), but it seems that it is still stuck at 2017-09-04 21:13:41 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.pan_tilt_phat. Do I need to install something manually?

uname -a Linux hassio 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

python3 --version Python 3.4.2

robmarkcole commented 6 years ago

No it should install. I suggest trying an older version of the OS for the time being

http://downloads.raspberrypi.org/raspbian/images/

dfranssen commented 6 years ago

I kept the newer OS, but got a clue when running hass as root the logs stated that python3-smbus was missing. This warning was not shown when running with the pi user. After install, I get a raspberry pi video stream visible, but the pan/tilt doesn't work. I see following error in the logs 2017-09-05 18:32:46 WARNING (MainThread) [homeassistant.core] Unable to find service pan_tilt_phat/tilt. Although in the /var/opt/homeassistant/deps/lib/python3.4/site-packages folder following dependencies are available:

Any ideas?

robmarkcole commented 6 years ago

I believe the smbus module is related to i2C communication which was raised in the earlier error. Can you try manual install of python3-smbus as root and see if the pan-tilt functions?

http://www.linuxcircle.com/2015/05/03/how-to-install-smbus-i2c-module-for-python-3/

sudo apt-get update
sudo apt-get install python3-smbus
dfranssen commented 6 years ago

I had the module already installed but had to enable I2C via raspi-config :-)

Now it is up and running. Is it possible to have a live videostream? Pan/tilt is immediately responding to changes, but the "picture" changes only after 5+ seconds

robmarkcole commented 6 years ago

Are you saying that you did sudo apt-get install python3-smbus ? I'm unable to get the pan-tilt working so please could you list all the steps you took? Cheers

The hass front-end only shows a still from the video capture, if you click on the still a pop-up will show with the video feed. I hope they update the front end to show the video feed

dfranssen commented 6 years ago

Hi,

indeed, before the install of sudo apt-get install python3-smbus it hung at Setting up sensor.pan_tilt_phat. Afterwards I got Unable to find service pan_tilt_phat/tilt and this was due to I2C that was not enabled via raspi-config.

So the steps I took:

It is a pity that it is a still image, even with the popup open there is a huge lag which makes it kind of useless :-( I was hoping for something to pan/tilt (with arrow keys or something) on the fly with a live videofeed at 30 fps...

robmarkcole commented 6 years ago

That is possible with https://github.com/waveform80/pistreaming/tree/pantilthat and an ipanel.

Agree faster update on the front end would be much more useful as it stands. Might be possible to trigger faster refresh by triggering captures at a rapid rate.

My idea with this component was to allow automations to point the camera in a particular direction and perform object tracking