def _send_keystroke(self, keystroke, wait=False): # Check if an IP address has been supplied, if it hasn't return false. if self.ip is None: return False # Make sure the TV is not already on, and then send keystroke return Control().send_keystrokes(self.ip, keystroke, wait)
def __init__(self, ip_address=None, source=None, initialized=True, assume_state=True): # Check if an IP address has been supplied to the constructor if ip_address is None: print('No TV supplied, hence it won\'t work') # Check if TV has been initialized for pymitv control if initialized is False: print('If the TV hasn\'t been setup for full pymitv control, \ using any of the polyfill controls, could produce weird results.') # Make IP address global regardless of value self.ip_address = ip_address # Make active source global self.source = source # Set assume_state self.assume_state = assume_state # Set volume self.volume = Control().get_volume(self.ip_address)
def change_source(self, source): """Change source of xiaomi tv""" # Check if an IP address has been supplied, if it hasn't return false. if self.ip_address is None: return False self.source = source return Control().change_source(self.ip_address, source)
def get_volume(self): """Get volume of xiaomi tv""" # Check if an IP address has been supplied, if it hasn't return false. if self.ip_address is None: return False self.volume = Control().get_volume(self.ip_address) return self.volume
def mute(self): """Mutes the TV.""" return Control().mute(self.ip) #def set_source(self, source): # """Selects and saves source.""" # self.source = source # route = Navigator(source=self.source).navigate_to_source(source) # print(route) # # return self._send_keystroke(route, wait=True)
def is_on(self): """Returns the assume state of the TV.""" if self.assume_state: return self.state return Control().check_state(self.ip_address)
def mute(self): """Mutes the TV.""" return Control().mute(self.ip_address)