[Request] Klevio Lock integration via API

Hy I've had a Klevio smart intercom installed which works great within its own App.

But was trying to see if I could tie it into the hub to add some smart functions to it, remote triggers etc.

They have an API available but its a bit beyond my technical level, but ultimately I just want to be able to send "open" commands to the device to open the locks.

The device instructions show connecting to the API as below:

Connecting to the API

Root address: https://api.klevio.com/sl/v1

Request format
a) HTTP Method: POST
b) HTTP Headers:
X-KeyID: [apiKeyId]
Content-Type: application/jwt | application/x-www-form-urlencoded
c) Request body:
Request body depends on the Content-Type HTTP header:

  • ā€application/jwtā€: [jwt]
  • ā€application/x-www-form-urlencodedā€: jwt=[jwt]

JWT format
a) JWT Header including the kid parameter (key algorithm should be ES256):
jwt_header = {
"alg": [key algorithm],
"typ": "JWT",
"kid": [apiKeyId]
}
b) JWT payload with an added rpc parameter that includes the JSON RPC 2.0 message (no
need for jsonrpc parameter):
rpc = {
// RPC request id; response will have the same id
"id": [rpc id],
// RPC method name
"method": [method name],
// RPC method parameters (object or list)
"params": [method params]
}
jwt_payload = {
// name of the issuer, characters allowed: 32 <= code <= 126
"iss": "[request issuer]",
// if a different audience is used => error
"aud": "klevio-api/v1",
// issued at time
"iat": [issued at],
// OPTIONAL; your id of the request token, used for debugging
"jti": [jwt token id],
// OPTIONAL; expiry; not more than 30s in the future
// DEFAULT: exp = iat + 5
"exp": [expires at],
// OPTIONAL; not before; if server time < nbf => error
// DEFAULT: nbf = iat
"nbf": [not before],
// JSON RPC message
"rpc": rpc
}

With the actual Open doors request:

req> {"id": 6, "method": "useKey", "params": {"key": "[keyId]"}}
res> {"id": 6, "result": true}

Does that make sense to anyone?

I am digging around on their site looking for their API information but have not had much luck. Where did you find this?

I corrected the typo you had in the title line also... Kelvio. :slight_smile:

Yeah I couldn't find the original on their site either their customer support sent me a copy via email.

Here's a link to the full file:
https://drive.google.com/file/d/1u5KtZs_-t9TWgvLaTjNvJycHe4hnZDeF/view?usp=sharing

I did find this section on their site though although I think its more about their general code base not the api

https://klevio.com/opensource/_/index.html

Yes, I stumbled across the opensource listings on their site. I will look over the API file your provided a bit first. I was just about to contact them earlier but thought I should ask you first.

Did you email them requesting an API Key? It does appear to ask for that, once you have set the public key in your account.

I may have to contact them anyway to see if they have a test system and a testAPI I could obtain, otherwise I would have to send you every single changed version to see if it works.

Not yet no, I'd originally emailed them about whether they had any existing connection points for smart hubs. But they mentioned the only working end point was the API.

Just to let you know I am still waiting for any type of response from Klevio. Sorry I cannot help at this time until they come back with something.

Thank you, I've been away myself so haven't been able to look into it either. But going to have a play around and see if I can find anything useful