Text-to-speech on Mobile with tasker

I like the possibility to output voice.
But in my house It’s not the perfect location to use the openHAB-Server as loudspeaker…

So I don’t use the say()-Command.

Instead I use the android app autoremote in combination with tasker.

So I can call an http-request via openhab to submit a string to my smartphone and there its read by tasker.

This works quite well, but it doesn’t look very elegant in the openHAB-rule (It’s a very long url).

Is there a possibility to create a custom function I can use in each rule?

Like sayOnMobile() ?

1 Like

I had a similar problem with my old home automation software… The text box to enter URLs for actions was to short… In the end I signed up for one of those services that lets you create short URL links for long complicated ones…

Worked well but I guess this made most of my actions reliant on an internet connection to resolve the addresses.

@mashborn
I have been considering trying to implement an autoremote action… just trying get my head around the IDE…

@mashborn

I just started playing with this, and it allows you to send autoremote messages and notifications from command line.

Format:
pythonremote --message Chrome_Laptop ‘hello mark’

Might be useful…

Hi, can I ask you how you did that?What’s the rule’s code? thank you very much

Install autoremote on your android.
Then open the device-URL on a desktop (shown as goo.gl/ksahdjkah)
there you can configure a notification-url
https://autoremotejoaomgcd.appspot.com/sendnotification?key=[yourlongkey]&title=fvsdfsdf
From openhab-rule your can call
sendHttpGetRequest(‘https://autoremotejoaomgcd.appspot.com/sendnotification?key=[yourlongkey]&title=fvsdfsdf’)

1 Like

Great! thanks a lot

@mashborn Could you give a brief explanation of how you create the Profile in Tasker to receive the text from AutoRemote and have AutoVoice then play it. I’m kind of new to Tasker but have looked at a lot of video tutorials but can’t quite figure it out. First I can’t even get the messages to get to the phone. Then I can’t figure out how in Tasker to take that message and port it over to AutoVoice. I assume you need to configure Tasker to see the pop-up message and send the message text to the AutoVoice app, maybe if a keyword is present like “openhab”.

I was finally able to figure out how to send the notification message to the phone. Now all I have to do is figure out how to make tasker convert it to voice.

there’s the “say()” command in tasker for voice-output.
I use the %arcomm-Variable from autoremote.

I have no idea what I’m doing wrong. I did see that the %arcomm variable was not something I could pick from the list when I built the task called “Say Notification”. Maybe you could export from your Tasker and send me the profile. I can’t imagine what I’m doing wrong. I did just try to make the task to trigger just a beep sound and that didn’t work either. I must be doing something very basic wrong.

Here is my Profiles description exported from Tasker:

Profile: Say Notification (2)
Event: AutoRemoteLite Communication [ Configuration:Communication Types: Notification ]
Enter: Say Notification (3)
A1: Say [ Text:%artext %arcomm Engine:Voice:com.google.android.tts:eng-usa Stream:3 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ] 

Here is the full XML export

<TaskerData sr="" dvi="1" tv="4.7u3m">
<Profile sr="prof2" ve="2">
<cdate>1443317236393</cdate>
<edate>1443540778048</edate>
<id>2</id>
<mid0>3</mid0>
<nme>Say Notification</nme>
<Event sr="con0" ve="2">
<code>48749</code>
<pri>0</pri>
<Bundle sr="arg0">
<Vals sr="val">
<CommunicationTypes>&lt;StringArray sr=""&gt;&lt;_array_CommunicationTypes0&gt;Notification&lt;/_array_CommunicationTypes0&gt;&lt;/StringArray&gt;</CommunicationTypes>
<CommunicationTypes-type>[Ljava.lang.String;</CommunicationTypes-type>
<com.twofortyfouram.locale.intent.extra.BLURB>Communication Types: Notification</com.twofortyfouram.locale.intent.extra.BLURB>
<com.twofortyfouram.locale.intent.extra.BLURB-type>java.lang.String</com.twofortyfouram.locale.intent.extra.BLURB-type>
<net.dinglisch.android.tasker.EXTRA_NSR_DEPRECATED>true</net.dinglisch.android.tasker.EXTRA_NSR_DEPRECATED>
<net.dinglisch.android.tasker.EXTRA_NSR_DEPRECATED-type>java.lang.Boolean</net.dinglisch.android.tasker.EXTRA_NSR_DEPRECATED-type>
<net.dinglisch.android.tasker.RELEVANT_VARIABLES>&lt;StringArray sr=""&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0&gt;%err
Error Code
Only available if you select &amp;lt;b&amp;gt;Continue Task After Error&amp;lt;/b&amp;gt; and the action ends in error&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1&gt;%errmsg
Error Message
Only available if you select &amp;lt;b&amp;gt;Continue Task After Error&amp;lt;/b&amp;gt; and the action ends in error&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2&gt;%arcommunicationtype
Communication Type
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3&gt;%artime
Current Time
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4&gt;%arsenderbtmac
Sender Bluetooth Mac Address
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES5&gt;%arsenderid
Sender Id
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES5&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES6&gt;%arsenderlocalip
Sender Local IP
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES6&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES7&gt;%arsendername
Sender Name
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES7&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES8&gt;%arsenderpublicip
Sender Public IP
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES8&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES9&gt;%arsendertype
Sender Type
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES9&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES10&gt;%artext
Notification Text
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES10&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES11&gt;%arvia
Way the message was sent (BT, Wifi, GCM)
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES11&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES12&gt;%artime
Current Time
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES12&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES13&gt;%arsenderbtmac
Sender Bluetooth Mac Address
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES13&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES14&gt;%arsenderid
Sender Id
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES14&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES15&gt;%arsenderlocalip
Sender Local IP
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES15&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES16&gt;%arsendername
Sender Name
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES16&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES17&gt;%arsenderpublicip
Sender Public IP
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES17&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES18&gt;%arsendertype
Sender Type
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES18&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES19&gt;%arvia
Way the message was sent (BT, Wifi, GCM)
&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES19&gt;&lt;/StringArray&gt;</net.dinglisch.android.tasker.RELEVANT_VARIABLES>
<net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>[Ljava.lang.String;</net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>
<net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS>CommunicationTypes plugininstanceid plugintypeid </net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS>
<net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS-type>java.lang.String</net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS-type>
<net.dinglisch.android.tasker.subbundled>true</net.dinglisch.android.tasker.subbundled>
<net.dinglisch.android.tasker.subbundled-type>java.lang.Boolean</net.dinglisch.android.tasker.subbundled-type>
<plugininstanceid>5abb1305-71c9-47aa-a735-1fa144bbe42b</plugininstanceid>
<plugininstanceid-type>java.lang.String</plugininstanceid-type>
<plugintypeid>com.joaomgcd.autoremote.IntentCommunication</plugintypeid>
<plugintypeid-type>java.lang.String</plugintypeid-type>
</Vals>
</Bundle>
<Str sr="arg1" ve="3">com.joaomgcd.autoremote.lite</Str>
<Str sr="arg2" ve="3">AutoRemoteLite Communication</Str>
</Event>
</Profile>
<Task sr="task3">
<cdate>1443317271069</cdate>
<edate>1443540521702</edate>
<id>3</id>
<nme>Say Notification</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>559</code>
<Str sr="arg0" ve="3">%artext %arcomm</Str>
<Str sr="arg1" ve="3">com.google.android.tts:eng-usa</Str>
<Int sr="arg2" val="3"/>
<Int sr="arg3" val="5"/>
<Int sr="arg4" val="5"/>
<Int sr="arg5" val="1"/>
<Int sr="arg6" val="0"/>
<Int sr="arg7" val="0"/>
</Action>
</Task>
</TaskerData>

OK, so I figured it out finally.
You need Tasker and the AutoRemote plugin on your phone. Take a look at this AutoRemote walk through. It’s a little outdated when it comes to my new install of Tasker and AutoRemote, but it is what finally got me to figure it out.

Whenever I want voice feed back on my android phone I just add the following to a rule:

postUpdate(Response,"the master bedroom motion detector was triggered") // Response is a String item in the items file    
callScript("autoremote") 

Here is the Script “autoremote.script” file:

var String url = "https://autoremotejoaomgcd.appspot.com/sendmessage?key=[your-very-long-key-here]&message="

Thread::sleep(1000) // give some time for the Response var to be set

// add the base url to
// the message prefix which consists of the filter word, what to set the voice pitch at (1-10) - used in Tasker Profile
// and what to set the speed of the voice (1-10) - used in Tasker Profile
// note the format that the message needs be in is parameter1 parameter2 parmeter3 =:= message
url = url + "openhab%205%205%20=:=" + Response.state.toString.encode("UTF-8")

// if the LogInfo flag is set on the send the url to the log for diagnostic purposes
if (LogInfo.state == ON) { logInfo("autoremote", url) }

// finally send the url 
sendHttpGetRequest(url)

Here is the description of the Profile from Tasker. Note I added a beep in the task to alert me of the incoming message. I will probabily tweek this in the future

Profile: Event Message From openHAB (11)
Event: AutoRemoteLite [ Configuration:openhab ]
Enter: Say Notification (3)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Say [ Text:%arcomm Engine:Voice:com.google.android.tts:eng-usa Stream:3 Pitch:%param2 Speed:%param3 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ]

1 Like

Each of my Android tablets has internet, but I rather messages from OpenHab to my tablets stay on the private network. Is there a way to have OpenHab signal Tasker to say something without going through a 3rd party like autoremote?