Ezlo Linux firmware - HTTP documentation preview

@cw-kid
Security_threat is internal item controlled by the logic of plugin.
Its not available for control from Lua API.

Its a known issue, we already have a ticket for this issue and working on it.
The easiest way to continue to work with disarm by HTTP - just restart the hub.

1 Like

@Oleh How about the “basic” item of this door contact sensor?

That does have “hasSetter” but seems it can not be used by the Http Api to manually trip it.

I am thinking ahead really for virtual devices when we will be able to add them in to the Ezlo controller.

For example a virtual motion sensor, I will need to be able to trip and untrip them via the Http Api.

hasSetter and hasGetter are members of item. Item is related to device.
If hasSetter false, usually it means that this item depends on sensors or other not edirable by user entities

Yep I understand that now.

So what about the “Basic” item?

It’s hasSetter = true.

By Zwave standard basic item should be available for all devices.

We already have possibility to create virtual devices.

Just execute these commands from command line of your hub:
opkg update
opkg install firmware-plugins-test_plugin

I will share the documentation here asap.

1 Like

OK that’s great!

I’ve just run those commands on my Ezlo Plus.

image image

1 Like

@cw-kid
The API for create virtual devices in attachment.
Great thing, you can rondomize values of the items with your custom settings.
VirtualDevices_API.pdf (87.7 KB)

I want to create a virtual motion sensor device, if you have some sample code for that ?

This is the example in the document

{
 "method": "extensions.plugin.run",
 "id": "_ID_",
 "params": {
 "script": "HUB:test_plugin/scripts/add_device",
 "scriptParams": {
 "name": "TestSwitch",
 "category": "switch",
 "subcategory": "interior_plugin",
 "type": "switch.outlet",
 "device_type_id": "test",
 "battery_powered": false
 }
 }
}

Do you have a list of categories we should be using ?

It appears you already have the sub categories listed in the document under “Supported device types”.

So I need to use “motion_sensor” for the sub category ?

But what is its category ?

Also what is the correct “type” ?

{
 "method": "extensions.plugin.run",
 "id": "_ID_",
 "params": {
 "script": "HUB:test_plugin/scripts/add_device",
 "scriptParams": {
 "name": "TestMotionSensor",
 "category": "switch",
 "subcategory": "motion_sensor",
 "type": "motion.sensor",
 "device_type_id": "test",
 "battery_powered": false
 }
 }
}

Thanks

OK so I just guessed at some of the other fields and ran this in the Api Tool

{
 "method": "extensions.plugin.run",
 "id": "1234",
 "params": {
 "script": "HUB:test_plugin/scripts/add_device",
 "scriptParams": {
 "name": "TestMotionSensor",
 "category": "sensor",
 "subcategory": "motion_sensor",
 "type": "motion.sensor",
 "device_type_id": "test",
 "battery_powered": false
 }
 }
}

REQUEST:

Request

Request body

method: "extensions.plugin.run"
id: "1234"
params:
script: "HUB:test_plugin/scripts/add_device"
scriptParams:
name: "TestMotionSensor"
category: "sensor"
subcategory: "motion_sensor"
type: "motion.sensor"
device_type_id: "test"
battery_powered: false

RESPONSE

error: null
id: "1234"
method: "extensions.plugin.run"

However no motion sensor device in the Vera app showing up.

I then rebooted the Ezlo Plus hub but still no motion sensor device showing in the app.

Also the motion sensor device does not appear in the results of a “hub.devices.list” query in the Api Tool, so I have obviously done it wrong.

I need more information about these fields and what to put in them ?

“id”: “ID”, - Presumably some random and unique ID number string.

“category”: “switch”, - Need a list of the possible categories.

“subcategory”: “interior_plugin”, - Need a list of possible sub categories.

“type”: “switch.outlet”, - Need a list of the possible types.

“device_type_id”: “test”, - What should be entered in to here?

EDIT:

This works instead “scripts/generate_devices”

{
 "method": "extensions.plugin.run",
 "id": "12345",
 "params": {
 "script": "HUB:test_plugin/scripts/generate_devices",
 "scriptParams": {
 "device_type": "motion_sensor",
 "devices_count": 1
 }
 }
}

The first attempt I was trying to use “scripts/add_device” and I need more information on that.

OK so I renamed my virtual motion sensor and added it in to a room.

From the API Tool - hub.devices.list:

hub.items.list:

image

@Oleh Its “hasSetter” is false as I feared it might be !

I need this to be true so I can control this virtual motion sensor from Blue Iris camera software and from other things on my LAN for other virtual motion sensors that I may create on the Ezlo Plus controller.

EDIT 2:

Seems it doesn’t matter if “hasSetter” = false.

In Postman I can trip this virtual motion sensor with this command:

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

And I can untrip it with this comand:

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

So someone please explain why “hasSetter” is false for this virtual motion sensor ? A bug ?

EDIT 3:

I just created a virtual Switch device and its “hasSetter” = true OK.

image

1 Like

@cw-kid,

Just use this request to generate a device and ID will be assigned automatically.
Put the type of device and quantity of devices you want to create.

{
    "method": "extensions.plugin.run",
    "id": "_ID_",
    "params": {
        "script": "HUB:test_plugin/scripts/generate_devices",
        "scriptParams": {
            "device_type": "bulb_rgb",
            "devices_count": 1
        }
    }
} 

Let me add more information about “hasSetter”…

1 Like

Yes I figured that out eventually easy to do it the way you just said.

I can’t seem to delete a device can anyone else confirm ?

{
" method ": "extensions.plugin.run" ,
" id ": "12345" ,
" params ": {
" script ": "HUB:test_plugin/scripts/remove_device" ,
" scriptParams ": {
" device_id ": "5f589402120bab1065bc0e7b"
}
}
}

Error:

error:
code: 18
data: "cloud.error.unsupported_message_type"
description: ""

No, I can successfully remove a virtual device.

Its working now and deleting the device with this code formatting:

{
    "method": "extensions.plugin.run",
    "id": "_ID_",
    "params": {
        "script": "HUB:test_plugin/scripts/remove_device",
        "scriptParams": {
            "device_id": "5f157ebd46aaf021143f67d4"
        }
    }
}

@Oleh

How do we switch House Modes using the HTTP API ?
What is the correct command ?

I can see there are two different device id numbers.

These are the _id numbers for each mode:

Home = _id “1”
Away = _id “2”
Night = _id “3”
Vacation = _id “4”

I’ve tried a command like this with both those device id numbers. but it doesn’t work.

https://192.168.0.11:17000/v1/method/hub.modes.switch?_id=5f4e588c120bab1069c13c4f&value_int=2

Response:

 "error": {
        "code": -32602,
        "data": "rpc.params.invalid",
        "message": "Wrong params"
    },
    "id": "5f58d29a120bab10908be220",
    "result": {}
https://192.168.0.11:17000/v1/method/hub.modes.switch?_id=5f57d230120bab1065bc0e73&value_int=2

Response:

"error": {
        "code": -32602,
        "data": "rpc.params.invalid",
        "message": "Wrong params"
    },
    "id": "5f58d2d5120bab10908be222",
    "result": {}

https://community.getvera.com/t/ezlo-linux-firmware-http-documentation-preview/214564/37

Just tried this command in Postman:

https://192.168.0.11:17000/v1/method/hub/modes/switch?modeId=2

Still no dice:

Response:

 "error": {
        "code": -32602,
        "data": "rpc.params.invalid",
        "message": "Wrong params"
    },
    "id": "5f58dae1120bab10908be257",
    "result": {}

Then tried this one:

https://192.168.0.11:17000/v1/method/hub/modes/switch?modeId="2"

Response is different:

"error": {
        "code": -32602,
        "data": "ezlo.house_mode.not.exist",
        "message": "The house mode with this id does not exist"
    },
    "id": "5f58db7e120bab10908be259",
    "result": {}

Hmmm, my requests are authenticated with a token. Perhaps that is the difference?

1 Like

I can try it using authentication.

So what is the HTTPS command you are using ?

Yes your correct it only works when using authentication:

This is the correct URL when used with authentication.

https://192.168.0.11:17000/v1/method/hub/modes/switch?modeId=2

Response:

HTTP/1.1 200 OK
content-type: application/json
connection: close

{
    "error": null,
    "id": "5f58eacb120bab10962191c5",
    "result": {
        "switchToDelay": 120
    }
}