Axis camera component

yup that solved it, i did the upgrade however looking at the axis camera motion detection i can see motion detected in the motion detection graph but the off / on on the binary_sensor for the camera does not change, i have seen it change few times but very rare compared to what i see on the graph, any reason for that ?

Great @donnib! Have you set the trigger_time to anything other than 0?

I tried trigger_time = 1 then the value is stuck to on and even if i lower the sensibility on motion detection so no motion is detected anymore the value keeps on staying on.

UPDATE: never mind, it works fine but i didn’t do save on the camera while i was playing with the motion detection settings so even though i could see lower activity the settings were not taken into account towards HA

1 Like

Great that you got it going. Not so great that it’s so hard to get going…

I’m interested in feedback for more features to integrate.

So today i upgaded HASS and had to go thru the hassle of installing all dependencies, making the link and do the copy of gi and then again i ran into the same problem as last time were HASS hangs with the 10 sec that it takes more to load axis component. I then removed as much as i could from the config then i got this :

2017-06-29 10:31:12 INFO (MainThread) [homeassistant.loader] Loaded camera from homeassistant.components.camera
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.setup] Setting up camera
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.setup] Setup of domain camera took 0.0 seconds.
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=camera>
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.camera, platform=axis, discovered=name=Skur, host=x.x.x.x, username=xxxx, password=xxxx, trigger_time=1, include=['camera', 'motion'], location=, hass=<homeassistant.core.HomeAssistant object at 0x7faa226caa58>>
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.loader] Loaded camera.axis from homeassistant.components.camera.axis
2017-06-29 10:31:12 ERROR (MainThread) [homeassistant.setup] Error during setup of component axis
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 190, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/axis.py", line 162, in setup
    if not setup_device(hass, config):
  File "/usr/src/app/homeassistant/components/axis.py", line 193, in setup_device
    device.initiate_metadatastream()
  File "/usr/local/lib/python3.6/site-packages/axis/__init__.py", line 110, in initiate_metadatastream
    self._metadatastream = MetaDataStream(self.metadata_url)
  File "/usr/local/lib/python3.6/site-packages/axis/stream.py", line 35, in __init__
    self.set_up_stream()
  File "/usr/local/lib/python3.6/site-packages/axis/stream.py", line 40, in set_up_stream
    self._stream = Gst.parse_launch(self.pipeline_string)
GLib.GError: gst_parse_error: no element "rtspsrc" (1)
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:
* [axis](https://home-assistant.io/components/axis/)
Please check your config, notification_id=invalid_config, service_call_id=140368650289448-2>
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.invalid_config, old_state=None, new_state=<state persistent_notification.invalid_config=The following components and platforms could not be set up:
* [axis](https://home-assistant.io/components/axis/)
Please check your config; title=Invalid config @ 2017-06-29T12:31:12.917102+02:00>>
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140368650289448-2>
2017-06-29 10:31:12 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of camera.axis. Setup failed for dependencies: axis
2017-06-29 10:31:12 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform camera.axis: Could not setup all dependencies.
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:
* [axis](https://home-assistant.io/components/axis/)
* camera.axis
Please check your config, notification_id=invalid_config, service_call_id=140368650289448-3>
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.invalid_config, old_state=<state persistent_notification.invalid_config=The following components and platforms could not be set up:
* [axis](https://home-assistant.io/components/axis/)
Please check your config; title=Invalid config @ 2017-06-29T12:31:12.917102+02:00>, new_state=<state persistent_notification.invalid_config=The following components and platforms could not be set up:
* [axis](https://home-assistant.io/components/axis/)
* camera.axis
Please check your config; title=Invalid config @ 2017-06-29T12:31:12.926197+02:00>>
2017-06-29 10:31:12 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140368650289448-3>

Now i am stuck and i don’t know how to get it running again, any ideas ?

There is a discrepancy between the Axis component doc and what is here in this post what needs to be installed :

sudo apt-get install python3-gst-1.0 gir1.2-gstreamer-1.0 gir1.2-gst-plugins-base-1.0 gstreamer1.0-plugins-good
gstreamer1.0-plugins-ugly gstreamer1.0-tools python3-gi

vs

sudo apt-get install python3-gi gir1.2-gstreamer-1.0

Is there a reason for that ? The other packages are included now in HASS or ?

I tried to install all of them and my problem since to have dissapeared but i am not sure that’s why since last time the problem was solved i was also in doubt what made it work suddenly.

1 Like

Hi @donnib! Great that you got this working, thanks for bringing this to my attention. I thought I’d minimised the dependency list to the required parts, apparently I missed at least one. I will have to do this on a clean system to verify what exactly is needed. Since it is the rtspsrc it complains about I’d take a guess that it’s the gstreamer1.0-plugins-good that was needed. These packages will probably never be a part of hass so users of this component will always have to go through this hassle once…

In next release of hass I’ve done some improvements on dependencies so if you only use the camera part of the Axis component you wouldn’t have any dependency issues.

/R

I just rebuilt my HASS instance using docker and I got it to work. I originally tried allowing docker access to the native hotst’s GI instance, but that didnt work at all - so I basically entered the docker host and installed it. Went something like

  1. Enter docker host sudo docker exec -it home-assistant bash
  2. apt-get all the needed packages
  3. copy _gi.cpython-34m-arm-linux-gnueabihf.so to _gi.cpython-36m-arm-linux-gnueabihf.so. This is because the docker container was running python 3.6
  4. Create the required symlink

Edit: I am new to docker, so maybe this wasnt the best way. No clue

DONE!

2 Likes

Great work!

Is there a way to get a higher refresh rate on the images from the camera ?

No sorry that is all part of the home assistant backend. If you click it full screen you get a better refresh rate

Hi!
I noticed that my Logbook was emptyand after hours of testing i found that if i removed my axis in the config file the logbook started to work again.
In the log files i get tons off errors when the cameras is activated. Anyone with the same problem?
Jul 10 22:41:02 hassbian hass[779]: requests.packages.urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’
Jul 10 22:41:02 hassbian hass[779]: 2017-07-10 22:41:02 WARNING (Thread-12) [requests.packages.urllib3.connectionpool] Failed to parse headers (url=http://192.168.1.21:80/axis-cgi/mjpg/video.cgi): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’

axis:
m3046:
host: 192.168.1.20
username: *********
password: *********
include:
- camera
- vmd3
trigger_time: 0
location: vard

m3047:
host: 192.168.1.21
username: *********
password: *********
include:
- camera
- vmd3
trigger_time: 0
location: kok

Hi @zidnuss!

Unfortunately, I can not do much here, since the axis component only wraps the mjpeg camera component which has this as a known issue…

You can try to add this to your configure
logger:
default: info
logs:
requests.packages.urllib3.connectionpool: critical

Else you might need to look in to the ffmpeg camera.

have the same problem with the new amcrest component in 0.49 - logfile was empty since upgrade. Commenting out the amcrest component allowed creating logbook entries again. The error for the recorder is

> > ERROR (Recorder [homeassistant.components.recorder.util] Error executing query: <AMCREST_SN" AMC_SN> is not JSON serializable

Ok. So there might be backend changes from the core team resulting in this behavior. That is good information for debugging this issue! Thanks!

Also, there is a issue for this on hass github.

/R

@Robban i am pulling my hair out here with :

2017-07-24 20:12:41 WARNING (MainThread) [homeassistant.setup] Setup of axis is taking over 10 seconds.

I got the component to work before but everytime i make an upgrade i ran into problems, i’ve done what i used to in the docker image as we agreed and still it hangs with this, anyway to debug and know more ?

Before this i see :

2017-07-24 20:27:38 INFO (MainThread) [homeassistant.loader] Loaded axis from homeassistant.components.axis

2017-07-24 20:27:39 INFO (MainThread) [homeassistant.setup] Setting up axis

2017-07-24 20:27:40 INFO (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.camera, platform=axis, discovered=name=Skur, host=xx, username=xx, password=xx, trigger_time=1, include=[‘camera’, ‘motion’], location=, hass=<homeassistant.core.HomeAssistant object at 0x7f19e7f379e8>>

2017-07-24 20:27:41 INFO (MainThread) [homeassistant.loader] Loaded camera.axis from homeassistant.components.camera.axis

UPDATE: So was playing around like i did last couple of times and suddenly it started to work, what i did last thing was to add :

homeassistant.components.camera: info

to the logger config and then restarted the docker instance, VERY weird. Every time i get a suprise.

Hi @donnib!

I will be back from vacation next week and will start look into the reported issues with Axis component within a week or so.

Saw your updated post. Would you mind posting a bit more detailed logs with and without that extra info setting? I might need to talk to balloob about that possibly weird behavior.

/R

Here is another issue, i keep seeing these in the log :

2017-08-02 10:12:46 ERROR (SyncWorker_12) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/axis.py", line 172, in axis_device_discovered
    request_configuration(hass, name, host, serialnumber)
  File "/usr/src/app/homeassistant/components/axis.py", line 137, in request_configuration
    'type': 'number'},
TypeError: request_config() got multiple values for argument 'description'

That’s weird, because description should never change. First! Have you added your devices to hass through the product configuration box on the frontend, or do you have devices not registered to hass? Because that code should only run if an Axis device is discovered that is not configured through configuration.yaml.

Regarding system dependencies Im planning on replacing gstreamer with something else that is python native in order to reduce complexity in getting the Axis component to work.

There is one device that it detects that’s an old Axis camera i can’t add because it’s not supported by the component so i can’t do anything about it or can i ?