Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Access control? #43

Open
robby-d opened this issue Sep 5, 2020 · 22 comments
Open

Support for Access control? #43

robby-d opened this issue Sep 5, 2020 · 22 comments

Comments

@robby-d
Copy link

robby-d commented Sep 5, 2020

Hi, just found this library. I have a A1001 door controller and tested the current state of the HomeAssistant integration. It appears that I can get a few states off of it, but no lock control (e.g. as switch entities) came across. It would be wonderful to be able to both discover and control the door lock state(s) for configured doors (as well as doors configured on additional connected/linked door controllers). Is this a planned feature? If not, I can look into adding it once I have some spare time.

(I also connected to an A8207VE MkII keypad/cam device, which was integrated via VAPIX to the aforementioned door controller -- I can see more information, including PIR state, camera feed and door status, however, I cannot operate the door lock through that as well. Being able to operate the door directly through a connection to the door controller(s) themselves would be optimal.)

@Kane610
Copy link
Owner

Kane610 commented Sep 5, 2020

Hi @robby-dermody! I do have plans to add support for this, but I can not promise when that would be. Feel free to open PRs to support these devices functionality.

@robby-d
Copy link
Author

robby-d commented Sep 5, 2020

Sounds good, thank you!

@robby-d robby-d closed this as completed Sep 5, 2020
@drewclauson
Copy link

@Kane610 - Didn't want to open up a new issue, so I'm commenting here. I've been reading through your code and am interested in doing some work and submitting a PR to support A1001, but I'm newer to Python (I'm a .NET turned Java guy) and haven't been able to find good tutorials/documentation related to VAPIX. Do you have any recommended resources on VAPIX or guidance on where to start that would let me create a CLI app that uses this library as a dependency so I can get started to add in lock controls and door lock states? I've gotten as a far as installing PyCharm as I'm a JetBrains fanatic.

Thanks!

@Kane610
Copy link
Owner

Kane610 commented May 14, 2021

Hey!

Awesome! When I'm adding a new API I usually augment the main function so I can just run everything from the commandline directly, ideally the main function would be a bit more advanced to offer some more CLI friendly controls.

Regarding documentation you have the official API documentation here https://www.axis.com/vapix-library/subjects/t10067552/section/t10068742/display

But in my experience you really need a device to try it out with, that also helps adding tests to improve iterating on it once you've got the basics implemented. Make sure to base your implementation on the latest firmware available, the API documentation typically only reflects the latest released version of the API.

I just wrapped up keypad support for the deCONZ integration a couple of weeks back so I'm also eager to get something similar running with the Axis integration.

Right now I'm finishing up my libraries to make sure dependencies and CI tools are helping out with verification and will also add proper typing before I go back to adding additional functionality.

Don't hesitate to ping me, we can also iterate quicker over discord should you prefer.

Reopening this issue in the mean time.

@Kane610 Kane610 reopened this May 14, 2021
@drewclauson
Copy link

Thanks! I have access to two A1001s and I'm hoping to spend some time looking into it this weekend.

@Kane610
Copy link
Owner

Kane610 commented May 14, 2021

Awesome! I will look into the different access control APIs as well

@drewclauson
Copy link

So, I've got the code connecting to my A1001 and -D is showing me params, but I'm getting a 404 when it tries to

POST http://<mydeviceip>/axis-cgi/apidiscovery.cgi

I haven't gotten too far, but I'm guessing that's a pretty integral part of the process, being able to discover what APIs are supported? It doesn't seem to exist when looking through the device's cgi scripts, but I can get params.cgi.

@Kane610
Copy link
Owner

Kane610 commented May 19, 2021

404s are expected to exist when talking to different devices with different feature sets. Older devices don't support API Discovery so its completely fine.

ERRORS = {401: Unauthorized, 404: PathNotFound, 405: MethodNotAllowed}

except PathNotFound: # Device doesn't support API discovery

@drewclauson
Copy link

Great, thanks. I've been able to do some figuring out of how to perform actions through VAPIX to get the basics of what I'm after (unlocking a door via button and getting door lock/unlock status). There's more than that available, but I at least have a good idea on how to make the right requests via Postman. Just need to figure out how to bring those actions into this code.

I see how you're capturing events through VAPIX. I don't see anything where the library issues actions through VAPIX. Does that sound accurate?

@Kane610
Copy link
Owner

Kane610 commented May 19, 2021

Awesome! Exciting to see what you come up with!

There are loads of examples controlling different parts of the device through Vapix

Enable MQTT service in device

async def activate(self) -> None:

Activate a specific light

async def activate_light(self, light_id: str) -> None:

Set state of port (new API)

async def set_state(self, set_port: SetPort) -> None:

Set state of port (old API)

async def action(self, action: str) -> None:

I'm up for general suggestions on how to improve the library as a whole. I'm trying to reflect changes in a way so my libraries for both deCONZ and UniFi are similar. I've done a lot of refactorings and improvements over the year where I've learned something with one of the libraries and then try to reflect the same changes in the other ones.

@drewclauson
Copy link

Thanks - sorry to be the newbie on this code, but it's my foray into a real Python library. 🤦‍♂️

I only thought that it wasn't using VAPIX because this URL was calling a cgi script where the A1001 would be calling /vapix/doorcontrol I'll have more time later this week to look through it more.

URL = "/axis-cgi/lightcontrol.cgi"

I'm not the best person from an architecture perspective, but I'll make any suggestions if I come up with some. (I've been working as a DBA for the past 3 years, which has left a bunch of coding experience more stagnant than I'd like)

@Kane610
Copy link
Owner

Kane610 commented May 19, 2021

No worries, I'm excited to have you just experimenting :)

Everything is Vapix, it's the branding of the APIs of Axis devices.

@drewclauson
Copy link

I made some progress on putting together the basics for defining API calls that I think will be useful and also associated tests.

If you have a minute, take a look at progress so far, I'm not sure of exact next steps, but I think I need to understand how to help HA discover the available services.

master...drewclauson:add-door-control

@Kane610
Copy link
Owner

Kane610 commented May 28, 2021

Hey! Looked at it and the documentation a bit, overall it looks good! Awesome job!

I do have comments, but nothing major.
E.g. door_control in param_cgi.py is superfluous since you have the api discovery mechanism stated, so one can always look in api discovery or check if door_control is None to see if it is supported.
Big groups of properties inside of a dict (device and door capabilities) should probably be clarified with global strings to avoid manually specifying keys in home assistant or other places the library is used.

I'm contemplating if this should be put under a /access_control folder similar to applications

Once I'm finished with the typing PR you will need to rebase and follow the additional tests performed (nothing major)

@drewclauson
Copy link

E.g. door_control in param_cgi.py is superfluous since you have the api discovery mechanism stated, so one can always look in api discovery or check if door_control is None to see if it is supported.

Thanks, I wasn't quite clear on that, but decided to mimic stuff that I was seeing in light_control.

Big groups of properties inside of a dict (device and door capabilities) should probably be clarified with global strings to avoid manually specifying keys in home assistant or other places the library is used.

Definitely had that in the back of my head and will do that. Would that look something like below on the door class for each capability that we want to be able to use?

image

@Kane610
Copy link
Owner

Kane610 commented May 28, 2021

Definitely had that in the back of my head and will do that. Would that look something like below on the door class for each capability that we want to be able to use?

I'm not sure, haven't had many capabilities like this before. What do you think?

It would either be class methods like you post or globals like

MOVE_RIGHT = "right"

@drewclauson
Copy link

Oh I see what you mean. I like the globals better, I'll work on that. Although there are a lot of capabilities, there's only a select few that will likely be useful for users. "Access" is probably the most used one, in order to allow a user to just unlock the door temporarily. That's actually the only one that I can think of currently that I need for my use case, but thought it good to just build the other ones out as other people might want them in the future.

@Kane610
Copy link
Owner

Kane610 commented May 28, 2021

Feel free to publish your PR, it might be better to contain this discussion to that rather than in this issue

@drewclauson
Copy link

Published #90

@darkdecoy
Copy link

I'm wondering what would be the best path forward in trying to get support added for the Axis A1001? I have access to one for testing and have done some programming in python.

@Kane610
Copy link
Owner

Kane610 commented Mar 26, 2024

I'm wondering what would be the best path forward in trying to get support added for the Axis A1001? I have access to one for testing and have done some programming in python.

I want to do this some time in the future as Drew couldn't complete it. But right now I'm focused on other things than access control. So if you can adapt Drew's or to work with latest version of the library world be a good start. If you have the patience I will help you move forward

@drewclauson
Copy link

Hi - my apologies! - yes I totally lost track of this due to life circumstances and ended up directly using a command line integration in HA and curl command to accomplish what I needed. I was also pretty new to Python at the time. I’d offer to pick it back up, but I have little time for side projects right now. All my progress should be clear in my PR, I didn’t have any modifications that I didn’t push to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants