Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Stuck in a question for next request #467

Open
maciekish opened this issue Mar 3, 2013 · 3 comments
Open

Stuck in a question for next request #467

maciekish opened this issue Mar 3, 2013 · 3 comments
Assignees

Comments

@maciekish
Copy link

Hi,
I have set siriproxy to control my tellstick net. If i ask it to "Set the kitchen light to 50%", it will do so and ask if i want it any darker or brighter. If i respond to that, everything is nice and dandy. If i just lock my phone without anwering her question, and unlock it a moment later and say something else like "Turn the kitchen light off", she will respond as if i had answered the previous question (She will say "Happy to be of service", instead of turning the light off).

So my question is, how do i "cancel" the question after inactivity/phone lock?

Here is the code:

listen_for /set(?: the)? ([a-z])(?: to)? ([0-9])(?: %)*/i do |light_name, value|
light_name = light_name.strip
print value + "\n"

value_original = String.new(value)
value = value.strip.to_f / 100.0
value = value * 255.0
light_id = get_light(light_name)

if (light_id.nil?)
  say "You dont have a " + light_name + " light."
else
  if (dim(light_id, value))
    value = value / 255.0
    value = value * 100.0
    response = ask "I have set the " + light_name + " light to " + value.to_s[0...-2] + "%, Do you want it any brighter or darker?"

    if (response =~ /dark/i)
      say "Okay, i made it a little darker."
      value = value_original.strip.to_f / 100.0
      value = (value * 255.0) - 50
      dim(light_id, value)
    elsif (response =~ /bright/i or response =~ /lighter/i )
      say "Okay, i made it a little brighter."
      value = value_original.strip.to_f / 100.0
      value = (value * 255.0) + 50
      dim(light_id, value)
    else
      say "Happy to be of service."
      request_completed
    end
  else
    say "I couldnt set the dimmer for the " + light_name + ", sorry about that."
    request_completed
  end
end

request_completed

end

@bgottsch
Copy link

bgottsch commented Mar 3, 2013

its a problem with the plugins execution on the SiriProxy server. I think that if you send a request_completed after you lock it or after a timeout it should work. Im not sure about it. Im having the same problem but i'm trying to figure it out. I have discovered that Apple uses callbacks to resolve some of this issues. I'll post if a have progress.

@plamoni
Copy link
Owner

plamoni commented Mar 4, 2013

I agree with @bgottsch... I think that your best bet might be to set up a worker thread when you ask the question and if they don't respond in like 10 seconds you can issue a request_completed.

Might not hurt to add a timeout to ask, but I think it lives in @chendo's cora code.

@ghost ghost assigned chendo Mar 4, 2013
@maciekish
Copy link
Author

Is it possible for you to provide a simple example of how to set up the worker thread after asking a question please? I'm very new to this language.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants