Avi-on API Key

Hi, I tried the setup procedure described on the plugin and the method to fetch the API key is not working

curl -X POST -H "Content-Type: application/json" \
    -d '{"email": "[email protected]", "password": "password"}' \
    https://admin.avi-on.com/api/sessions | jq

Anyone successfully using this plugin and know how to get the API key?

I got my answer from the source of the python module, it seems the correct url for the command is https://api.avi-on.com/sessions, which would then make

curl -X POST -H "Content-Type: application/json" \
    -d '{"email": "[email protected]", "password": "password"}' \
    https://api.avi-on.com/sessions | jq

If someone is interrested in updating the module doc.

1 Like

The REST api no longer provides an API key. I have been able to reproduce the basic communication using bleak instead of bluepy, but that now is the main thing holding me back. AVI-ON has been making a lot of changes. I am not keen on the internet access bridge, as it seems to route all control operations via their website.

Has anyone recently been able to retrieve an API key? Will buying an access bridge return the API key?

I haven’t been able to see the API key even with the bridge. I can get back an auth token following the steps in this document (https://avi-on.com/wp-content/uploads/pdf/install-guides/Cloud-Public-API.pdf) but when I try to use that I get an error saying “unsupported version for this endpoint”.

To get the api key, you need to add a header to use the v2 version of the api, for example:

curl -X POST -H "Content-Type: application/json" -H 'Accept: application/vnd.avi-on.v2+json' \
    -d '{"email": "[email protected]", "password": "password"}' \
    https://api.avi-on.com/sessions | jq '.credentials.passphrase'

In my case it looked like a giant base64 encoded string (something like ZTNiMGM0NDI5OGZjMWMxNDlhZmJmNGM4OTk2ZmI5MjQyN2FlNDFlNDY0OWI5MzRjYTQ5NTk5MWI3ODUyYjg1NSAgLQo= but not that), which you use as is (you don’t decode it).

Using this, I was able to get my light to turn off using a toy script using the bleak library. Unfortunately, the encryption of commands is done using the csrmesh library, which currently also depends on bluepy (although it’s not used by the avion library itself).

See GitHub - oyvindkinsey/avionmqtt: MQTT/BLE bridge for Avi-on based lights for a fully working local solution for Avi-on based lights.

1 Like