public function togglepower() { $state = $this->state->Get($this->StateStorage); $toggle = false; if (strpos($this->triggered['keywords'], '9c6651f707ba0cf8f8dcbe9329ff8cb8') !== FALSE) { if ($state['power'] == 1) { $toggle = 'OFF'; $state['power'] = 0; } else { $toggle = 'ON'; $state['power'] = 1; } } if (Prompt::MatchAnswer(array('on'), $this->triggered['keywords']) && $state['power'] == 0 || $toggle == 'ON') { shell_exec("sudo irsend SEND_ONCE " . $this->Device . " KEY_POWER KEY_POWER"); if ($this->speak) { TTS::Speak("Turning TV On"); } $state['power'] = 1; } elseif (Prompt::MatchAnswer(array('off'), $this->triggered['keywords']) && $state['power'] == 1 || $toggle == 'OFF') { if ($this->speak) { TTS::Speak("Turning TV Off"); } $state['power'] = 0; shell_exec("sudo irsend SEND_ONCE " . $this->Device . " KEY_POWER KEY_POWER"); } //Add toggle capability $this->state->Set($this->StateStorage, $state); }
public function prompt_read_email_subject($message) { if (Prompt::MatchAnswer(Prompt::$Yes, $message)) { echo "Prompt Response: Yes\n"; $responses = array("Okay. Downloading emails.", "Sure thing. Give me a second to fetch your emails", "Please wait while I load your emails", "Sure. Downloading your emails now."); if ($this->speak) { TTS::Speak($responses); } $this->read_new_email_subject(); Prompt::Clear(); shell_exec("sudo /etc/init.d/SAM stopquitely"); } elseif (Prompt::MatchAnswer(Prompt::$No, $message)) { //$Prompt = Prompt::Get(); echo "Prompt Response: No\n"; $responses = array("Okay", "Dont forget to read them later", "Ok just call me if you need anything else", "Great! i cant read properly anyway"); if ($this->speak) { TTS::Speak($responses); } Prompt::Clear(); shell_exec("sudo /etc/init.d/SAM listenquitely"); } else { echo "Not the answer im looking for!"; } }
/** * Power Subwoofer */ public function power_subwoofer() { $state = $this->state->Get('AVR'); $toggle = false; if (strpos($this->triggered['keywords'], 'ffb8c7c5755626f0d56076c0cb60292a') !== FALSE) { if ($state['subwoofer'] == 1) { $toggle = 'OFF'; } else { $toggle = 'ON'; } } if (Prompt::MatchAnswer(array('on'), $this->triggered['keywords']) && $state['subwoofer'] == 0 || $toggle == 'ON') { if ($this->speak) { TTS::Speak("Turning Subwoofer On"); } $state['subwoofer'] = 1; } elseif (Prompt::MatchAnswer(array('off'), $this->triggered['keywords']) && $state['subwoofer'] == 1 || $toggle == 'OFF') { if ($this->speak) { TTS::Speak("Turning Subwoofer Off"); } $state['subwoofer'] = 0; } //var_dump($this->triggered['keywords']); $this->state->Set('AVR', $state); }