axis icon indicating copy to clipboard operation
axis copied to clipboard

Add door control API

Open drewclauson opened this issue 4 years ago • 18 comments

Opening up PR to have a place to discuss adding in these capabilities.

  • [x] Add API requests for basic door operations
  • [x] Add Tests
  • [ ] Any further integration to work with HA
  • [ ] Squash commits?
  • [x] Rebase after #85 is merged.
  • [x] Add event support
  • [ ] More event tests

drewclauson avatar Jun 03 '21 13:06 drewclauson

Awesome! I'll have a look during the weekend

Kane610 avatar Jun 04 '21 18:06 Kane610

Don't forget to look at events for door state changes so we get that warm fuzzy feeling of push notifications :)

Yes, thanks for the reminder. I just discovered how this works through ONVIF, but need to head to bed for tonight. That part will be a bit easier than I originally thought. At first glance (and I'm new to ONVIF), but looks like adding some notification filters / topics.

drewclauson avatar Jun 08 '21 03:06 drewclauson

Don't forget to look at events for door state changes so we get that warm fuzzy feeling of push notifications :)

Yes, thanks for the reminder. I just discovered how this works through ONVIF, but need to head to bed for tonight. That part will be a bit easier than I originally thought. At first glance (and I'm new to ONVIF), but looks like adding some notification filters / topics.

Hopefully it's as easy as extending https://github.com/Kane610/axis/blob/master/axis/event_stream.py with a new class

Kane610 avatar Jun 08 '21 06:06 Kane610

Don't forget to look at events for door state changes so we get that warm fuzzy feeling of push notifications :)

Yes, thanks for the reminder. I just discovered how this works through ONVIF, but need to head to bed for tonight. That part will be a bit easier than I originally thought. At first glance (and I'm new to ONVIF), but looks like adding some notification filters / topics.

Hopefully it's as easy as extending https://github.com/Kane610/axis/blob/master/axis/event_stream.py with a new class

I think this is the case and I've added the right topics, but when I run __main__ and watch the events come in as I trigger actions manually on the device, I'm not seeing anything related to the topics I added. Should the debug output log out all events that come in from the device or just ones that are in set up event_stream.py? Do you have any other tools that you use to capture events from a device for troubleshooting or anything like that?

drewclauson avatar Jun 08 '21 18:06 drewclauson

I think this is the case and I've added the right topics, but when I run __main__ and watch the events come in as I trigger actions manually on the device, I'm not seeing anything related to the topics I added. Should the debug output log out all events that come in from the device or just ones that are in set up event_stream.py? Do you have any other tools that you use to capture events from a device for troubleshooting or anything like that?

I don't remember 😂 .

Have you enabled events with main? https://github.com/Kane610/axis/blob/17051d191f2b3dab6e993d6e71b45621595913f6/axis/main.py#L92 This one should print all events https://github.com/Kane610/axis/blob/17051d191f2b3dab6e993d6e71b45621595913f6/axis/main.py#L17

You can put a print here to debug https://github.com/Kane610/axis/blob/17051d191f2b3dab6e993d6e71b45621595913f6/axis/streammanager.py#L67

Kane610 avatar Jun 08 '21 19:06 Kane610

I think this is the case and I've added the right topics, but when I run __main__ and watch the events come in as I trigger actions manually on the device, I'm not seeing anything related to the topics I added. Should the debug output log out all events that come in from the device or just ones that are in set up event_stream.py? Do you have any other tools that you use to capture events from a device for troubleshooting or anything like that?

I don't remember 😂 .

Have you enabled events with main?

https://github.com/Kane610/axis/blob/17051d191f2b3dab6e993d6e71b45621595913f6/axis/main.py#L92

This one should print all events

https://github.com/Kane610/axis/blob/17051d191f2b3dab6e993d6e71b45621595913f6/axis/main.py#L17

You can put a print here to debug

https://github.com/Kane610/axis/blob/17051d191f2b3dab6e993d6e71b45621595913f6/axis/streammanager.py#L67

LOL and yes, I have --events enabled. I'm wondering if the device isn't sending all the events and I'm missing a configuration requirement for RSTP/ONVIF on the device. I'll keep digging. :-)

drewclauson avatar Jun 08 '21 19:06 drewclauson

LOL and yes, I have --events enabled. I'm wondering if the device isn't sending all the events and I'm missing a configuration requirement for RSTP/ONVIF on the device. I'll keep digging. :-)

AFAIK it should support metadata events

Kane610 avatar Jun 08 '21 19:06 Kane610

I think I have events all configured, just need to add tests. Also, I did finally figure out how to get the events to log out when running with --events. I suspect it was actually a firewall issue as I was accessing my door controller through a firewall. Still more work to do, but I'm figuring some things out.

Remind me - I can't find the comment you previously made - is this the right spot to load/configure/include/not-sure-the-right-word the door_control.py stuff?

https://github.com/drewclauson/axis/blob/fed1fdfd71815f42299a95aaa78088d253209103/axis/vapix.py#L144

Or do I need to include something like how the light_control does it?

https://github.com/drewclauson/axis/blob/fed1fdfd71815f42299a95aaa78088d253209103/axis/vapix.py#L184

drewclauson avatar Jun 09 '21 20:06 drewclauson

Remind me - I can't find the comment you previously made - is this the right spot to load/configure/include/not-sure-the-right-word the door_control.py stuff?

https://github.com/drewclauson/axis/blob/fed1fdfd71815f42299a95aaa78088d253209103/axis/vapix.py#L144

Or do I need to include something like how the light_control does it?

https://github.com/drewclauson/axis/blob/fed1fdfd71815f42299a95aaa78088d253209103/axis/vapix.py#L184

It depends ;)

If the oldest device available (A1001 in this case) supports API discovery in its latest release, then it is fine to keep it to just be API discovery. But if the A1001 has a too old firmware to work with API discovery then you need to support the older mechanism to identify if it is supported or not. Hope that is clear

Kane610 avatar Jun 09 '21 21:06 Kane610

Hey! Press the re-request review button when you want my attention.

Kane610 avatar Jun 15 '21 17:06 Kane610

Hey @drewclauson, everything ok?

Kane610 avatar Jun 21 '21 18:06 Kane610

Yep, just ran into a home project that has eaten ALL of my time lately.  Should have more done next week! On Jun 21, 2021, 2:37 PM -0400, Robert Svensson @.***>, wrote:

Hey @drewclauson, everything ok? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

drewclauson avatar Jun 21 '21 19:06 drewclauson

Take your time! I will go on vacation next week so might be a bit less active at times

Kane610 avatar Jun 21 '21 19:06 Kane610

I'll be coming back to this soon - had a death in the family that made things very busy for a month.

drewclauson avatar Jul 21 '21 13:07 drewclauson

I'll be coming back to this soon - had a death in the family that made things very busy for a month.

My condolences.

I appreciate the status update but don't feel rushed that I'm expecting preogress. I have a couple of bug reports that I will try to solve before going back to working on Axis integration.

Kane610 avatar Jul 23 '21 19:07 Kane610

@Kane610 - I came back to this and fixed the failing flake8 statement. I think this encapsulates the functionality that I think would be beneficial for an A1001 door controller integration, but there might be other API calls that could be helpful. The majority of the Axis door controller API has to do with configuring the controller and I focused on the ones that are more about the day to day operation of the door (lock/unlock/access/etc). My specific use case is just to be able to have a button in HA that will let me click it to open it temporarily, but I tried to go much further outside that into the other API operations.

Let me know what you think! I'm finally back at a place where I can put a bit more time into it.... If I can get past the flake8 guardian 😂

drewclauson avatar Jul 31 '21 18:07 drewclauson

I'll have a look during the next week. I think regardless of what additional apis to support to keep the PR to one api.

What I think would be interesting is card reader / access panel support. Possibly user support.

Kane610 avatar Aug 05 '21 07:08 Kane610

Hey @drewclauson everything ok?

Kane610 avatar Sep 20 '21 19:09 Kane610