How to - Create virtual devices on Ezlo platform

We can now create some virtual devices on the Ezlo Plus / Secure and Vera Edge running Ezlo firmware.

There are two methods you can use to install the Virtual Devices plugin.

Method 1 - Using SSH

You need to SSH in to your Ezlo controller using Putty or some other SSH client and run these two commands first:

The uername is: root and the password is on the sticker underneath the controller.

image

opkg update
opkg install firmware-plugins-test_plugin

OR

Method 2 - Using API Tool

Go to the online Api tool here connect to the serial number of your Ezlo Plus. Use the “Not Listed” option from the “API Calls” drop down box.

In the text box enter the codes below and hit the query button.

First we need to execute:

{
"method" : "hub.software.update.plan" ,
"id" : "_ID_" ,
"params" : {
"operation" : "install" ,
"type" : "plugin" ,
"id" : "test_plugin"
}
}

The result of the previous request should be inserted into this request:

{
"method" : "hub.software.update.execute" ,
"id" : "_ID_" ,
"params" : {
"actions" : [
<Result of previous command>
]
}
}

Once you have installed the Virtual Devices plugin, go to the online Api tool here connect to the serial number of your Ezlo Plus. Use the “Not Listed” option from the “API Calls” drop down box.

In the text box enter this code and hit the query button to create a motion sensor.

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

or you can use the following codes

Plug Interior - Switch:

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

Temperature Sensor:

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

Thermostat:

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

Combo Sensor: (Humidity , Temp and Motion Sensor)

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

Plug Dimmable:

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

Door Lock:

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

Bulb RGB:

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

Garage Door:

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

Roller Shutter / Window Covering:

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

To delete a virtual device:

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

You can find the device ID of the device you wish to delete by using the hub.devices.list query in the online API Tool and looking in the Response section and Result.

image

Virtual Device API documentation:

VirtualDevices_API.pdf (87.7 KB)

Also see here the Vera to Ezlo Bridge plugin, if you want to create virtual devices on the Ezlo Plus hub that actually control real devices on your Vera hub.

5 Likes

Couple things need to be added to the “How to” about virtual devices:

  1. The easiest way for most of the users of how to install test plugin to emulate devices is quite simple and requires 2 requests.

First we need to execute:
{
"method" : "hub.software.update.plan" ,
"id" : "_ID_" ,
"params" : {
"operation" : "install" ,
"type" : "plugin" ,
"id" : "test_plugin"
}
}

The result of the previous request should be inserted into this request:
{
"method" : "hub.software.update.execute" ,
"id" : "_ID_" ,
"params" : {
"actions" : [
<Result of previous command>
]
}
}

Thats all, now we have installed virtual devices on your Ezlo Plus/Ezlo Secure hub.

  1. This field from the documentation is just a message id and no need to assign a custon number to it.
"id": "_ID_",
  1. Error with removing virtual devices.
    @cw-kid
    all backspaces in the request you wrote as example need to be removed.
    In original manual request looks like this:
{
    "method": "extensions.plugin.run",
    "id": "_ID_",
    "params": {
        "script": "HUB:test_plugin/scripts/remove_device",
        "scriptParams": {
            "device_id": "5f157ebd46aaf021143f67d4"
        }
    }
}

without additional backspaces.

1 Like

Thank you for the further information.

I have now been able to delete that virtual device OK !

I’ve added “Roller Shutter / Window Covering” device that was not listed in the PDF document, but there is a device LUA file for it on the system in this folder /opt/firmware/plugins/test_plugin/scripts/device_info and it works when added as a device in the API Tool.

I have a problem creating virtual device.
When i enter this code in api tool i get this response:

error: null

id: "_ID_"

method: "hub.software.update.plan"

result:

sender:

conn_id: "b5a4e054-0543-48e7-9c89-566d982c0252"

type: "ui"

I tried also with ssh and when i try to create virtual device i get this

error: null

id: "_ID_"

method: "extensions.plugin.run"

result:

sender:

conn_id: "b5a4e054-0543-48e7-9c89-566d982c0252"

type: "ui"

This is what i get in broadcast message when i try to create a virtual device

{
“id”: “ui_broadcast”,
“msg_subclass”: “hub.extensions.plugin.run.progress”,
“result”: {
“completed”: 0,
“error”: {
“code”: -32603,
“data”: “ezlo.lua.script.error”,
“message”: “Script error”,
“reason”: “?:-1: attempt to index a nil value\nstack traceback:\n\t=?\n\t=?\n\t=?\n\t=?”
},
“operationId”: “ID”,
“status”: “failed”
}
}

I’ve never used method 2 I don’t think it worked for me either.

Method 1 and running the plugin install commands in SSH should work.

I fixed it, i dont know how not i can create virtual devices :slight_smile:

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules