[Custom Component] Roborock communication

@jd89 for users that use HassOS, they can’t easily install Node or NPM. Is it possible to build a Dockerfile into the plugin to install these…in a similar way that the new AppleTV component does ?

I removed python miio and reinstalled your repo via hacs
but now it says
Unable to prepare setup for platform roborock.vacuum: Platform not found (No module named ‘miio’).

Hey, shouldnlt need to do that!

How are you adding the vacuum? Doing it via integrations->Roborock?

Not really familiar with docker to be honest.

Is it not possible just to connect to the docker, and run apt install node / apt install npm ?

HassOS doesn’t give you access to the host OS.

No. Containers are immutable, the content is kinda reset on a restart.

That’s why I created a docker file that pulls the official Home Assistant Container and adds npm

thats my Dockerfile:

from homeassistant/home-assistant:stable
RUN apk add --update nodejs npm

that I run with this script:

#!/bin/bash
docker build . --pull -t "ha_mit_npm"

and then use in this docker-compose.yaml to actually spin up HA:

version: '3'
services:
  homeassistant:
    container_name: home-assistant
    image: ha_mit_npm:latest
    # image: homeassistant/home-assistant:stable
    volumes:
      - ./config:/config
      - ./npm/.config:/root/.config
      - ./npm/.npm:/root/.npm
      - ./npm/.cache:/root/.cache
    environment:
      - TZ=Europe/Vienna
    restart: unless-stopped
    network_mode: host
    devices:
      - /dev/serial/by-id/usb-EnOcean_GmbH_EnOcean_USB_300_DB_FT3OIZSO-if00-port0:/dev/ttyACM0
1 Like

Ok cool, thanks for all the updates.

So if I was to put a docker file in the root, is there something I need to do to make it run when it gets installed / startup?

Yes, I added your custom repo in HACS, then restarted. went to integrations in HA, clicked on RoboRock, added the name, my IP, dev ID and Key. I received the following error

You indicated it may be trying to use the previous miio integration, so I removed everything and started over by re-installing your repo and then received this error

Ok. Cool, well I think you may need to add the original one back (sorry :))

For the code, I am not 100% sure, are you just using the code that you got when you followed the instructions to grab them via ADB?

Cheers

I may have made a mistake here, I think the Dockerfile in that component is for development purposes.

As a side note, I think I found where to put restart/shutdown logic in init.py.

async def async_setup_entry(hass, entry):

    @callback
    def on_hass_stop(event):
        """Logic for when hass stops."""
1 Like

Can you please explain how to extract the file? I grabbed it via root but can’t open or read it, I tried with notepad++ and a DB Browser with no luck (I couldn’t get the adb instruction to work either)

  • go to the roborock directory and manually cat the tuya file to /mnt/sdcard/roborock.gz

This is what I’m struggling with

Thank you

I mounted the virtual “sd card” in bluestacks and copied the file there.
then its accessible from the host.
its a gz file, so you need somethign that can unzip that.
or you open the json directly

1 Like

Thank for your reply, after pulling my hair our for a while I decised to look at the other files in the location and saw that for the s6Max it is a different file. And after reading here @ghvader found the same.

So I set up the integration but as others have mentioned, I’m using HassOs on a Pi (v 5.2 USB boot) And this integration doesn’t work due to missing dependancies.

So I will wait and hope that it can be updated to contain the necessary requirememts to run

I’m getting the same error as @bernhard

## Log Details (ERROR)

Logger: homeassistant.components.vacuum
Source: custom_components/roborock/vacuum.py:146
Integration: Vacuum ([documentation](https://www.home-assistant.io/integrations/vacuum), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+vacuum%22))
First occurred: 7:37:03 AM (1 occurrences)
Last logged: 7:37:03 AM

Error while setting up roborock platform for vacuum

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/roborock/vacuum.py", line 146, in async_setup_entry tuya_init(js_dir) File "/usr/local/lib/python3.8/site-packages/tuyapipc/__init__.py", line 106, in init Popen(['npm', 'install', 'tuyapi-ipc'], \ File "/usr/local/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'npm'

Yes of course as there is no NPM in the Container.
I honestly never got the idea why Hass OS is Chosen over regular docker containers if you have a clue what you are doing. It blocks more than it helps.
If you move to a Debian or raspian installation on your host and use docker containers, you can easily modify those as needed.

@Craig_Burton If you look at the json file, the last value says “tuya_migrated:false” jd89 and I suspect that the s6’s (at least not the s6 Max V) have not been moved to the Tuya platform yet, thus his wrapper will not work since it’s using the Tuya API. our only options at this point are 1) go back to the miio integration with the mi home app and give up on the roborock app 2) wait until it’s moved to the Tuya platform or 3) hope someone figures out another approach.

1 Like

One should be able to make a Docker Container with node which takes on the tuya communication in itself - this can then be added to the AddOn Store with a custom repository this would make it run on HassOs easily too.

I’m happy to provide you guys with this container but unfortunately I also own the S6Vmax which apparently does not work yet - "TuyaMigrated":false

my guess would be that they’re using some proprietary modification of the tuya implementation to protect the platform being tampered with because it has the camera feature which could potentially be a big security concern

1 Like

Sorry for delay. Been moving house.

For docker, yeh, I wonder if I can just add a script that installs node automatically as part of config flow, and integration startup.

For S6vmax. It is hard for me to work out how it does its communications without the machine in front of me. I know where I would need to look in the APK, but other than that, it is a bit of a struggle…

1 Like

I can provide you with everything you need to poke it remotely - tell me when you are open to have a look

How did you get Roborock apk installed on Bluestacks, I am getting
INSTALL_FAILED_CPU_ABI_INCOMPATIBLE
error

I can have a look at my Bluestacks Settings end of week when I am back home. Iguess it has to do with the model youngish to emulate?