Giter Site home page Giter Site logo

ha_xiaomi_vacuum_map's Introduction

# Home Assistant Xiaomi Rooted Vacuum live map

Thanks :

Special thanks to dustcloud project https://github.com/dgiese/dustcloud for giving method for rooting devices and also the base of my application to build the robot map.

Requirement

What tou need :

  • A Rooted Xiaomi Vacuum cleaner
  • Home Assistant installed and configured
  • Appdaemon running and plugged to home assistant
  • python pillow package installed (needed for appdaemon app, in appdaemon venv if you installed it that way)

Installation

Create secret entries

xiaomi_vacuum_token: <token | used by HA>
xiaomi_vacuum_host: <host or IP | used by HA and AD>
xiaomi_vacuum_map_generated: <file path of output image | used by AD>
xiaomi_vacuum_map_base: <file path of input image as background | used by AD>

xiaomi_vacuum_map_base will define where you put the background image (ie the 2D floorplan of your house) xiaomi_vacuum_map_generated will define where the generated map will bestored. Put it somewhere so that HA can use it as a local camera (see example in my package vacumm.yaml)

Connectivity

Ensure that the user running appdaemon can connect to your robot This means that appdaemon users has an SSH key that is allowed to connect as root to the robot

Hass Configuration

Create at least those 3 input_number :

input_number:
  vacuum_mapbuilder_ratio:
    min: 0
    max: 100
    mode: box
    step: 0.001
  vacuum_mapbuilder_dock_x:
    min: 0
    max: 9999
    mode: box
  vacuum_mapbuilder_dock_y:
    min: 0
    max: 9999
    mode: box

Appdaemon Configuration

Copy XiaomiVacuumCleaner.py to your appdaemon apps directory Configure apps.yaml as follow:

XiaomiVacuumCleaner_MapBuilder:
module: XiaomiVacuumCleaner
class: MapBuilder
xiaomi_vacuum_host: !secret xiaomi_vacuum_host
xiaomi_vacuum_map_generated: !secret xiaomi_vacuum_map_generated
xiaomi_vacuum_map_base: !secret xiaomi_vacuum_map_base

First run

Put your vacuum somewhere in your home but not docked This will trigger the map building and image will be rebuilded every 2 seconds.

You can now adjust setting by changing in HA the input_numbers defined previously.

vacuum_mapbuilder_dock_x & vacuum_mapbuilder_dock_x: define the position of the vacuum when docked on your background image (in pixel) vacuum_mapbuilder_ratio : define the ration to upscale / downscale the vacuum image.

Keep in mind the vacuum map is pretty low definition, in my house, I've an floorplan of 1748 × 958 and my ratio is 6.52

Each time you adjust setting, wait for the image to update and check everything is OK.

How it works

AD will be listening on state change of the vacuum. When the state of the vacuum is different from docked, it copies needed files to build the map. Then locally, it cleans, upscales the vacuum map, draw the vacuum path and merge the background image

ha_xiaomi_vacuum_map's People

Contributors

neuron303 avatar

Stargazers

Toms  avatar Ivan Belokobylskiy avatar Ed Wios avatar Bruno Bastos avatar  avatar  avatar Piotr Machowski avatar  avatar spische avatar Christoph avatar Markus Goy avatar Felix K avatar reaper7 avatar  avatar Tomas Jansson avatar  avatar

Watchers

Markus Goy avatar Dylan avatar

Forkers

pezema rkrotov

ha_xiaomi_vacuum_map's Issues

Screenshot of generated map

sounds nice you project but could you post a screenshot of the generated map. I actually use an android app and valetudo 0.3.0 NOT 0.3.1 (map generation has been outsources in latest release)

mine looks like this for the moment:

rockrobo implementation

python import from PIL

Hi,
to start with, really nice script!

im trying to get it working, but without any luck. i have install AppDaemon via Hass.io addon (running HassOS)
but it seems like my app.yaml that loading your module fail importing needed libs from PIL? have you seen same error before? from the log of AppDaemon:

another question: do i need to fill out xiaomi_vacuum_map_base: ? can i outcommit it, if i don't have any background image?

thanks in advance

2019-12-27 11:40:56.870745 WARNING AppDaemon: ------------------------------------------------------------
2019-12-27 11:40:56.871061 WARNING AppDaemon: Unexpected error loading module: /config/appdaemon/apps/XiaomiVacuumCleaner.py:
2019-12-27 11:40:56.871208 WARNING AppDaemon: ------------------------------------------------------------
2019-12-27 11:40:56.875032 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/appdaemon/apps/XiaomiVacuumCleaner.py", line 7, in <module>
    from PIL import Image, ImageDraw, ImageChops
ModuleNotFoundError: No module named 'PIL'

2019-12-27 11:40:56.875261 WARNING AppDaemon: ------------------------------------------------------------
2019-12-27 11:40:56.875410 WARNING AppDaemon: Removing associated apps:
2019-12-27 11:40:56.875576 WARNING AppDaemon: XiaomiVacuumCleaner_MapBuilder

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.