How to - Create virtual devices on Ezlo platform

Update: This is now built into the Ezlogic web GUI see here. Which should make this guide obsolete.

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

(NOTE:- This method doesn’t seem to work use Method 1 instead).

Go to the online Api tool here connect to the serial number of your Ezlo Plus. Use the “custom” 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>
]
}
}

UPDATE: REBOOT your hub first in SSH by typing: reboot and hit enter.

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 “custom” 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.

UPDATE:

Below you can find some more detailed instructions on how to use Putty to connect to SSH Terminal.

Putty for Windows can be downloaded here you probably want the one called 64-bit x86.

In the Vera mobile app go to Settings - Network from the menu.

Make a note of the Current Connection, Ethernet or WIFI etc. Mine is Ethernet so I select that from this page

On the next page make a note of your Ezlo controllers IP address

Open the Putty client program you should of installed and create a connection

image

Enter the IP address of your Ezlo Hub the port number should be 22 and SSH should be selected.

You can also enter a name in to the “Saved Sessions” field, to save this connection session and then press the save button.

To actually connect press the Open button.

In the terminal window enter the user name “root” and the WIFI password from the sticker underneath your Ezlo controller.

image

Once logged in to the terminal you can issue the two commands to install the required virtual devices plugin.

opkg update
opkg install firmware-plugins-test_plugin
  • Reboot your hub to complete the plugin installation. Type ‘reboot’ at the Putty (or other client) window then hit ‘Enter’.

Now you need to use the Online API Tool and issue the code commands in there to start creating your virtual devices.

You can now follow the rest of the setup from the official guide here in the “Create your Virtual Switches” section.

7 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

1 Like

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 ?

Does anyone have a link to a list of devices, i.e. “device_type” that we can create?
I am thinking about using this to trigger a scene based on my home mode by setting sensors in the mode configuration. I’m thinking about using a door/window virtual sensor for this.

Hello @rlargent.
On the second page of the attached PDF, you can find the following list of supported devices:


Regards!

VirtualDevices_API.pdf (87.7 KB)

That is exactly what I needed. Thank you

1 Like

Hi, is still working method 2? Trying to create a virtual plugin but nothing at the moment.

Should do but haven’t tried it recently. Maybe I’ll try and create a new device tomorrow.

@lord55

Don’t think method 2 ever worked to install the plugin, use method 1 instead and SSH terminal and run the install commands.

Thanks a lot, you save a lot of time to all the community! Method 1 is working to create virtual devices.

Seems that “Manage Alexa” and “Manage Alexa Ezlo”" doesn’t show virtual switches on the device list. Is it a bug?

Manage Alexa for Vera firmware hubs certainly does expose virtual devices to the Alexa voice assistant platform.

As for “Manage Alexa Ezlo” I’d have to double check and test, but I’d assume it does also.