/ha-prosenic

Prosenic Vacuum integration for Home Assitant

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

License

[DEPRECATED] Prosenic Home Assistant component

My prosenic vacuum broke and I bought a vacuum robot from a different manufacturer. I will archive this component and therefore also remove it from HACS. Feel free to fork it and take over.

A full featured Homeassistant component to control Prosenic vacuum cleaner locally without the cloud. This component is based on the underlying PyTuya library available here.

Towards Homeassistant official integration

My personal goal is to make this component fully compliant with Homeassistant, so that it may be added as the official library to handle Prosenic vacuum cleaners. However, before pushing a PullRequest to the official Homeassistant repository, I would like to share it to some users. In this way we can test it massively, check it for any bug and make it robust enough to be seamlessly integrated with Homeassistant.

Installation

You can install this component manually.

  1. Download the latest zip release archive from here (or clone the git master branch)

  2. Unzip/copy the prosenic direcotry within the custom_components directory of your homeassistant installation. The custom_components directory resides within your homeassistant configuration directory. In other words, the configuration directory of homeassistant is where the configuration.yaml file is located. After a correct installation, your configuration directory should look like the following. └── ... └── configuration.yaml └── secrects.yaml └── custom_components └── prosenic └── __init__.py └── const.py └── ...

    **Note**: if the custom_components directory does not exist, you need to create it.
    

Component setup

Once the component has been installed, you need to configure it in order to make it work. First we need to find out the device_id, ip address and local key of your prosenic vacuum cleaner. Todo that you have multiple options:

  • Use mitmproxy to intercept the connection between the prosenic app and the tuya cloud (Described below and I used this approach)
  • Read the following link

Extracting the required data with mitmproxy.

  1. First we need to setup mitmproxy. The easiest way is to setup a docker container. Other installation type can be found here Below the docker-compose script, which will setup mitmproxy on port 8080 with the web interface on port 8081

    version: "3.3"
    services:
      mitmweb:
        ports:
          - "8080:8080"
          - "127.0.0.1:8081:8081"
        image: mitmproxy/mitmproxy
        entrypoint: "mitmweb --web-iface 0.0.0.0"
    • If you have an iPhone or iPad, use please one of these device as the setup is easier there. Setup the proxy to point to your docker container. A tutorial can be found here. Afterwards go to mitm.it and install the certificate. The tutorial for this step can be found here
    • If yoi have a rooted Android device, then you can install the certificate nearly the same way as iOS. Only be sure you install it as System Certificate.
    • If you have a "normal" (not rooted) Android device, please refer to this tutorial here
  2. Open the prosenic app and refresh all your devices

  3. On the computer, where your mitmproxy docker container is running, open the following link http://localhost:8081

  4. There you should see some request to the tuya cloud. Depending on your region, you should see request to tuyaeu.com or similar. Click on the first of these requests and a detail view will be open on the right hand sight. Go to the response and search for localKey You should get similar result as the follwoing:

...
 "result": [{
            "virtual": false,
            "dpName": {},
            "lon": "0",
            "uuid": "REMOVED_FOR_PRIVACY",
            "mac": "REMOVED_FOR_PRIVACY",
            "iconUrl": "https://images.tuyaeu.com/smart/product_icon/sd.png",
            "lat": "0",
            "runtimeEnv": "prod",
            "devId": "YOUR_DEVICE_ID",
            "productId": "REMOVED_FOR_PRIVACY",
            "dps": {
...
            },
            "activeTime": 1580185647,
            "ip": "REMOVED_FOR_PRIVACY",
            "categoryCode": "wf_sd",
            "moduleMap": {
...
            },
            "devAttribute": 3,
            "name": "Cocosmart 820T",
            "timezoneId": "Europe/Rome",
            "category": "sd",
            "localKey": "YOUR_LOCAL_KEY"
        }]
...

You will need the localKey and the devId (device id).

Find out the local ip address of your vacuum robot

There are multiple ways to find out the local ip address of your vacuum robot:

  • Login into your router or dhcp server and check there for the assigned ip address
  • Run nmap to find all devices in your network. The Prosenic (Cocosmart) 820T has the open port 6668. So we can search for devices, which have open this port with the following script. Please adjust the command, that nmap is searching your network.
nmap -p 6668 192.168.0.0/24 --open

Configuration via editing configuration.yaml

  1. Enable the component by editing the configuration.yaml file (within the config directory as well). Edit it by adding the following lines: yaml vacuum: - platform: prosenic host: YOUR_IP device_id: YOUR_DEVICE_ID local_key: YOUR_KEY remember_fan_speed: false #Optional, default false Note! If you have already configured other vacuum robot, add your configuration there.

  2. Reboot hassio

  3. Congrats! You're all set!

Additional Information

Currently this integration is only tested with a Prosenic (Cocosmart) 820T, because I only have this one. @gibranZawahra confirmed that also the Model 830 is working. Please give me feedback, if it works with other models too.

The integration is communicating locally only, so you can block the access of your vacuum robot to the internet.

If you find a problem/bug or you have a feature request, please open an issue.

What's next?

  • Better error handling
  • Automated test