VoxCommando - Control Vera by Voice

I was just looking for a way to trigger an action in VC based off a notification in Vera. Doesn’t matter what’s producing the notification so luup for my case. Plus I am not big on coding. If I can trigger events with Vera alerts my needs have been met.

If you would prefer to use this method, then go ahead. They both work. I noticed that the function I defined in my Vera luup startup code is not accessible from the luup code in the scene defined by the PLEG action, so if you want to it this way you will probably need to define the entire method each time, rather than just calling the function with a single line of code.

I think the choice comes down to how you want to use it. If you already have alerts and you want to send a message to VC for all of them, then using Vera Alerts makes perfect sense. But if you just want to add a few specific messages to VC from PLEG actions, then maybe using the luup code makes more sense. For my humble needs so far, I have found that the scene and devices events that VC is already generating are enough.

Vera Alerts is not working for me.

Has anyone tried it successfully?

Yes.

@JitterJames thanks for posting your instructions however. However, it is not working for me personally. And your not providing an troubleshooting advice or confirmation my screenshot is correct. I’m not asking if your environment is working as I assume it does (as your well versed in your product)…I’m on the forum asking for help as to why it does not as I’m not expert.

Has anyone been able to duplicate the configuration of Vera Alerts? As of now, nobody else has confirmed it is working and I’m trying to compartmentalize the problem.

Sorry,

I can’t really provide troubleshooting because you have not described what you have done other than to say that telnet does not work. I never suggested using telnet. VC is not a telnet server and does not follow the telnet protocol. Just because there is a TCP socket does not mean that it supports telnet.

I provided instructions that should be sufficient for you to test it, assuming that you know how to use VeraAlerts. I am no expert in VeraAlerts having only installed it yesterday. I do not know if you are familiar with using VeraAlerts or if you have used them successfully before. I do not know if you followed my instructions properly because all you really said was “I wasn’t able to get this to work.” which doesn’t give me a lot to go on.

It seemed like you wanted confirmation that this method worked when you asked “Has anyone tried it successfully?” so I answered you, to let you know that I had actually tested the method successfully.

Your screen-shot of VeraAlerts looks correct, assuming that your IP address is correct. The next step would be to go to the Send Alert tab, make sure that the new VC profile you have created is selected and try entering text into the Message box and clicking send. If this does not work as expected, please try to tell me what, if anything is happening in the VC history windows and/or log file.

James,
I am looking at this right now and do have a question. I have created the profile in Vera Alerts and have it pointed to my VC computer. I enabled the TCP Plugin on VC and I am at the point of adding in the XML you provided. This is the part that I am confused on. I see in the TCP plugin folder a file names “actions.xml” and see the tcp.start.server option in there, but suspect this is not the file where I need to dump in what you provided. What am I missing?

[quote=“waynehead99, post:47, topic:177473”]James,
I am looking at this right now and do have a question. I have created the profile in Vera Alerts and have it pointed to my VC computer. I enabled the TCP Plugin on VC and I am at the point of adding in the XML you provided. This is the part that I am confused on. I see in the TCP plugin folder a file names “actions.xml” and see the tcp.start.server option in there, but suspect this is not the file where I need to dump in what you provided. What am I missing?[/quote]

You don’t need to create any files or edit any files by hand. We are able to copy and paste commands to and from the command tree using XML. Please see here for general information about this: XML on the forum - VoxCommando

In your case, you should:

  • go to VoxCommando, enabled the TCP plugin and restart VoxCommando (which I guess you have done)
  • Click Edit to open your command tree.
  • select all the xml that I posted to the forum, and press ctrl-C to copy it
  • click on a group in your VC command tree editor to make sure it has focus again and then press ctrl-V
    You should see a new command group appear in your tree called “TCP Vera Alerts”. If you don’t then you probably made a mistake somewhere along the way, such as not copying the entire code block of xml.

Then you should

  • click the save icon and then close the edit window.
  • restart VoxCommando.

When VC restarts the VC.Loaded event should automatically trigger the command that you have just created, which will create the TCP server. Then if it works, you should see events generated when you click “send” from the “send alert” tab of the Vera Alerts plugin, you will hopefully see something happen in your VoxCommando history panel. Note that you need to have the correct profile selected. I am not 100% sure how to configure VeraAlerts to make sure that it is sending to the correct profile. I have unpredictable behaviour from this plugin. Often when I click to click a check box I get a javascript pop-up saying “failed” and at that point I need to restart UI5.

I think I will need to create a video to outline the steps from beginning to end because if you are not familiar with VC and not familiar with VeraAlerts (which I am not), there are a lot of things that can go wrong. Once I got VeraAlerts to actually send the alert to the correct profile though, I had 100% success.

If you want to simplify the process somewhat you could as for a new feature in Vera Alerts to be able to send a UDP message instead of having to use TCP.

I have now independently tested the instructions that James has provided above and was able to get TTS.Speak to work immediately.

However, I did have difficulty using a Vera Alert event to trigger a command in VoxCommando at first, until it became clear that the the problem was that when I sent the message:

VC.TriggerEvent&&VeraAlert

an invisible character was being added at the end of my event name. This meant that although the event was generated and I could see it in my history panel, the VoxCommando command that was trying to use this event as a trigger wasn’t being executed.

The “failed” command was the following:

<?xml version="1.0" encoding="utf-16"?> <command id="268" name="this is a vera alert" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description=""> <action> <cmdType>TTS.Speak</cmdType> <cmdString>This is a Vera Alert.</cmdString> <cmdRepeat>1</cmdRepeat> </action> <action> <cmdType>OSD.ShowText</cmdType> <cmdString>This is a Vera Alert. Triggered by the Vera Alert plugin in Vera.</cmdString> <cmdRepeat>1</cmdRepeat> </action> <event>VeraAlert</event> </command>

To make this work, I changed the event name in my VoxCommando command to VeraAlert* (i.e., I added a wildcard character), so that VC would still use the event being generated by Vera Alerts regardless of invisible characters to trigger my command.

The following worked consistently:

<?xml version="1.0" encoding="utf-16"?> <command id="268" name="this is a vera alert" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description=""> <action> <cmdType>TTS.Speak</cmdType> <cmdString>This is a Vera Alert.</cmdString> <cmdRepeat>1</cmdRepeat> </action> <action> <cmdType>OSD.ShowText</cmdType> <cmdString>This is a Vera Alert. Triggered by the Vera Alert plugin in Vera.</cmdString> <cmdRepeat>1</cmdRepeat> </action> <event>VeraAlert*</event> </command>

I hope that makes sense and is of use to those who wish to try it.

Here is a video walkthrough from the very beginning.

http://www.screencast.com/t/HZDFHOaoFVgN

I went through it pretty quickly to avoid a massive upload, so use pause if you need to. Some steps are not really steps, I am just opening the command, for example, to show the settings that are in there.

I hope it helps somewhat.

The following LUUP code can be used to trigger an event without using Vera Alerts:

local socket = require("socket")
host = "192.168.0.100"
c = assert(socket.connect(host, 2048))
c:send("tts.speak&&This is a test")

Added the “tts.speak&&” prefix and removed the “c:close()”. Since VoxCommando closes the socket forcefully on it’s end…and if Vera was delayed in closing the command on it’s end after the socket was already closed…it was hanging Luup.

You beat me to it @AgileHumor :slight_smile:

I’ve been working on some code myself, it’s slightly different as I wanted to create a dynamic piece of tts, but it does the same thing and seems to work well.

[code]socket = require(“socket”)
local s = socket.udp()

local sensor = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, 210)

s:sendto("The temperature in bens room is now " … sensor, “192.168.1.29”, 33000)
s:close()[/code]

However, while I can see it appear in the event list of VoxCommando, I can’t seem to do anything with it at the moment.

You need to prefix it with “tts.speak&&” in the sendto. Look one message up for exact syntax.

I think you must have not noticed that I already posted this link, so I will post it again:

Given the choice, if you are going to use luup anyway, I would suggest that UDP is preferable to TCP, mostly because it is easier to set up (no plugin required VoxCommando is already listening for UDP messages on port 33000 by default), and because it is more “tried and true” for VoxCommando. The TCP server action for VC has not really been tested or developed to the point where I would describe it as robust. If people start using it more though, I will work on it more.

With your current code you are just sening text. You need to send something that VC can understand such as an action. This is explained in the link that I posted.

Hi @jitterjames, the piece of code I posted above was UDP, I just missed the “tts.speak&&”

I saw your post and had a look, but wanted to have a play and see if I could build me own bit of code (I’m a novice, so using any opportunity to learn something new :wink: )

James,
Thanks for the link how to upload XML… pretty slick. That was the missing piece. I have it working now and delivers what I initially wanted.

Thanks again.

Cool. Sounds like everyone is making progress. ;D

Meanwhile I made some minor adjustments to the TCP plugin for those of you who still want to use VeraAlerts. There is no major changes here except that there were some null characters at the end of the message that were messing up events (thanks to Nime5ter for noticing this) etc. and I have cleaned that up. Also, it seemed that when putty disconnected VC would go into an endless loop, so now I AM forcing a disconnect after the message is received. I’m not sure if this is the same issue that AgileHumour mentioned, or how it will affect that.

I recommend you replace the tcp.dll file in …VC\plugins\TCP with the attached tcp.dll

By the way I have been able to test the connection to VC using a telnet client like putty, but not with the windows telnet client which sends messages one character at a time as you type them in.

This little TCP server that we are creating in VC extremely simple. It just listens for a single TCP message that arrives in one shot, then disconnects and waits for another connection. It does not make any assumptions about how the message should be terminated, so it will not keep listening until a particular character arrives (like carriage return) to signal the end of the message. That is why it doesn’t work well with the windows telnet client. If this functionality is required it can be made possible in a future update, but I won’t lock it down to any one standard. I will try to make it as flexible and user configurable as I can so that it can be used in a variety of different ways. This will probably mean an extra parameter in the action to specify the termination sequence.

edit: I’m not allowed to attach a .dll - so I will rename it .jpg please just save the file and then rename it back to tcp.dll

You can’t use Startup LUA in PLEG actions per:
http://forum.micasaverde.com/index.php/topic,17624.msg161405.html#msg161405

This would be the best LUA code in PLEG for built in VC TTS UDP option (no extra plugin required, builtin to VoiceCommando):

local ttsMsg = "This is a Test" local socket = require("socket") local udp = socket.try(socket.udp()) ttshost = "192.168.0.100" socket.try(udp:sendto("tts.speak&&" .. ttsMsg, ttshost, 33000))

This would be the LUA code in PLEG action for VC TTS TCP plugin (extra config required on VC TCP/IP plugin):

local ttsMsg = "This is a Test" local socket = require("socket") ttshost = "192.168.0.100" tcp = assert(socket.connect(ttshost, 2048)) tcp:send("tts.speak&&" .. ttsMsg)

Note - Update ttshost with IP of your TTS server running VoiceCommando

Is this working with UI6. I’ve tried the login and password but the add on in vox doesn’t find my Vera. Remote or local.

Thanks.

Sent from my SAMSUNG-SGH-I747 using Tapatalk

I have not tried it with UI6. I only have one unit and I am not eager to get involved in whatever headaches UI6 will bring me. I did not even know that UI6 had been released util today, but a quick browse of this forum shows that they have changed how authentication works. I don’t know if that will apply to local access or not.

You can try to enter the IP and port of your unit in to the address field on the VC\Vera plugin settings and see if it works.

example: 192.168.0.100:3480

I am too busy with other things at the moment but if someone wants to grant me remote access to their unit running UI6 I will take a look some time in the coming weeks and see if there are any quick fixes I need to apply to the plugin to make it work on UI6.