Virtual HTTP Devices Plug-in v2

I just released v2 of my Virtual HTTP Devices Plug-in. As always, 100% local, 100% standard, mobile friendly and working on openluup/altui as well.

What’s new in v2:

  • Master/Children: now you can just create a master and have any number of children attached. They will still work separately, but this will greatly improve memory consumption on Vera. Please see GitHub for guidance on migration. No need to do it unless you have many devices on your system.
  • async update of device’s status. If you want to update the status of a device separately, just return something different than the HTTP code 200/300 family. it’s useful if your device doesn’t complete the response with the call and you want to update its status. Just use a normal Vera call to update the corresponding variable
  • added support for Scene Controllers (see my post in Shelly i3 for a use case)
  • more work around switches/heaters
  • stabilization and fixes

I’m still not sure I will add it to the official store, so get it from GitHub.

6 Likes

Hello @therealdb,

there is a bug in the dimmable light, the brightness url is missing

1 Like

@therealdb Well done superb plugin :wink:

1 Like

yep, thanks for noticing. fixed in the new version published on GitHub.

Hi @therealdb

Hope all is well, I’m trying to figure out how best I can make a 4 plug IP switch work with your http plugin, any guidance would be appreciated… The details below hopefully will help.

  1. on / off commands for one socket are sent via the following command.
http://192.168.1.199/set.cmd?user=admin+pass=12345678+cmd=setpower+p61=1
http://192.168.1.199/set.cmd?user=admin+pass=12345678+cmd=setpower+p61=0
  1. on/off commands for multiple sockets sent at the same time is as follows
http://192.168.1.199:80/set.cmd?user=admin+pass=12345678+cmd=setpower+p61=1+p62=0+p63=1+p64=0 
  1. the status of all sockets can be requested like this.
http://192.168.1.199/set.cmd?user=admin+pass=12345678+cmd=getpower

Which returns this.

p61=1,p62=0,p63=0,p64=0 
HTTP/1.0 200 OK 
Connection: close 

The last one, (FYI) I’ve got a bit of Lua code to capture the specific socket values.

local http = require "socket.http"
local result, status = http.request("http://192.168.1.199:80/set.cmd?user=admin+pass=12345678+cmd=getpower")
local report = string.match(result, 'p61=%d.p62=%d.p63=%d.p64=%d')
local pw1, pw2, pw3, pw4 = string.match(report, "(p%d+=%d),(p%d+=%d),(p%d+=%d),(p%d+=%d)")
print(string.sub(pw1, -1))
print(string.sub(pw2, -1))
print(string.sub(pw3, -1))
print(string.sub(pw4, -1))

I have the plugin installed and added the on and off commands, but they don’t seem to work. (See below)

@therealdb

Another question I wanted to ask was around future support for command line requests? For example I make a few calls to other devices, e.g. my NAS to see if a VM is running on a host. E.g below.

local command = io.popen("ssh -y -i /etc/dropbear/dropbear_rsa_host_key pi@192.168.1.37 '/QVS/usr/bin/virsh list --all' 2>&1")
print(command)
local msg = command:read("*a")
print(msg)

Which returns this.

Id    Name                           State
----------------------------------------------------
 5     6e856cb2-2793-4acd-9a15-9e1d28ff0caf running
 -     137f2fcf-2db2-43a8-8dc3-9964dfe6aabf shut off
 -     4ad65c4d-99d5-4c2f-aca4-edaca820e8df shut off
 -     7b0f8c69-de6y-4aa2-a601-1414304fff30 shut off
 -     84e9b437-7e09-4ee6-ba4e-201096b9266c shut off
 -     d7216338-8e39-4107-b8e0-2019cd150ed2 shut off
  1. set debugmode variable to 1 and look at logs. There’s maybe something going on.
  2. you could send any complex command via curl support. Look at docs.

If you want to sync back status, you’ll have to write some code. I was thinking of a way to ping an endpoint for status, but I’m not sure it could be an easy task to be general enough.

Hi @therealdb

Just wanted to suggest a possible idea for a future feature and that’s to add a ‘GetStatusURL’ option, where the person can add a url in to get the current status and your plugin will looks for either a “1” or “True” for on, and a “0” or “false” for off being returned.

If their ‘GetStatusURL’ does not return exactly that, then also have a ‘GetStatusLua’ option too, where you can put some Lua code in that the plugin runs to return once again either a “1” or “True” for on, and a “0” or “false” for off.

I appreciate you can do scene for this , and set variables, but I just thought it would be nice to have everything in the same device/plugin etc.

I can’t create an RGBW dimmer. Please check my parameters screenshot
name
Virtual HTTP Devices
device_type
urn:schemas-upnp-org:device:DimmableRGBLight:1
altid
ip
mac
manufacturer
model
id_parent
0
nobulk
embedded
disabled
restricted
device_file
D_VirtualRGBW1.xml
id
56
room
0
time_created
1614605503
plugin
9281
impl_file
I_VirtualRGBW1.xml
category_num
4
subcategory_num
2
device_json
D_VirtualRGBW1.json
local_udn
uuid:4d494342-5342-5645-0038-000002b06c71

Parameters are OK. go to variables, set debugmode to 1 and look at logs. You’ll find better instructions on the readme.

I’m still not 100% convinced. The use case here is to avoid polling and using pushing instead (ie from Tasmota or whatever), but I’ll try to add something in the next version.

Thanks @therealdb

Perhaps I’m missing something, how do you get push to work with quite old and very basic http request based plug sockets (those that just have basic on/off/status capability ) ?

You can’t and your use case obviously needs polling and this feature.

Yep afraid so, all my http sockets and some of my lights only work like that … (I must be oldskool) :slight_smile:

I’m trying to stay away from polling, because I’m sure it will impact the stability of your Vera. But I’ll add it anyway, as an optional feature for everyone who needs it and want to run it at their own risk.

Thanks, so much :slight_smile:

How will you look to set up the polling feature?

Will it be something where I set a frequency variable (e.g number of seconds) between polls so I know it will always be accurate after a period time ?

Or would you look to trigger that in a different way maybe x seconds after any command is sent ?

Or ideally both?

Just polling, with a configured variable. Otherwise it will become too complex to handle.

Best Home Automation shopping experience. Shop at getvera!

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