Hi
I’m trying to create a switch to turn a device on and off (H801 LED controller).
The command line i’m using works just fine, when I use it directly on a command line, but nothing happens when I try to use it as a switch with HomeAssistant.
The command used sends 11 bytes to the device (I got the byte sequence from wireshark), so I can’t just remove the null bytes.
Here is the config:
platform: command_line
switches:
bookcase_light:
command_on: "echo -ne '\xfb\xeb\x00\x17\x00\xc8\xaf\xb3\xb0\x1a\x00' | nc -w1 -u -p 30978 -s 10.0.3.23 10.0.3.109 30977"
command_off: "echo -ne '\xfb\xeb\x00\x00\x00\x00\x00\xb3\xb0\x1a\x00' | nc -w1 -u -p 30978 -s 10.0.3.23 10.0.3.109 30977"
friendly_name: Bookcase Light
and the error from HASS whenever I try to use the switch:
2017-07-12 18:40:40 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 181, in _step
result = coro.throw(exc)
File "/usr/src/app/homeassistant/core.py", line 1023, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/src/app/homeassistant/components/switch/__init__.py", line 105, in async_handle_switch_service
yield from switch.async_turn_on()
File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
future.result()
File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
raise self._exception
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/app/homeassistant/components/switch/command_line.py", line 149, in turn_on
if (CommandSwitch._switch(self._command_on) and
File "/usr/src/app/homeassistant/components/switch/command_line.py", line 85, in _switch
success = (subprocess.call(command, shell=True) == 0)
File "/usr/local/lib/python3.6/subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/local/lib/python3.6/subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.6/subprocess.py", line 1260, in _execute_child
restore_signals, start_new_session, preexec_fn)
ValueError: embedded null byte