PiotrMachowski / lovelace-xiaomi-vacuum-map-card

This card provides a user-friendly way to fully control map-based vacuums in Home Assistant. Supported brands include Xiaomi (Roborock/Viomi/Dreame/Roidmi/Valetudo/Valetudo RE), Neato, Wyze, Roomba, Ecovacs (and probably more).
MIT License
1.43k stars 247 forks source link

Vacuum doesn't start #7

Closed Anisse4 closed 5 years ago

Anisse4 commented 5 years ago

Hi 3_14,

Congrats for this developpment, and thanks for sharing it.

I have installed your module following you HowTo.

Creating directories

/home/homeassistant/.homeassistant/www/custom_lovelace/xiaomi_vacuum_map_card

With homeassistant rights

drwxr-xr-x 2 homeassistant homeassistant 4.0K Aug 26 14:18 xiaomi_vacuum_map_card

Download the 3 files inside directory adding same homeassistant rights

-rw-r--r-- 1 homeassistant homeassistant 1.1K Aug 26 09:03 style.js -rw-r--r-- 1 homeassistant homeassistant 442 Aug 26 09:03 texts.js -rw-r--r-- 1 homeassistant homeassistant 18K Aug 26 09:02 `xiaomi-vacuum-map-card.js

Added your the ressource in top of my ui-lovelace.yaml

resources:
  - url: /local/my-custom-card.js
    type: js
  - url: /local/my-webfont.css
    type: css
  - url: /local/custom_lovelace/xiaomi_vacuum_map_card/xiaomi-vacuum-map-card.js
    type: module

And added in ui_lovelace.yaml the configuration

  - icon: mdi:robot-vacuum
    # Title of the view. Will be used as the tooltip for tab icon
    title: Interactive map
    cards:
      - type: custom:xiaomi-vacuum-map-card
        entity: vacuum.xiaomi_vacuum
        map_image: '/local/custom_lovelace/xiaomi_vacuum_map_card/map4.png'
        base_position:
          x: 201
          y: 283
        reference_point:
          x: 161
          y: 247
        zones:
          - [[25500, 25500, 26500, 26500]]

I am able to check that my coordinates are correct, as when I display the cleaning zone [[25500, 25500, 26500, 26500]], I can see the square at the right place in the map. Cf screenshot under:

Don't pay attention for the play/pause... buttons, they are only screenshot:

Screenshot

But When I click on start nothing happens. Same when I specify GoTo zone or new zoned cleanup.

Could you give any help please ? Thanks in advance

PiotrMachowski commented 5 years ago

Hi, Are you sure that entity id is correct? Does anything appear in HA logs?

Anisse4 commented 5 years ago

Thanks for your quick reply.

I have tried with the 2 entities I have added in homeassistant.

With the vacuum mqtt vacuum I have this following error:

Log Details (ERROR) Mon Aug 26 2019 17:40:14 GMT+0200 (Central European Summer Time) cannot convert dictionary update sequence element #0 to a sequence Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 128, in handle_call_service connection.context(msg), File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1235, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1260, in _execute_service await handler.func(service_call) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 210, in handle_service self._platforms.values(), func, call, service_name, required_features File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 334, in entity_service_call future.result() # pop exception if have File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 356, in _handle_service_platform_call await getattr(entity, func)(**data) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/mqtt/vacuum/schema_state.py", line 405, in async_send_command message.update(params) TypeError: cannot convert dictionary update sequence element #0 to a sequence

But with the entity added in the configuration.yaml named "vacuum.xiaomi_vacuum_cleaner" I have nothing in the log.

in the ui_yaml I have tried with the thwo entities

title: Interactive map
cards:
  - type: custom:xiaomi-vacuum-map-card
    entity: vacuum.rockrobo
    map_image: '/local/custom_lovelace/xiaomi_vacuum_map_card/map4.png'
    base_position:
      x: 201
      y: 283
    reference_point:
      x: 161
      y: 247
    zones:
      - [[25500, 25500, 26500, 26500]]
    debug:
      true

title: Interactive map
cards:
  - type: custom:xiaomi-vacuum-map-card
    entity: vacuum.xiaomi_vacuum_cleaner
    map_image: '/local/custom_lovelace/xiaomi_vacuum_map_card/map4.png'
    base_position:
      x: 201
      y: 283
    reference_point:
      x: 161
      y: 247
    zones:
      - [[25500, 25500, 26500, 26500]]
    debug:
      true

In my Homeassistant the 2 availables entities, for the same vacuum. I am able to launch the robot with both entities

xiaomi_vacuum_cleaner rockrobo

Anisse4 commented 5 years ago

It seems also there are some errros writing in the sql database on the raspberry, but all devices are working properly......:

> rror saving event: <Event state_changed[L]: entity_id=vacuum.rockrobo, old_state=<state vacuum.rockrobo=cleaning; battery_level=100, battery_icon=mdi:battery, fan_speed=medium, fan_speed_list=['min', 'medium', 'high', 'max', 'mop'], cleanTime=8.6, cleanArea=412.7, cleanCount=67, last_run_stats=startTime=1566834435000, endTime=1566834436000, duration=0, area=0.0, errorCode=0, errorDescription=No error, finishedFlag=False, mainBrush=291.4, sideBrush=191.4, filter=141.4, sensor=21.4, state=docked, valetudo_state=id=8, name=Charging, friendly_name=Roborock S50, supported_features=10236 @ 2019-08-26T17:47:24.464835+02:00>, new_state=<state vacuum.rockrobo=cleaning; battery_level=100, battery_icon=mdi:battery, fan_speed=medium, fan_speed_list=['min', 'medium', 'high', 'max', 'mop'], cleanTime=8.6, cleanArea=412.7, cleanCount=67, last_run_stats=startTime=1566834435000, endTime=1566834436000, duration=0, area=0.0, errorCode=0, errorDescription=No error, finishedFlag=False, mainBrush=291.4, sideBrush=191.4, filter=141.4, sensor=21.4, state=cleaning, valetudo_state=id=5, name=Cleaning, friendly_name=Roborock S50, supported_features=10236 @ 2019-08-26T17:47:24.464835+02:00>>
> Traceback (most recent call last):
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
>     cursor, statement, parameters, context
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute
>     cursor.execute(statement, parameters)
> sqlite3.DatabaseError: database disk image is malformed
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):
>   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/recorder/__init__.py", line 346, in run
>     session.flush()
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2459, in flush
>     self._flush(objects)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2597, in _flush
>     transaction.rollback(_capture_exception=True)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
>     compat.reraise(exc_type, exc_value, exc_tb)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 154, in reraise
>     raise value
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2557, in _flush
>     flush_context.execute()
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
>     rec.execute(self)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
>     uow,
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
>     insert,
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1138, in _emit_insert_statements
>     statement, params
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute
>     return meth(self, multiparams, params)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
>     return connection._execute_clauseelement(self, multiparams, params)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
>     distilled_params,
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
>     e, statement, parameters, cursor, context
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
>     util.raise_from_cause(sqlalchemy_exception, exc_info)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 399, in raise_from_cause
>     reraise(type(exception), exception, tb=exc_tb, cause=cause)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
>     raise value.with_traceback(tb)
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
>     cursor, statement, parameters, context
>   File "/srv/homeassistant/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute
>     cursor.execute(statement, parameters)
> sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
> [SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (?, ?, ?, ?, ?, ?, ?)]
> [parameters: ('state_changed', '{"entity_id": "vacuum.rockrobo", "old_state": {"entity_id": "vacuum.rockrobo", "state": "cleaning", "attributes": {"battery_level": 100, "battery_ico ... (1516 characters truncated) ... -26T15:47:24.541259+00:00", "context": {"id": "dbaa62d0e55446ad981689a600b01e03", "parent_id": null, "user_id": "c6b2363233a6474cab9e598c9c429115"}}}', 'LOCAL', '2019-08-26 15:47:24.541373', '2019-08-26 15:47:29.220022', 'dbaa62d0e55446ad981689a600b01e03', 'c6b2363233a6474cab9e598c9c429115')]
> (Background on this error at: http://sqlalche.me/e/4xp6)
Error executing query: (sqlite3.DatabaseError) database disk image is malformed
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{"entity_id": "sensor.entree_luminosite", "old_state": {"entity_id": "sensor.entree_luminosite", "state": "1000", "attributes": {"illuminance": 1000, ... (716 characters truncated) ... :00", "last_updated": "2019-08-26T16:00:50.584439+00:00", "context": {"id": "dbaed5e7e9104837bd72e7f3e7cc2979", "parent_id": null, "user_id": null}}}', 'LOCAL', '2019-08-26 16:00:50.584554', '2019-08-26 16:00:52.899062', 'dbaed5e7e9104837bd72e7f3e7cc2979', None)]
(Background on this error at: http://sqlalche.me/e/4xp6)

For information I am not running out of space

pi@raspberrypi:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        29G  3.4G   24G  13% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M   47M  417M  11% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   40M  214M  16% /boot
tmpfs            93M     0   93M   0% /run/user/1000
PiotrMachowski commented 5 years ago

MQTT vacuum is definitely not supported by this card, so we can already skip on vacuum.rockrobo. Can you use service vacuum.xiaomi_clean_zone for entity vacuum.xiaomi_vacuum_cleaner?

Now I also saw that you have a small configuration issue for debug mode. Corrected config:

  - type: custom:xiaomi-vacuum-map-card
    entity: vacuum.rockrobo
    map_image: '/local/custom_lovelace/xiaomi_vacuum_map_card/map4.png'
    base_position:
      x: 201
      y: 283
    reference_point:
      x: 161
      y: 247
    zones:
      - [[25500, 25500, 26500, 26500]]
    debug: true
Anisse4 commented 5 years ago

Ok so I will try only with the entity without mqtt.

Yes I am able to use the service from HA interface:

cleanzone

The robot starts his cleaning following this command.

Thanks for the correction on debug: true

Anisse4 commented 5 years ago

For information I have no more errors on sqlite database. I've dump it and restored, no more errors on log file.

But no change in the interactive map. I've restarted as well HA

PiotrMachowski commented 5 years ago

Does any errors appear in browsers console?

Anisse4 commented 5 years ago

nothing related to vacuum

image

PiotrMachowski commented 5 years ago

This is HA log, to open browsers console you have to press [F12]

Anisse4 commented 5 years ago

Here is the error displaying

PiotrMachowski commented 5 years ago

Thank you, now I know everything I need to fix this issue.

Anisse4 commented 5 years ago

Thank you ! You've made a great job, can't wait to to upgrade to version fixing this issue

PiotrMachowski commented 5 years ago

Issue should be fixed right now

Anisse4 commented 5 years ago

Thanks for you correction and updates. Unfortunetly not yet fixed. Before I had the error when I loaded the page and when I clicked on the button start.

Now I have the error only when I first load the page. But on the start button click no more error, but the vacuum doesn't move.

Here is the same error on the first page load image

And here is when I try to launch one start action image

Nothing in the homeassistant log except for my xiaomi fan:

Mon Aug 26 2019 23:09:55 GMT+0200 (heure d’été d’Europe centrale)
You are using a custom integration for xiaomi_miio_fan which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
Anisse4 commented 5 years ago

Of course I have downloaded again the three files of the card from a wget with same address as your HowTo

PiotrMachowski commented 5 years ago

You have to clean browsers cache for HA site

Anisse4 commented 5 years ago

I have deleted all cache images and files, deleted all cookies history, changed to another pc. Erros are not displayed anymore but vacuum doesn't launch.

image

PiotrMachowski commented 5 years ago

Can you try again with the latest version (just updated)?

Anisse4 commented 5 years ago

yep

Anisse4 commented 5 years ago

Same error as previously and no start from vacuum. I have deleted cache also

image

Anisse4 commented 5 years ago

Tell me if it would help to give you a username to have directly access to my HA. I have internet access with reverse proxy Nginx

PiotrMachowski commented 5 years ago

It seems that error is deeper than I thought. I should be able to reproduce this error on my dev environment.

Anisse4 commented 5 years ago

ok thanks. Do not hesitate if you need further information

Maximus97 commented 5 years ago

I am having the same issue I think, none of the three commands (Go-to, Zones and Zoned cleanup) starts the robot vacuum. This card https://github.com/benct/lovelace-xiaomi-vacuum-card works fine for me so I don't think there is anything wrong with my setup.

Btw, thanks for sharing this amazing card.

PiotrMachowski commented 5 years ago

I had to remove long-press as it was responsible for all the issues. I have now a way to reproduce this issue locally, so hopefully it will be added again when I will figure it out.

Could you confirm that everything is working right now?

Anisse4 commented 5 years ago

Thanks for your efforts. I'll give it a try right now

Anisse4 commented 5 years ago

It's a little bit improving but not yet there. No more errors on browser debug; and I have a dialog box that shows the coordinates of the task I have selected to start. But vacuum still doesn't move when I click on Ok on the dialog box

Anisse4 commented 5 years ago

I have to go, I'll connect tomorrow evening GMT time.

Thanks for you work, you will move this vacuum soon ;)

For Information I have Valetudo on my HA working properly when launching vacuum action from another card

PiotrMachowski commented 5 years ago

This behavior is exactly as expected. Previously after holding Start button a popup was displayed, but vacuum was not triggered. Right now I have removed long-press, so only popup will be shown if you have debug mode enabled. To disable popups and enable interactions with a vacuum you have to disable debug.

Anisse4 commented 5 years ago

Ok I understand. Thanks for this great job, I have quickly made a test this morning, the Vacuum has moved to the target point.

So congratulations for all your work on this card and this bug. Do you want me to close this issue or let it open until long click is available ?

PiotrMachowski commented 5 years ago

Great! You can close this issue, I will open a new one by myself

Anisse4 commented 5 years ago

👍

Anisse4 commented 4 years ago

Hi,

thanks again for your work, I've just paid you a coffe ;) Cheers, Anisse

On Thu, 29 Aug 2019 at 10:02, Piotr Machowski notifications@github.com wrote:

Great! You can close this issue, I will open a new one by myself

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card/issues/7?email_source=notifications&email_token=AM57HM5ZPLVZUEQDK4BVUADQG57CPA5CNFSM4IPPXW42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5NT7OA#issuecomment-526073784, or mute the thread https://github.com/notifications/unsubscribe-auth/AM57HMZ4AH74TH7AT4AYJMDQG57CPANCNFSM4IPPXW4Q .

PiotrMachowski commented 4 years ago

Hi Anisse, Thank you very much! Piotr