VeraLite socket level communication support

Hi,

I’m progressing a small project to integrate a VeraLite device and Z-Wave support into my hybrid technology home automation system I’m not allowed to post a link to my web page describing it :frowning:

Can someone tell me if the Vera will support socket level communication, e.g. could I put the following code in the Luup tab for a scene and expect it to work?

require “luasocket”
host = “192.168.1.29”
c = assert(socket.connect(host, 4488))
c:send(“Command,Zwave,Scene,GoodNight”)
c:close()

I bascially want to send a packet of structured text to a Java process running on my home automation server.

Thanks

Rob Collingridge

You can open a tcp socket with luup.io.open().

There’s no facility to close a socket, or to bind to a port, as far as I can tell.

If you do work out how to do anything more, please post some details here.

A workaround for what you want to do is to write a device for Vera that opens the socket; then there are various ways you could send the device the data you want to transmit from inside some scene code. But that will hold the port open on your remote device even when you’re not sending data.

Another suggestion: you can send OS commands from within luaUPnP, so you could write a shell script to do it and call that from inside a scene.

Hi Rob,

Luasocket is installed, so your code might work as-is. The issue is more to do with blocking. If you put that code inside a Luup plugin then it may block more than just your plugin.

The best thing to do is try it and see. If it does affect stability, then you can fall back to autotoronto’s solution.

Thanks for the responses guys. This stuff is all new to me. My VeraLite arrived 2 days ago and up till then my knowledge of Z-Wave, Lua and Luup was non-existent. It’s a shame I’m not allowed to link to the project on my web site. I’ve spent this evening getting my plan B working successfully, which is to use this code in the Luup tab:

local status, result = luup.inet.wget(“http://192.168.1.80/zwave/update.php?command=some_command”, 5)

This calls some PHP code on my home automation server, which then passes the command using socket level comms to the main HCS process. It’s a bit of a circuitous route but it does work :slight_smile:

All I really want is a way for Z-wave sensors to trigger a scene and the new status to be sent to my HCS process, which is where all the intelligence sits in my hybrid technology system. I can also do the reverse by invoking scenes using the VeraLite web interface.

I’ll now have another try with getting the VeraLite to do socket layer comms directly as this would be tidier and more efficient.

Got it to work as hoped :slight_smile: There was a mistake in my code but fixed this by looking at some examples on the web.

This is the code that worked:

local socket = require(“socket”)
host = “192.168.1.80”
c = assert(socket.connect(host, 4488))
c:send(“Command”)
c:close()

Thanks again for your help and advice. I now have the full level of Z-Wave integration I’d hoped for.

Rob

All I really want is a way for Z-wave sensors to trigger a scene and the new status to be sent to my HCS process, which is where all the intelligence sits in my hybrid technology system. I can also do the reverse by invoking scenes using the VeraLite web interface.
You might not be aware (shoot me if you are) that basically Vera exposes [i]everything[/i] via a web interface available on port 3480? For some info see http://wiki.micasaverde.com/index.php/UI_Notes#The_HTTP_interface

Also it broadcasts all your zwave devices as UPnP endpoints?

To test UPnP calls you can use the Intel Device Spy utility available [url=http://www.intel.com/cd/ids/developer/asmo-na/eng/downloads/upnp/tools/218896.htm?desturl=http://softwarecommunity.intel.com/isn/downloads/zips/IntelToolsForUPnPTechnology_v2.zip]here.[/url] It should pick up Vera, show you all the devices, like light switches, thermostats, etc., let you expand the services and see the actions and variables. Click an action, like SetTarget, to specify the arguments and click 'Invoke' to run the action, such as turning on and off the light.

Just some other ways to interface to Vera, in case you didn’t know of them.

Had seen this but not got round to looking at the detail. This is all very new to me.

Thanks, will take a look.

Rob

Think I can post links now, so this is the detail of my project:

Rob

Very useful - thanks.