diary at Telent Netowrks

Yes You! I'm talking tuya#

Mon, 14 Dec 2020 22:31:19 +0000

A very short entry today as it's already bedtime, but I would like to note that I have followed all the Tuyapi instructions and can now turn my Christmas tree lights on and off from the command line.

First impressions: seems to work. There are occasional "Timeout waiting for status response from device id" errors, which seem to happen mostly if I try doing two `set` operations without an intervening `get`. I don't yet know the technical details of how it works, but I do find it interesting that (according to strace) it seems to be talking directly to the device instead of to a cloud server:

socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 20
connect(20, {sa_family=AF_INET, sin_port=htons(6668), sin_addr=inet_addr("192.168.8.84")}, 16) = -1 EINPROGRESS (Operation now in progress)
epoll_ctl(13, EPOLL_CTL_ADD, 14, {EPOLLIN, {u32=14, u64=14}}) = 0
epoll_ctl(13, EPOLL_CTL_ADD, 16, {EPOLLIN, {u32=16, u64=16}}) = 0
epoll_ctl(13, EPOLL_CTL_ADD, 20, {EPOLLOUT, {u32=20, u64=20}}) = 0
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 0) = 1
read(16, "\1\0\0\0\0\0\0\0", 1024)      = 8
epoll_wait(13, [{EPOLLOUT, {u32=20, u64=20}}], 1024, 4997) = 1
getsockopt(20, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
write(20, "\0\0U\252\0\0\0\1\0\0\0\n\0\0\0\210\234\0\334\351T\302\30\17%\31H\351\36\306\24\312"..., 152) = 152

I wonder if Tuya Haskell bindings exist.