Exemplo n.º 1
0
 def async_play_media(self, media_type, media_id, **kwargs):
     """Support changing a channel."""
     if media_type != MEDIA_TYPE_CHANNEL:
         _LOGGER.error('Unsupported media type')
         return
     try:
         cv.positive_int(media_id)
     except vol.Invalid:
         _LOGGER.error('Media ID must be positive integer')
         return
     # Hack to map remote key press
     # 2   Key "1"
     # 3   Key "2"
     # 4   Key "3"
     # 5   Key "4"
     # 6   Key "5"
     # 7   Key "6"
     # 8   Key "7"
     # 9   Key "8"
     # 10  Key "9"
     # 11  Key "0"
     for digit in media_id:
         if digit == '0':
             channel_digit = '11'
         else:
             channel_digit = int(digit) + 1
         self.request_call('/web/remotecontrol?command=' +
                           str(channel_digit))
Exemplo n.º 2
0
    def async_send_message(self, message="", **kwargs):
        """Send message."""
        try:
            displaytime = DEFAULT_DISPLAY_TIME
            messagetype = DEFAULT_MESSAGE_TYPE
            data = kwargs.get(ATTR_DATA) or {}
            if data:
                if 'displaytime' in data:
                    displaytime = data['displaytime']
                if 'messagetype' in data:
                    messagetype = data['messagetype']

            _LOGGER.debug("Enigma notify service: [async_send_message] - Sending Message %s \
                          (timeout=%s and type=%s", message, displaytime,
                          messagetype)
            self.request_call('/web/message?text=' +
                              message.replace(" ", "%20") + '&type=' +
                              messagetype + '&timeout=' + displaytime)
        except ImportError:
            _LOGGER.error("Enigma notify service: [Exception raised]")