Giter Club home page Giter Club logo

Comments (19)

Kane610 avatar Kane610 commented on June 24, 2024 1

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.

from axis.

Kane610 avatar Kane610 commented on June 24, 2024 1

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

from axis.

Kane610 avatar Kane610 commented on June 24, 2024 1

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

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

from axis.

Kane610 avatar Kane610 commented on June 24, 2024

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.

from axis.

robby-dermody avatar robby-dermody commented on June 24, 2024

Sounds good, thank you!

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

@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!

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

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

from axis.

Kane610 avatar Kane610 commented on June 24, 2024

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

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

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.

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

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?

from axis.

Kane610 avatar Kane610 commented on June 24, 2024

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.

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

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)

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

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

from axis.

Kane610 avatar Kane610 commented on June 24, 2024

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)

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

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

from axis.

Kane610 avatar Kane610 commented on June 24, 2024

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"

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

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.

from axis.

Kane610 avatar Kane610 commented on June 24, 2024

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

from axis.

drewclauson avatar drewclauson commented on June 24, 2024

Published #90

from axis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.