parameters: (self, source_key)
return_statement: return True
docstring: Manage the SmartThings key commands.
docstring_summary: Manage the SmartThings key commands.
docstring_tokens: Manage the SmartThings key commands .
function: async def _smartthings_keys(self, source_key):
          """Manage the SmartThings key commands."""
          if not self._st:
              _LOGGER.error("SmartThings not configured. Command not valid: %s", source_key)
              return False
          if self._st.state != STStatus.STATE_ON:
              _LOGGER.warning("SmartThings not available. Command not sent: %s", source_key)
              return False
  
          if source_key.startswith("ST_HDMI"):
              await self._st.async_select_source(source_key.replace("ST_", ""))
          elif source_key == "ST_TV":
              await self._st.async_select_source("digitalTv")
          elif source_key == "ST_CHUP":
              await self._st.async_send_command("stepchannel", "up")
          elif source_key == "ST_CHDOWN":
              await self._st.async_send_command("stepchannel", "down")
          elif source_key.startswith("ST_CH"):
              ch_num = source_key.replace("ST_CH", "")
              if ch_num.isdigit():
                  await self._st.async_send_command("selectchannel", ch_num)
          elif source_key == "ST_MUTE":
              await self._st.async_send_command(
                  "audiomute", "off" if self._muted else "on"
              )
          elif source_key == "ST_VOLUP":
              await self._st.async_send_command("stepvolume", "up")
          elif source_key == "ST_VOLDOWN":
              await self._st.async_send_command("stepvolume", "down")
          elif source_key.startswith("ST_VOL"):
              vol_lev = source_key.replace("ST_VOL", "")
              if vol_lev.isdigit():
                  await self._st.async_send_command("setvolume", vol_lev)
          else:
              _LOGGER.error("Unsupported SmartThings command: %s", source_key)
              return False
          return True
function_tokens: async def _smartthings_keys ( self , source_key ) : if not self . _st : _LOGGER . error ( "SmartThings not configured. Command not valid: %s" , source_key ) return False if self . _st . state != STStatus . STATE_ON : _LOGGER . warning ( "SmartThings not available. Command not sent: %s" , source_key ) return False if source_key . startswith ( "ST_HDMI" ) : await self . _st . async_select_source ( source_key . replace ( "ST_" , "" ) ) elif source_key == "ST_TV" : await self . _st . async_select_source ( "digitalTv" ) elif source_key == "ST_CHUP" : await self . _st . async_send_command ( "stepchannel" , "up" ) elif source_key == "ST_CHDOWN" : await self . _st . async_send_command ( "stepchannel" , "down" ) elif source_key . startswith ( "ST_CH" ) : ch_num = source_key . replace ( "ST_CH" , "" ) if ch_num . isdigit ( ) : await self . _st . async_send_command ( "selectchannel" , ch_num ) elif source_key == "ST_MUTE" : await self . _st . async_send_command ( "audiomute" , "off" if self . _muted else "on" ) elif source_key == "ST_VOLUP" : await self . _st . async_send_command ( "stepvolume" , "up" ) elif source_key == "ST_VOLDOWN" : await self . _st . async_send_command ( "stepvolume" , "down" ) elif source_key . startswith ( "ST_VOL" ) : vol_lev = source_key . replace ( "ST_VOL" , "" ) if vol_lev . isdigit ( ) : await self . _st . async_send_command ( "setvolume" , vol_lev ) else : _LOGGER . error ( "Unsupported SmartThings command: %s" , source_key ) return False return True