I just bought some china smartlights from aliexpress that i hoped i was able to flash tasmota firmware. But it seems like TechLife Pro is another app, and not based on tuya cloud.
The bulbs are available from here: Amtoo bulb
Anyway, i installed the app and paired up the bulbs and started tcpdump on my router to find out how this worked. It turnes out that its using mqtt, and the bulbs subscribe to a topic on their server.
After some research and alittle help from a friend, we figured out that they connect to an mqtt server.
Works very well and fast. But now i want to figure out how the dimming works. I can ofc hardcode 4-5 different states, but i really wanted to be able to controll from 0-100%. But i cannot figure it out.
I found this document but it dosent seem to be the same protocoll.
Thanks for this, I am interested in trying to debug these bulbs too.
I am having some trouble being able to get started debugging the messages. When I tried a tcpdump on my wireless network I was not able to observe the messages you are seeing. Do you have any tips to get started?
i ran the tcpdump on my router. Saved the files if you want to take a look at them?
But i was thinking i should get some more samples, so i can “hardcode” dimming in steps of 10. For instance this is the lowest lightsetting:
echo -en “\x28\x00\x00\x00\x00\x00\x00\x64\x00\x00\x00\x00\x01\xf0\x95\x29” | mosquitto_pub -t ‘dev_sub_xx:xx:xx:xx:xx:xx’ -s
And the highest:
echo -en “\x28\x00\x00\x00\x00\x00\x00\x11\x27\x00\x00\x00\x64\xf0\xa2\x29” | mosquitto_pub -t ‘dev_sub_xx:xx:xx:xx:xx:xx’ -s
You can probably send that to their mqtt server if you dont want to run your own
So i decided to try to integrate this in openhab using a switch and a dimmer.
Itemfile as follows:
// Kina lysene fra ali
Group gKinaKontorLys "Kinalys1" <light> (gKontor, gItems)
Switch kinaKontorLys "Kinalys1 switch" <light> (gKinaKontorLys)
Dimmer kinaKontorDimmer "Kina1Dimmer" (gKinaKontorLys)
And i had to make a script to controll them + and rules file.
// kinalys 1 på kontor.
rule "kinalys1 switch on"
when Item kinaKontorLys changed to ON
then
logInfo("kina", "kinalys1 til på")
executeCommandLine("/etc/openhab2/misc/kinalys/lys1.sh on",10000)
end
rule "kinalys1 switch off"
when Item kinaKontorLys changed to OFF
then
logInfo("kina", "kinalys1 til av")
executeCommandLine("/etc/openhab2/misc/kinalys/lys1.sh off",10000)
end
rule "Kinalys1 dimmer mottatt"
when Item kinaKontorDimmer received update
then
logInfo("kina", "kinalys fikk " + kinaKontorDimmer.state )
executeCommandLine("/etc/openhab2/misc/kinalys/lys1.sh dim " + kinaKontorDimmer.state,10000)
end
And a little bashscript:
#!/bin/bash
t="dev_sub_xx:xx:xx:xx:xx:xx"
if [ "$1" != "" ]; then
if [ "$1" == "on" ]; then
echo -en "\xfa\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\xfb" | mosquitto_pub -t $t -s
elif [ "$1" == "off" ]; then
echo -en "\xfa\x24\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x24\xfb" | mosquitto_pub -t $t -s
elif [ "$1" == "dim" ]; then
if ((1<=$2 && $2<=10))
then
echo -en "\x28\x00\x00\x00\x00\x00\x00\x64\x00\x00\x00\x00\x01\xf0\x95\x29" | mosquitto_pub -t $t -s
elif ((11<=$2 && $2<=25))
then
echo -en "\x28\x00\x00\x00\x00\x00\x00\x36\x04\x00\x00\x00\x0a\xf0\xc8\x29" | mosquitto_pub -t $t -s
elif ((26<=$2 && $2<=50))
then
echo -en "\x28\x00\x00\x00\x00\x00\x00\x23\x0e\x00\x00\x00\x24\xf0\xf9\x29" | mosquitto_pub -t $t -s
elif ((51<=$2 && $2<=75))
then
echo -en "\x28\x00\x00\x00\x00\x00\x00\x89\x14\x00\x00\x00\x34\xf0\x59\x29" | mosquitto_pub -t $t -s
elif ((76<=$2 && $2<=100))
then
echo -en "\x28\x00\x00\x00\x00\x00\x00\x11\x27\x00\x00\x00\x64\xf0\xa2\x29" | mosquitto_pub -t $t -s
fi
fi
else
echo "Usage: "
echo "$0 on - turn on"
echo "$0 off - turn off"
echo "$0 dim % - dimmer"
fi
Alittle hackish, but it works like a charm. Note that its one way, so if something else (ie you run the script at the commandline), they wont be in sync.
But for me, who uses openhab to automaticly controll the lights this is working as intended.
And its very fast aswell!
I go a little deeper into the protocol and found how to control the level of brigtness more accurately.
Brightness level is unsigned short from 0 to 10000. Write it to 7 and 8 bytes in little endian format.
14th byte is checksum. For calculating just XOR all bytes from 1 to 13.
Well you need to tell your dnsserver to redirect that. Or override. it really depends on your setup. But basicly you need a caching nameserver or your own nameserver.
This is really impossible with ASUS RT-N18U, Windows and end users.
I want method which connect with smart bulb and replace his DNS server name in chip as that resolve TechLife Pro app.
This change must be trough AP-TechLife-??:??.
You know about this possibility?
This is really impossible with ASUS RT-N18U, Windows and end users.
I want method which connect with smart bulb and replace his DNS server name in chip as that resolve TechLife Pro app.
This change must be trough AP-TechLife-??:??.
You know about this possibility?
But if you can specify static ips in the dhcp server, i guess you can redirect it somewhere else? Ie your “fake” dns server.
I run pfsense, so it was no problem for me.
Small update. Since i dont want to implement all this logic in openhab, i have created it outside of openhab. After i got the code from Yaros i updated the bash script and created a c++ (very horrid) code.
Here is the new bash script:
#!/bin/bash
t="dev_sub_xx:xx:xx:xx:xx:bx"
if [ "$1" != "" ]; then
if [ "$1" == "on" ]; then
echo -en "\xfa\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\xfb" | mosquitto_pub -t $t -s
elif [ "$1" == "off" ]; then
echo -en "\xfa\x24\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x24\xfb" | mosquitto_pub -t $t -s
elif [ "$1" == "dim" ]; then
# Gang opp med 100.
d=$(expr $2 \* 100)
k=$(/etc/openhab2/misc/kinalys/ckinalys $d) ; echo -en $k | mosquitto_pub -t $t -s
fi
else
echo "Usage: "
echo "$0 on - turn on"
echo "$0 off - turn off"
echo "$0 dim % - dimmer"
fi
I think that, DNS server return IP address by name, but TechLife bulb use IP address and really DNS not return nothing. TechLife bulb used IP address of amazon MQTT server.
There might be some alternative that does not involve changing the board to an esp8266.
The SM02A module the lamp uses has an RDA5981 SoC. If there is an easy way to read and write to its flash, maybe we can change any reference to “cloud.qh-tek.com” so that it points to another name (it can be a name that resolves to an private IP, so that it’s easier to set up)
There is probably a mechanism for doing OTA updates. I tried doing a port scan but it seems like the device is not listening on any particular port.