samsung-tv-ws-api icon indicating copy to clipboard operation
samsung-tv-ws-api copied to clipboard

[TODO] Add text support

Open xchwarze opened this issue 2 years ago • 0 comments

taken from https://github.com/roberodin/ha-samsungtv-custom/blob/master/custom_components/samsungtv_custom/samsungctl_080b/remote_websocket.py

    def _serialize_string(string):
        if isinstance(string, str):
            string = str.encode(string)

        return base64.b64encode(string).decode("utf-8")
    def input_text(self, text):
        """
        {
            "method":"ms.remote.control",
            "params":{
                "Cmd":base64.b64encode,
                "TypeOfRemote":"SendInputString",
                "DataOfCmd":"base64",
            }
        }
        """

        params = dict(
            Cmd=self._serialize_string(text),
            TypeOfRemote="SendInputString",
            DataOfCmd="base64"
        )

        self.send('ms.remote.control', **params)

xchwarze avatar Mar 19 '22 18:03 xchwarze