This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to

This forum is now read-only for archive purposes.

Get result through ask

So I finally got a homey and started playing with it this week.

Currently I'm playing with the speech api to attempt a simple dialog between Homey and the user. The triggers work and Homey responds, but when I use the ask method to ask a question and expect a result the result comes back empty.
speech.ask('What is the airspeed of a swallow?', function (e, r) {
Homey.log("Answer: '" + r + "'.");
When running I hear the Homey ask the question, the ring turn yellow which seems to respond to my voice. But the log message is actually "Answer: ' '." no matter what I say in what any language. Am I missing something?


  • Hi,  I think the variabele r is an object (probably a Homey speech object). Have you tried logging r itself (instead of trying to convert it to a string). 
  • From the docs: 

    Homey.manager('speech-input').on('speech', function( speech, callback ) { speech.ask('What is your name?', function( err, result ) { if( err ) return Homey.error(err); // result is the transcript of the user, in this case it might be `Mike` }); });

    if r is empty then it means that e should be filled with some data. And also what does r return when you log it this way? Is it just an empty string or [Object] ? 
  • There doesn't seem to be an error. I changed the callback code to

    Homey.log("Error: '" + err + "'.")
    if (err) return Homey.error(err);
    Homey.log("Answer: '" + result + "'.");

    And now the result is:

    1/4 - Archiving...
    2/4 - Uploading to Homey @
    3/4 - Running `xx.xxxx.xxxxxxx`, press CTRL+C to abort...
    4/4 - Debugging...
    Hello world!
    Answer: ''.
    Error: 'null'.

    The empty line appears to be the direct log statement.

  • I added lodash to the project so I could examine the result better.
    Homey.log("Null: " + _.isNull(result));
    Homey.log("Undefined: " + _.isUndefined(result));
    Homey.log("Empty: " + _.isEmpty(result));
    Homey.log("String: " + _.isString(result));
    Homey.log("NaN: " + _.isNaN(result));
    Homey.log("Error: " + _.isError(result));
    Homey.log("Is err null? " + _.isNull(err));
    Null: false
    Undefined: false
    Empty: true
    String: true
    NaN: false
    Error: false
    Is err null? true
    So it seems the result is really an empty string and there is no err value. Any ideas?
Sign In or Register to comment.