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?