Making the Lefant LS1 a good citizen with LocalTuya
Following on from lamps doing strange things, the next device I noticed that was being noisy on the network was our robot vacuum. It also phones home very regularly, but only at about 1 request per second, much more sensible (not). The vacuum we bought is the Lefant LS1. It seems to only be available on Amazon and has no other support or info on it, so not a good start. It works out if it has work to do by polling Tuya, and only gets one 'go ahead' instruction a day when it sets off for its morning clean. That's a lot of wasted requests that don't end in something to do.
This vacuum is the last thing that isn't integrated into Home Assistant, and it'd be oh so very nice if everything was under one panel, so off I go trawling the internet to see if anyone's done it before. There's a native Tuya integration which I'd used in the past, but that still results in the vacuum polling which is what I'm trying to avoid. There is a custom integration though called LocalTuya
, which looks very promising.
LocalTuya
pretends to be Tuya by throwing broadcast packets across the network that imitate Tuya itself, so the vacuum doesn't need to phone home every second because it's just been told what's going on anyway. The only downside to LocalTuya
is that you have to configure everything about your devices yourself. Tuya has the idea of 'DP's (datapoints
), which map to controls or statuses on the device itself. LocalTuya
can detect the existence of a device, but you still need the device's local_key
to actual control it. This can be found by doing Home Assistant's usual Tuya process and poking their API at General Devices Management -> Get Device Information
.
Once I had the local_key
, LocalTuya
could connect and talk to the device over LAN instead of going out to the internet every time! But I still had to map what the device was reporting with what LocalTuya
could control. This list is at the end for anyone who might find it useful.
The end result is that we have vacuums showing up in Home Assistant, scheduled through automations like everything else, and generally behaving very well!
LocalTuya field | LS1 DP or value |
---|---|
Idle status | standby,sleep |
Power DP | 1 |
Docked status | charging,charge_done |
Returning status | goto_charge |
Battery status DP | 8 |
Mode DP | 4 |
Modes list | smart,chargego,zone,pose |
Return home mode | chargego |
Fan speeds DP | 9 |
Fan speeds list | gentle,normal,strong |
Clean time DP | 6 |
Clean area DP | 7 |
Locate DP | 11 |
Fault DP | 28 |
Pause state | paused |
Stop status | chargego |