def get_data(self, handler_input):
     return {
         "duration":
         utils.get_slot_value(handler_input, 'duration',
                              'PT30S'),  # 30 seconds
         "direction":
         utils.get_slot_value(handler_input, 'direction', 'forward')
     }
 def get_data(self, handler_input):
     params = [
         'play', 'app', 'room', 'title', 'song', 'album', 'artist',
         'playlist', 'tvshow', 'movie'
     ]
     result = {
         param:
         utils.get_slot_value(handler_input, param, '').lower().replace(
             'the playlist', '').replace('the album', '').replace(
                 'the tv show', '').replace('the show', '').replace(
                     'the t. v. show', '').replace('the t. v. series', '')
         for param in params
         if utils.get_slot_value(handler_input, param, '')
     }
     return result
Beispiel #3
0
    def handle(self, handler_input):
        room = utils.get_slot_value(handler_input, 'room', False)
        device_id = handler_input.request_envelope.context.system.device.device_id

        if not room:
            room = utils.get_persistent_session_attribute(handler_input, 'DEVICE_'+device_id, False)
            if not room:
                speak_output = 'I need to set the room of the Chromecast that this Alexa device will control. Please say something like: set room to media room.'
                return (
                    handler_input.response_builder
                        .speak(speak_output)
                        .ask('Please set the Chromecasts room, by saying something like: set room to media room.')
                        .set_card(ui.SimpleCard(CARD_TITLE, speak_output))
                        .response
                )

        try:
            data = self.get_data(handler_input)
            self.publish_command_to_sns(room, self.get_action(), data)
            speak_output = self.get_response(data)
            return (
                handler_input.response_builder
                    .speak(speak_output)
                    .set_card(ui.SimpleCard(CARD_TITLE, speak_output))
                    .response
            )
        except SNSPublishError as error:
            logger.error('Sending command to the Chromecast failed', exc_info=error)
            speak_output = 'There was an error sending the command to the Chromecast'
            return (
                handler_input.response_builder
                    .speak(speak_output)
                    .set_card(ui.SimpleCard(CARD_TITLE, speak_output))
                    .response
            )
Beispiel #4
0
 def handle(self, handler_input):
     device_id = handler_input.request_envelope.context.system.device.device_id
     room = utils.get_slot_value(
         handler_input,
         'room')  # Must have a value enforced by Alexa dialog
     utils.set_persistent_session_attribute(handler_input,
                                            'DEVICE_' + device_id, room)
     handler_input.attributes_manager.save_persistent_attributes()
     speak_output = 'Ok, this Alexa device will control the Chromecast in the %s. To control another room you can say something like: Alexa, play in the media room.' % room
     return (handler_input.response_builder.speak(speak_output).set_card(
         ui.SimpleCard(CARD_TITLE, speak_output)).response)
Beispiel #5
0
 def get_data(self, handler_input):
     #TODO: Support other apps in the future
     return {
         "title": utils.get_slot_value(handler_input, 'video'),
         "app": 'youtube'
         }
Beispiel #6
0
 def get_data(self, handler_input):
     return {"title": utils.get_slot_value(handler_input, 'movie')}
Beispiel #7
0
 def get_data(self, handler_input):
     volume = int(utils.get_slot_value(handler_input, 'volume'))
     if volume > 10 or volume < 0:
         return "Sorry, you can only set the volume between 0 and 10."
     return {"volume": volume}
Beispiel #8
0
 def get_data(self, handler_input):
     return {"app": utils.get_slot_value(handler_input, 'app')}
 def get_data(self, handler_input):
     params = ['epnum', 'seasnum', 'title', 'tvshow']
     return {
         param: utils.get_slot_value(handler_input, param, '')
         for param in params
     }
 def get_data(self, handler_input):
     return {
         "duration": utils.get_slot_value(handler_input, 'duration', '')
     }