Ezlo Linux firmware - HTTP documentation preview

Well, at least you know that it works over https and the json payload confirmed that you have enabled insecure local access.

I think you have to use https but since you enabled anonymous acces you don’t need to use an auth token. You won’t get any feedback in a browser, just a blank page or in some cases “the page can’t be reached” but if you have the MiOS app open you can see that the scene runs instantly when called from a browser with https. Quite impressive that the app is updating live!

1 Like

that’s because they’re using websockets. that’s a bi-directional socket connection between clients and servers. So, servers can push update to the client without polling. Less memory, less CPU and better UX for apps. That’s a right approach, kudos to the team for that.

2 Likes

OK I have finally gotten a token from my Ezlo Plus, I had to remove the controller from my Vera account and add it back again.

I can successfully send commands to the Ezlo Plus with authentication to get the hub info and to list devices.

However when I try to send a command to turn on an appliance plug device I see this in Postman:

I have triple checked from the Api Tool that I have the correct device ID

So why isn’t it working and why am I seeing this error ?

HTTP/1.1 500 Internal Server Error
content-type: application/json
connection: close

{
    "error": {
        "code": -32602,
        "data": "rpc.params.wrong_field",
        "message": "Wrong field of object",
        "reason": "Item not found by id: 5f4e5871120bab1069c13c49"
    },
    "id": "5f54bcf1120bab191bf1dbe7",
    "result": {}
}

If I try it using Curl instead I see the same thing:

Thanks

I am also unable to send a command to run a scene.

Again I have checked in the Api Tool that I have the correct scene ID:

image

Yet this error is returned:

content-type: application/json
connection: close

{
    "error": {
        "code": -32601,
        "data": "rpc.method.notfound",
        "message": "Unknown method"
    },
    "id": "5f54c053120bab191bf1dbec",
    "result": {}
}

If I try it using Curl instead I see the same thing:

Have you tried https without the auth token?

A HTTPS hub info get command without authentication does appear to work yes.

pi@raspberrypi:~/Ezlo $ curl --http1.1 --insecure --verbose https://192.168.0.11:17000/v1/method/hub/info/get
* Expire in 0 ms for 6 (transfer 0xb6e880)
*   Trying 192.168.0.11...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0xb6e880)
* Connected to 192.168.0.11 (192.168.0.11) port 17000 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=RO; ST=Iasi; L=Iasi; O=controller; OU=d026af70-7f32-11ea-ab2d-b7c43c5254eb; CN=90000400; emailAddress=sysadmins@ezlo.com
*  start date: Sep  6 10:04:16 2020 GMT
*  expire date: Mar  5 10:04:16 2021 GMT
*  issuer: C=RO; ST=Iasi; L=Iasi; O=location; OU=8098afb0-a7da-11e9-ab53-05964c0ff1e4; CN=clas.ezlo.com; emailAddress=sysadmins@ezlo.com
*  SSL certificate verify result: EE certificate key too weak (66), continuing anyway.
> GET /v1/method/hub/info/get HTTP/1.1
> Host: 192.168.0.11:17000
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: application/json
< connection: close
<
HTTP/1.1 200 OK
content-type: application/json
connection: close

* TLSv1.2 (IN), TLS alert, close notify (256):
* Closing connection 0
{"error":null,"id":"5f54d7ad120bab31af481074","result":{"architecture":"armv7l","build":{"branch":"at","builder":"@6f94411cdbcf","commit":"e218a385eccb4ef8bcf0c1d1","time":"2020-08-28T13:27:44+0000"},"firmware":"1.3.1028.3","kernel":"4.19.75","localtime":"2020-09-06T13:35:57+0100","location":{"latitude":54.0043029785156,"longitude":-1.55435645580292,"state":"customAll","timezone":"Europe/London"},"model":"h2.1","offlineAnonymousAccess":true,"offlineInsecureAccess":true,"serial":"90000400","uptime":"3d 18h 39m 59s"}}pi@raspberrypi:~/Ezlo $

However if I try the commands to run a scene or turn on a device using HTTPS and no authentication, I still get the same errors I listed above.

So your saying that when the authentication has been turned off as I did previously, you still need to use https:// in your command rather than http:// right ?

Correct, that’s the only thing working for me.

OK so do my commands look to be correct for running a scene and turning on a device ?

Thanks

Yes, I’m guessing you have token in the headers in postman, if so remove them and try again. Or try to run a scene in a browser. I have not tried with devices myself, only scenes.

If I remove the token / authentication from Postman and set it to No Auth

I see the same error when trying to run a scene.

Ok, browser? Reboot hub?

In a browser I get this:

Yes, click advanced and continue to site.

After clicking Advanced and Continue, I then just get a blank white page and the scene isn’t run.

I’ve rebooted the Ezlo Plus hub and trying again in Postman I still get the same error. :sleepy:

HTTP/1.1 500 Internal Server Error
content-type: application/json
connection: close

{
    "error": {
        "code": -32601,
        "data": "rpc.method.notfound",
        "message": "Unknown method"
    },
    "id": "5f54df4a120bab10873069d2",
    "result": {}
}

Ok, I found your problem for scenes. The url should be scenes, not scene.

1 Like

OK that works now in Postman with or without authentication !

Not my mistake however @Oleh said it was “scene” with no S

run scene:
https://127.0.0.1:17000/v1/method/hub/scene/run?sceneId=NNN + authentification headers

So does anyone have a working command example for turning a device on and off ?

Thanks

Try replacing the dots with “/“ like in the api documentation /v1/method/hub/item/value/set?_id=09234njnj234&value=cooling#1_2

This was the command I was trying to use.

https://192.168.0.11:17000/v1/method/hub.item.value.set?_id=5f4e5871120bab1069c13c49&value_bool=true

If I change it to this instead with “/”

https://192.168.0.11:17000/v1/method/hub/item/value.set?_id=5f4e5871120bab1069c13c49&value_bool=true

I get the same error:

Item not found.

Yet looking in the online API Tool that is the correct ID for that device.

Using value_int=1 on the end instead of value_bool=true makes no difference either.