Modified localtuya for Liectroux ZK901 and Alfawise V10 vacuums

This is a unfinished integration for Liectroux ZK901 and his white label cousins. It branched from the open PR for vacuum implementation that localtuya guys should release soon. Comparing to the original PR, this one has to take status updates from DP 102 base 64 encoded data.

https://github.com/pratesbh/localtuya


Sample YAML configuration:

localtuya:
  - host: <ip address>
    device_id: <device id>
    local_key: <local key>
    friendly_name: Maradona
    protocol_version: "3.3"
    entities:
      - platform: vacuum
        friendly_name: Maradona
        id: 1
        commands_set: "smart,stop,chargego"
        commands_dp: 3
        idle_status_value: "dormant,idle,pause,fault"
        returning_status_value: "backcharge"
        docked_status_value: "fullcharge, charge"
        battery_dp: 5
        cleaning_mode_dp: 3
        cleaning_modes: "smart,random,spiral,wall_follow"
        fan_speed_dp: 3
        fan_speeds: "quiet,auto,strong"

To Do

  • Fix heartbeat code. While I don’t know why vacuum don’t answer sometimes, the reconnect interval was reduced and device status is kept constantly online.
  • Implement additional commands (zone cleaning, spot cleaning, fan control…). Please note that only “total cleaning” and “return to base” commands on DP 3 are working at this moment. I’m not sure, but maybe other commands should be sent to a different DP, probably encoded on base 64.
  • Not related to this integration, but looking to update the vacuum position in the floorplan based on its X,Y position.

ps:LocalKey and device ID from your vacuum is needed. There are many tutorials on how to get such info on the web. I recommend to install “Laser Robot” app on Bluestacks, start an ADB shell and run “logcat | grep localKey” while opening the app. Please note that Laser Robot app can work simultaneously with this this integration.

Big thanks for it.
Can you help with integration?
I have tried HA from 2021.8.0 to the last.
I tried get Key from logcat, dev account tuya and tuya smart app (it changed and I updated config every time). But every time I get this error.

I have newly installed HA Core and copy your fork to custom_components.
On start I have this error.

2021-09-26 22:20:55 ERROR (MainThread) [custom_components.localtuya.common] [bfd...abi] Connect to addr:172.16.95.109 failed
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/localtuya/common.py", line 139, in _make_connection
    self._interface = await pytuya.connect(
  File "/home/homeassistant/.homeassistant/custom_components/localtuya/pytuya/__init__.py", line 637, in connect
    _, protocol = await loop.create_connection(
  File "/usr/local/opt/python-3.8.7/lib/python3.8/asyncio/base_events.py", line 986, in create_connection
    infos = await self._ensure_resolved(
  File "/usr/local/opt/python-3.8.7/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/local/opt/python-3.8.7/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/opt/python-3.8.7/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/opt/python-3.8.7/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

I found some error.
I don’t know why but there is wrong address set. If i change it in VSCode debuging time all begins work well.
My config the same as yours

localtuya:
  - host: 172.16.95.109
    device_id: <>
    local_key: <>
    friendly_name: Sweepe
    protocol_version: "3.3"

Where “addr:” was added? =(