Vera UI7: How to open an URL (ImperiHome)

Hello.
Here’s a basic question:

I’d like to use Luup code (Lua) to open an URL like http://www.example.com

How do I do that?

Some additional info: I have Imperihome running on an Android-tablet and I’d like to use the TTS in Imperihome so the tablet can give me voice acknowledgments when a scene is run.

[size=20pt]Update Oct 27, 2016:
Problem solved[/size]

Instead of reading trough the whole thread, here is a brief summary of the problem and it’s solution.

Mission:
When a scene is triggered, I’d like a device running Imperihome to say something using the TTS of that device.

Method:
The Imperihome app for Android comes with a web server that has to be enabled in the app settings. In my case, the device running Imperihome will be located at the local adress http://192.168.0.11:8081 (The IP is of course something else on your local network). So by opening a browser and typing that adress, I could reach my Imperihome web interface where I can make the Imperihome do some cool stuff, bu that is out of the scope for this thread.

By typing the URL below in a browser, the Imperihome device will say “Hello”:

http://192.168.0.11:8081/api/rest/speech/tts?text=Hello

In the Luup Wiki, you can use this piece of code to open an url:

local status, result = luup.inet.wget("http://www.example.com", 5)

So, in my Vera Edge, I tried the Luup code below, but it did not work. The code was sent successfully but Imperihome was silent.

local status, result = luup.inet.wget("http://192.168.0.11:8081/api/rest/speech/tts?text=Hello", 5)

Solution:
At the very end of the Luup code above, the figure 5 is some kind of timeout setting.
By changing that figure from 5 to 10 made it work!!!

So, by using the Luup code below, my Imperihome device said “hello”, just as expected.

local status, result = luup.inet.wget("http://192.168.0.11:8081/api/rest/speech/tts?text=Hello", 10)

I hope this helps anyone with a similar problem.
(Say thanks at the end of the thread if it helped you! :smiley: )

Wiki - Luup Scenes : Access the web

local status, result = luup.inet.wget("http://www.example.com", 5)  -- Times out after 5 seconds.

Thanks a lot. I will give that a try when i get home.

I don’t understand why you would want/need a LUUP code to open a URL in imperihome…? or is “(Imperihome)” a different question?

One idea is to get as notification if your website is down.

Sorry, i don’t mean to be difficult but i still don’t get it:

OP asked: “I’d like to use Luup code (Lua) to open an URL like http://www.example.com.” does he want to open a URL in imperihome or in Vera? or where?

Then OP adds: “I have Imperihome running on an Android-tablet and I’d like to use the TTS in Imperihome so the tablet can give me voice acknowledgments when a scene is run.” I don’t understand how this statement ties into the question above (about the Lua code)?

It seams like 2 different questions to me?? But OP appears to be satisfied with just the one question answered… ???

I am running Imperihome on an Android device on the same Wi-Fi as my Vera edge.

In Imperihome you can access it’s TTS by accessing an URL on that same device since Imperihome comes with a web server.

What I’d like to do is when a scene is triggerd, my Imperihome device will give me a voice confirmation using its TTS.

Skickat fr?n min Nexus 6P via Tapatalk

I think you are all over the place with your questions (and i may be the only one that don’t understand). You say you would like imperihome speak in response to scene that is triggered…what scene? a scene in general or one where you plan to incorporate that LUUP code?

If it’s a scene in general, i can try to help but i don’t have a clue about Lua code

[quote=“treetop777, post:9, topic:193973”]I think you are all over the place with your questions (and i may be the only one that don’t understand). You say you would like imperihome speak in response to scene that is triggered…what scene? a scene in general or one where you plan to incorporate that LUUP code?

If it’s a scene in general, i can try to help but i don’t have a clue about Lua code[/quote]

He already got his answer to his question, so unless he asks another he’s now just answering your questions. A stock scene is probley to limited for his needs (and most everyone elses) and hes going to add it to luup code.

@Integlikewhoa is correct. But, I’ll attempt to describe what he’s trying to do, since you(@treetop777) didn’t understand his explanation.

Imerihome contains a Text-To-Speech capability. Imperihome exposes this capability in the form or a web “API”. If you point your PC’s browser at Imperihome’s built -in web server(running on your tablet) with a URL like below

http://TabletsIP:8080/api/rest/speech/tts?text="Greetings, treetop777. How are you?"

Imperihome will say that text.

@ilias wants to put that URL into a Vera scene or PLEG and have Vera run that URL against Imperihome. He’ll probably put the following code in his scene’s Luup tab.

local status, result = luup.inet.wget(http://TabletsIP:8080/api/rest/speech/tts?text='Greetings, treetop777. How are you?"), 5)

With that, he’s using Vera to initiate speech form Imperihome.

I get it! I get that it’s way too advance for me. I REALLY appreciate you guys patience. :slight_smile:

@Z-waver: You’re right on the spot there!

Due to a busy schedule, I still haven’t hade time to try that out. I’ll get back to the thread when I have tried that out, just to confirm that it’s working.

Hello again.

Tried to make Imperihome speak, but w/o success.

If I paste and go to this URL in my browser, then Imperihome says “Hello” loud and clear.

http://192.168.0.11:8081/api/rest/speech/tts?text=Hello
Then, in my Vera Edge: Left menu → Apps → Develop apps → Test Luup code (Lua)
There, I pasted the code below:

local status, result = luup.inet.wget(http://192.168.0.11:8081/api/rest/speech/tts?text=Hejsan"), 5)
When I press the green Go-button, I got this dialog saying

Success
Code sent successfully.

but the Imperihome-device is silent. Totally silent!

My conclusion is that some setting in my Vera Edge concerning Imperihome is incorrect.
Stil, all other functions in my imperihome is working perfect.

Any Idea of what I am doing wrong?

You’ve got a typo. You’re missing the double quote before http

local status, result = luup.inet.wget("http://192.168.0.11:8081/api/rest/speech/tts?text=Hejsan", 5)

I see I have a similar but different typo in my last comment as well.

Are you sure that your port number is correct? I recall Imperihome uses 8080, not 8081. But I don;t have Imperihome to test.

Edit: corrected another typo; removed extraneous )

Edit2: Question port.

Hehe, typo error must be the devil for us coders. ;D

Trying again when I get home this eavning.

Jepp, 8081 is correct. I changed it since I am running IP Webcam om that same tablet and the webcam software by some strange reason has to run on port 8080.

Nope, nothing is spoken.

local status, result = luup.inet.wget("http://192.168.0.11:8081/api/rest/speech/tts?text=Hejsan&&vol=45", 1)

Returns that same “Code sent successfully” but the device is silent.

But when typing this in the same browser, the imperihome TTS works just fine.

http://192.168.0.11:8081/api/rest/speech/tts?text=Hejsan&&vol=45

I don;t know what to tell you at this point. Does Imperihome have debug logging that might indicate what is happening?

You don’t, by chance, have “Secure my Vera” enabled and blocking all local network traffic, do you?

Where do i find this “Secure my Vera” setting? I have been looking after the “Secure my Vera” setting in the entire system but without finding it.

This is what we know right now:

[ul][li]The Imperihome app does receive external commands since a direct URL does work[/li]
[li]Commands from within LUA does not work[/li][/ul]

So the problem is related to my Vera device.

I’ll simply have to contact Vera support.

Thank’s a lot for your assistance so far!

Setup → Unit Settings.