Axis camera component

@Robban can you give me a hint, please?

Sorry, I run it completely local on my laptop when developing

I thought you asked about how to use the environment but maybe you meant more in line with where to start looking at development? You have to be more explicit with what you’re asking :slight_smile:

Sorry, I’m actually asking for both things :wink: And I think I started too ambitious, since I have no experience in HASS. I actually installed Docker in a ProxMox server and VS Code points already to the CORE Dev Container: Home Assistant Dev, as shown in the picture. I don’t know how to test if it works. For example, trying to run the Hello World program, or someting similar ? Many thanks!

There is no hello world program, you start home assistant :slight_smile: , I don’t really use the dev containers as it was complicated to get working when developing libraries and integrations in tandem. You do get the benefit of not needing to care about environment (which dependencies breaks for me sometimes). Have you checked the dev docs?

Just a little bit, I will have a closer look… It would be nice to provide a small program with the first installation just to check the environment…

@Robban I think it works! The following is thwe configuration in VS Code:

And this image is HASS working in the browser in the localhost:

What I did was just to click in the upper left arrow in the “Run and Debug” tab:

So it seems working! Now, do you think it would be possible to install your AXIS project? How would I do this? Many thanks!

@Robban do you think it would be possible to get your Axis integration to start working from there? Many thanks!

Sorry. Forgot to reply. Yes. It’s already bundled. It’s just to set up as usual

@Robban Could you please give me some instructions about how to load it? I have no experience at all on how to setup a project, sorry. Is it an integration or an add-on? Many thanks!

It’s all in the code base already. Running the dev version of home assistant you can set up the Axis integration using the interface and then you can traverse the hass code base homeassistant/components/axis to see the integration code

@Robban I tnik I’m getting there little by little… Could you give me a hint about where to look to add PTZ commands? What files shall I look for? Sorry for my lack of knowledge… Many thanks!

The following picture shows the scroll of the Axis integration in VS Code, I guess, right?

That’s correct! I did a quick search on PTZ in the home assistant code base and one good inspiration would be the amcrest integration.

@Robban I found the amcrest integration and I guess the camera.py is the file to change, right? There might be others? To me the structure looks a little different and I’m not sure whether I will know how to change the axis integration, unfortunately?.. I know very well how to use the gotoposition (for the presets), zoom and PTZ commands, but it looks quite challenging to include them in your axis project… I’m not sure where to learn the syntax and the procedures?..

PTZ controls are already implemented in the Axis python library axis/ptz.py at a12a89b461b16f145ff3f9459a4430c0ef4a86cc · Kane610/axis · GitHub.

Within the AxisCamera class you have a property self.device which in turn has an api property.
That property is the Axis python library (axis/device.py at a12a89b461b16f145ff3f9459a4430c0ef4a86cc · Kane610/axis · GitHub) which manages the communication and abstraction of the physical device.

You can reach PTZ controls through self.device.api.vapix.ptz.control(...)
Which you can utilize in a method similar to Amcrest integrationasync_ptz_control

You need to tie a service call registered in home assistant with a method in the camera class which does PTZ control and sends data from the service call into the Axis python library

More or less :slight_smile:

@Robban You make it sound simple, but unfortunately I don’t know how to proceed. I have no experience with Home Assistant, I’m so sorry.
There is another point, it would be nice to be able to choose the stream, instead of using h264, which is slow, using mjpeg…
Many thanks!

1 Like

No worries! It was a good exercise for myself on how it could be done today :slight_smile: , just tell me if you want to proceed.

Please open a GitHub issue here as I might loose track of it if its only posted in the forums.

It would be great to use mjpeg yes! The response of the cameras is almost instantaneous! I can help you however you want, you will just need to drive me, since I have no experience…

The following is the code for the stream:

baseUrl = 'http://' + plugin.Settings["Username"] + ':' + plugin.Settings["Password"] + '@' + plugin.Settings["HostName"] + port + '/axis-cgi';
axisDevice.Stream = baseUrl + '/mjpg/video.cgi';

@Robban So how can we proceed? You know much better than myself what we need to do, I can only offer “to be your hands”, I can write the program, but you need to give me some instructions… :wink:

If I have to spell out every exact step then its better I do it myself, which would happen at some point in the future :slight_smile: . For this to work you need to invest time in trying to solve it and I can help you out as you proceed.

I have already described the basic principles about what is needed to be done with references to other code examples, now you have to play around a bit to understand it and I will be here when you get stuck.