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.

6 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”
}
}

To install the plugin, 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:

@Oleh

Is this still working? I cannot create a new virtual device by using the Online API Tool method.

I wanted to create an interior plug virtual device, I ran this code but no new device is created.

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

Please can you test and confirm it still works ?

Thanks

I’ve just tried creating a new virtual device on my Ezlo Atom and that has worked OK.

However I cannot create a new device on my Ezlo Plus hub.

This is the Atom:

I then used the Vera mobile app connected to the Atom and I can see this new Test switch. Cannot actually make it turn ON however. But its there, its also visible in the new web GUI, same in there I cannot turn on the Test switch either.

Back to the Ezlo Plus it looks like the plugin is installed as its files are there:

image

Looking in this log file ha-extensions_manager.log in this folder /tmp/log/firmware after trying to create the virtual device I am seeing this:

2021-04-27 19:30:03.778688 INFO : Running plugin script: HUB:test_plugin/scripts/generate_devices
2021-04-27 19:30:03.779268 WARN : Plugin test_plugin is not registered

Just rebooted the Ezlo Plus hub and now I see this in the same log file, so it looks like the plugin is starting OK.

2021-04-27 19:33:17.626022 INFO : Plugin started: test_plugin-1.0.719
2021-04-27 19:33:17.639362 INFO : init: GatewayPlugin: the gateway (test_plugin) got registered for the plugin (test_plugin-1.0.719)
2021-04-27 19:33:17.650416 INFO : Plugin: request to start the plugin (test_plugin-1.0.719, HUB:test_plugin/scripts/startup)

I then used the Online API Tool again and attempted to create a new device.

And this time its bloody working !

I saw this in the log file

2021-04-27 19:36:48.948960 INFO : Running plugin script: HUB:test_plugin/scripts/generate_devices

And a new virtual device has been created on the Ezlo Plus.

Wish I rebooted it earlier it would of save me a lot of hassle and time !

I can see this new device in UI1, its called it TestSwitch_2 for some reason. The one created earlier on the Atom is named “TestSwitch”.

I can turn this one on and off OK also, so all good.

This is UI1 for the Atom:

I cannot turn that virtual device on or off, maybe the Atom does not fully support this test plugin ?

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules