sca075 / mqtt_vacuum_camera

Camera Integration for Home Assistant to export and render all Vacuums connected via MQTT( including Valetudo Hypfer and RE(rand256)) Maps.
Apache License 2.0
91 stars 5 forks source link

Rooms Attribute isn't show on Xaiomi C1 #42

Closed sca075 closed 11 months ago

sca075 commented 11 months ago

Hi,

Firstly thanks for creating this Camera for HA.

I currently have a Xiaomi 1C robot vacuum running Hyperfer\Valetudo and have setup your camera as per the instructions and it is giving me the map data, which each room coloured appropriately. I have the areas named in the Valetudo software. I am using the lovelace-xiaomi-vacuum-map-card configured with your camera and it is displaying the map fine, however I can't figure out how to get Rooms working. When I go into the card the link for 'GENERATE ROOMS CONFIG' is greyed out and I can't click on it to auto generate the code for the rooms.

What am I missing ?

_Originally posted by @duffmiester in https://github.com/sca075/valetudo_vacuum_camera/discussions/11#discussioncomment-7247125_

sca075 commented 11 months ago

@duffmiester I opened this issue to keep track.

duffmiester commented 11 months ago

Have sent you an email with the Debug ZIP. :-)

sca075 commented 11 months ago

@duffmiester tested the data you kindly provided either in development and test environment (PI4 with HA OS and supervised) the camera output normally the rooms attribute:

rooms:
  '1':
    number: '1'
    outline:
      - - 2340
        - 1625
      - - 2745
        - 1625
      - - 2745
        - 2185
      - - 2340
        - 2185
    name: MasterBedroom
    x: 2542
    'y': 1905
  '3':
    number: '3'
    outline:
      - - 2420
        - 2525
      - - 2700
        - 2525
      - - 2700
        - 2720
      - - 2420
        - 2720
    name: Office
    x: 2560
    'y': 2622
  '4':
    number: '4'
    outline:
      - - 2300
        - 2780
      - - 2725
        - 2780
      - - 2725
        - 3075
      - - 2300
        - 3075
    name: GeorgeBedroom
    x: 2512
    'y': 2927
  '5':
    number: '5'
    outline:
      - - 2370
        - 3085
      - - 2690
        - 3085
      - - 2690
        - 3365
      - - 2370
        - 3365
    name: SpareBedroom
    x: 2530
    'y': 3225
  '8':
    number: '8'
    outline:
      - - 2345
        - 2175
      - - 2715
        - 2175
      - - 2715
        - 2445
      - - 2345
        - 2445
    name: Bathroom
    x: 2530
    'y': 2310
  '9':
    number: '9'
    outline:
      - - 2685
        - 1875
      - - 3345
        - 1875
      - - 3345
        - 3415
      - - 2685
        - 3415
    name: Living
    x: 3015
    'y': 2645

I confirmed also from your log data that the DEBUG:image_handler:Checking for rooms data.. was not there, I can't reproduce the issue.. Can you try to turn OFF and after a while ON again using the HA services? this should force the refresh..
Screenshot 2023-10-12 at 07 22 01

duffmiester commented 11 months ago

That is really weird, I wonder why it isn't getting the room data for me.

I have even tried removing the Vacuum camera completely from Integrations and HACS, rebooting, reinstalling the Vacuum Camera in HACS and rebooting and still when I check in Developer tools I am missing the room section. I also tried installing version 1.4.4 of the Vacuum camera, but that was the same.

I wonder what other differences there are between our setups. I am running HA in a VM using the HA VMWare image, I am running latest version of HA. I am using MQTT integration in HA for the vacuum.

sca075 commented 11 months ago

@duffmiester to be honest @rohankapoorcom had a similar issue with his S50 sometimes ago.. at that time it was just matter of time until the rooms attribute did show up (some magic probably).

In any case, whatever installation is indeed it must work. I will add some debugging logs and release a new version at the end of this week. We do have check to remove this attribute (for vacuum not having segments) I need to double check, probably the issue is that C1 and S50 have either floor and segments and probably the camera is checking just once if there are rooms, if so I will add a retry to make sure the attribute is displayed within 3 retries.. This is the reason why I thank you for reporting this situation.. it's clear that some HA environment isn't reactive as the test environment we use.

sca075 commented 11 months ago

@duffmiester I just published the additional logging, now the state attribute will be update after the first frame. Can you please download from HACS the "main" version (this will download the fix I just published). I will wait for you to confirm before releasing officially this fix, I tested it and now also by suspending the frame basically it is forced to get the rooms attribute as soon available, this should solve your issue.

2023-10-12 19:25:43.284 DEBUG (MainThread) [custom_components.valetudo_vacuum_camera.valetudo.image_handler] Crop and Trim image size: (2948, 2948)
2023-10-12 19:25:44.031 DEBUG (MainThread) [custom_components.valetudo_vacuum_camera.valetudo.image_handler] Checking for rooms data..
2023-10-12 19:25:44.031 DEBUG (MainThread) [custom_components.valetudo_vacuum_camera.valetudo.image_handler] Rooms data extracted!
2023-10-12 19:25:44.031 DEBUG (MainThread) [custom_components.valetudo_vacuum_camera.valetudo.image_handler] Got Rooms Attributes.
2023-10-12 19:25:44.031 DEBUG (MainThread) [custom_components.valetudo_vacuum_camera.camera] State attributes update: {'1': {'number': '1', 'outline': [(2340, 1625), (2745, 1625), (2745, 2185), (2340, 2185)], 'name': 'MasterBedroom', 'x': 2542, 'y': 1905}, '3': {'number': '3', 'outline': [(2420, 2525), (2700, 2525), (2700, 2720), (2420, 2720)], 'name': 'Office', 'x': 2560, 'y': 2622}, '4': {'number': '4', 'outline': [(2300, 2780), (2725, 2780), (2725, 3075), (2300, 3075)], 'name': 'GeorgeBedroom', 'x': 2512, 'y': 2927}, '5': {'number': '5', 'outline': [(2370, 3085), (2690, 3085), (2690, 3365), (2370, 3365)], 'name': 'SpareBedroom', 'x': 2530, 'y': 3225}, '8': {'number': '8', 'outline': [(2345, 2175), (2715, 2175), (2715, 2445), (2345, 2445)], 'name': 'Bathroom', 'x': 2530, 'y': 2310}, '9': {'number': '9', 'outline': [(2685, 1875), (3345, 1875), (3345, 3415), (2685, 3415)], 'name': 'Living', 'x': 3015, 'y': 2645}}
2023-10-12 19:25:44.031 DEBUG (MainThread) [custom_components.valetudo_vacuum_camera.camera] Applied silenttepidstinkbug image rotation: {180}
2023-10-12 19:25:44.032 INFO (MainThread) [custom_components.valetudo_vacuum_camera.camera] Suspended the camera data processing for: silenttepidstinkbug.
2023-10-12 19:25:44.036 INFO (MainThread) [custom_components.valetudo_vacuum_camera.valetudo.connector] Saved image data from MQTT in mqtt_silenttepidstinkbug.raw!
2023-10-12 19:25:44.104 INFO (MainThread) [custom_components.valetudo_vacuum_camera.valetudo.image_handler] Getting Calibrations points
2023-10-12 19:25:45.096 INFO (MainThread) [custom_components.valetudo_vacuum_camera.camera] silenttepidstinkbug: Image update complete
duffmiester commented 11 months ago

I just installed the 'main' version and that fixed it straight away and the room info showed instantly in developer tools. The Generate Room code now works in the Vacuum Map card. image

Thanks so much for all your help with this!!

sca075 commented 11 months ago

Thanks @duffmiester this was a great request from your side. It helps us to improve this add on, please feel free to get in contact with us (team) at any time;)

sca075 commented 11 months ago

Released v1.4.6 with the fix. This issue is closed.