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

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Closed

Ask multiple questions

Hi, 

I'm currently trying to build an app that requires me to let Homey ask the user several questions after each other. I'm currently running into an issue where the second question's callback is triggered without a result ( and no error ) before I have time to answer it. 

My gues is that the callback of the previous question is triggered becuase the timeout of 10 seconds has expired. I have the following pseudo code


Homey.manager('speech-input').ask('Vraag 1',function(err,result){
   Homey.log('asking first question');
   Homey.log(result); 
   if(result != ""){
      Homey.manager('speech-input').ask('vraag 2',function(err,result){ 
        Homey.log('Answer to second question');
        Homey.log(result); 

     });
   }
});

What happens is the following |

- asking the first question
- answer 1
- asking the second question


In other words the last answer is directly returned as an empty string and I can not answer it myself. Is this a bug? And if not how to solve?

Comments

  • Try using a different variable name inside the second ask call (so not result)
  • jjtbsomhorstjjtbsomhorst Member
    edited October 2016
    Does not work. The following code executes almost instantly the second ask callback instead of waiting for user input

        Homey.manager('speech-input').ask('Yum Yum??',function(err,result1){
            if(result1 != "" && result1 != null){
                Homey.log(result1);
                Homey.manager('speech-input').ask('Yam Yam?',function(err2,result2){
                    Homey.log(result2);
                });
            }
        });

    I noticed that the led ring is also orange (and stays that way) after the question sequence has started. 
  • casedacaseda Member
    edited October 2016
    and what if you take the 2nd question outside of the 1st ones' loop:

        Homey.manager('speech-input').ask('Yum Yum??',function(err,result){
            if(result){
                Homey.log(result);
                asksecond(result); // you can leave the result out of here if you don't need it in 2nd question
            }
        });
        var asksecond = function (result1) {
            Homey.manager('speech-input').ask('Yam Yam?',function(err,result){
                Homey.log(result);
            });
        };


  • jjtbsomhorstjjtbsomhorst Member
    edited October 2016
    When I ask the second question directly that answer is also returned. But when I wait a bit the result is empty and I can't answer the question anymore. I'm using the /manager/speech-input page now to test but in a real situation I would expect the user to wait a bit before answering and therefore this second question will always fail
  • and what if you add a small timeout (delay) to the 2nd call?
  • something like settimeout? or 
  • yeah, that's what i mean with a timeout
  • Just did some testing with timeout and stuff but nothing seems to be working. Maybe someone from Athom can help us out here?

This discussion has been closed.