From 53b60aca3e3bc5d6e4235f160ce42d88a4a82b40 Mon Sep 17 00:00:00 2001 From: raphael1688 <51769889+raphael1688@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:54:25 +0800 Subject: [PATCH 1/3] Create .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3f9f384d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +controller.py From 5fd234f00fa24b686b4b642677dacd79cbb9ca8d Mon Sep 17 00:00:00 2001 From: raphael1688 <51769889+raphael1688@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:59:03 +0800 Subject: [PATCH 2/3] Update controller.py Remove "\" from JSON data of command when using MQTT. --- custom_components/smartir/controller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/smartir/controller.py b/custom_components/smartir/controller.py index 30758f62..27e14a5e 100644 --- a/custom_components/smartir/controller.py +++ b/custom_components/smartir/controller.py @@ -142,6 +142,8 @@ def check_encoding(self, encoding): "by the mqtt controller.") async def send(self, command): + _original = command + _command = _original.replace("\\", "") """Send a command.""" service_data = { 'topic': self._controller_data, @@ -183,4 +185,4 @@ async def send(self, command): service_data = {'command': json.loads(command)} await self.hass.services.async_call( - 'esphome', self._controller_data, service_data) \ No newline at end of file + 'esphome', self._controller_data, service_data) From 7b0987794bbd2611744f23f38b0bfc9f9080fc5f Mon Sep 17 00:00:00 2001 From: raphael1688 <51769889+raphael1688@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:00:07 +0800 Subject: [PATCH 3/3] Update controller.py --- custom_components/smartir/controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/smartir/controller.py b/custom_components/smartir/controller.py index 27e14a5e..c6e49cda 100644 --- a/custom_components/smartir/controller.py +++ b/custom_components/smartir/controller.py @@ -147,7 +147,7 @@ async def send(self, command): """Send a command.""" service_data = { 'topic': self._controller_data, - 'payload': command + 'payload': _command } await self.hass.services.async_call(