コード例 #1
0
 def _process_volume(cmd, att):
     if isinstance(att, (str,)):
         att = att.strip()
     if att == CMD_PRESS:
         hdmi_network.send_command(KeyPressCommand(cmd, dst=ADDR_AUDIOSYSTEM))
     elif att == CMD_RELEASE:
         hdmi_network.send_command(KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
     else:
         att = 1 if att == "" else int(att)
         for _ in range(0, att):
             hdmi_network.send_command(KeyPressCommand(cmd, dst=ADDR_AUDIOSYSTEM))
             hdmi_network.send_command(KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
コード例 #2
0
 def send_keypress(self, key):
     """Send keypress to CEC adapter."""
     _LOGGER.debug(
         "Sending keypress %s to device %s", hex(key), hex(self._logical_address)
     )
     self._device.send_command(KeyPressCommand(key, dst=self._logical_address))
     self._device.send_command(KeyReleaseCommand(dst=self._logical_address))
コード例 #3
0
ファイル: hdmi_cec.py プロジェクト: yottatsa/home-assistant
 def _volume(call):
     """Increase/decrease volume and mute/unmute system."""
     mute_key_mapping = {ATTR_TOGGLE: KEY_MUTE_TOGGLE, ATTR_ON: KEY_MUTE_ON,
                         ATTR_OFF: KEY_MUTE_OFF}
     for cmd, att in call.data.items():
         if cmd == CMD_UP:
             _process_volume(KEY_VOLUME_UP, att)
         elif cmd == CMD_DOWN:
             _process_volume(KEY_VOLUME_DOWN, att)
         elif cmd == CMD_MUTE:
             hdmi_network.send_command(
                 KeyPressCommand(mute_key_mapping[att],
                                 dst=ADDR_AUDIOSYSTEM))
             hdmi_network.send_command(
                 KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM))
             _LOGGER.info("Audio muted")
         else:
             _LOGGER.warning("Unknown command %s", cmd)
コード例 #4
0
 def power_on_devices(self):
     self.transmit(KeyPressCommand(KEY_POWER))
     self.transmit(KeyReleaseCommand())
コード例 #5
0
ファイル: cec.py プロジェクト: rajlaud/pyCEC
 def set_command_callback(self, callback):
     self._cecconfig.SetKeyPressCallback(
         lambda key, delay: callback(KeyPressCommand(key).raw))
     self._cecconfig.SetCommandCallback(callback)