Closed HummerDK closed 1 year ago
Hmm, for some reason it suddently started working again. Ill close this issue for now
Error appears again
The problem appears when Map Extractor tries to display a text on the image (e.g. when the map can't be retrieved from the cloud/vacuum). It should work properly when the map is downloaded correctly.
After latest HA 2023.8.0 update for me not working too. If I login xiaomi mihome app, map is disappered too. Don't know what happend. Yesterday was good...
@spider7611 #422
Yea, same for me. Stopped working after update.
Possible solution:
left, top, right, bottom = draw.textbbox((0, 0), text)
w, h = right - left, bottom - top
Same as in:
I also keep getting this error (log is full of them) since HA 2023.08
2023-08-04 12:38:59.896 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.vacuum_top fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 699, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 282, in update
self._set_map_data(MapDataParser.create_empty(self._colors, str(self._status)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_cloud_map_extractor/common/map_data_parser.py", line 16, in create_empty
empty_map = ImageHandler.create_empty_map_image(colors, text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py", line 76, in create_empty_map_image
w, h = draw.textsize(text)
^^^^^^^^^^^^^
AttributeError: 'ImageDraw' object has no attribute 'textsize'
Same for me. I've got exactly the same error in the log. I can confirm that the fix @redblue-pkt suggests does indeed seems to work.
Possible solution: #w, h = draw.textsize(text) left, top, right, bottom = draw.textbbox((0, 0), text) w, h = right - left, bottom - top
Same as in:
Similar situation here, but in different line (306). Does @redblue-pkt solution would work in my case aswell? My coding skills are 0 so I would be grateful if You guys could explain a bit more how to properly implement those changes.
My log:
File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 278, in update self._handle_map_data(map_name) File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 335, in _handle_map_data map_data, map_stored = self._device.get_map(map_name, self._colors, self._drawables, self._texts, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/xiaomi_cloud_map_extractor/common/vacuum.py", line 36, in get_map map_data = self.decode_map(response, colors, drawables, texts, sizes, image_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/xiaomi_cloud_map_extractor/roidmi/vacuum.py", line 23, in decode_map return MapDataParserRoidmi.parse(unzipped, colors, drawables, texts, sizes, image_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/xiaomi_cloud_map_extractor/roidmi/map_data_parser.py", line 41, in parse MapDataParserRoidmi.draw_elements(colors, drawables, sizes, map_data, image_config) File "/config/custom_components/xiaomi_cloud_map_extractor/common/map_data_parser.py", line 59, in draw_elements ImageHandler.draw_room_names(map_data.image, map_data.rooms, colors) File "/config/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py", line 168, in draw_room_names ImageHandler.draw_text__(image, room.name, point.x, point.y, color) File "/config/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py", line 309, in draw_text ImageHandler.draw_on_new_layer(image, draw_func, 1, ImageHandler.__use_transparency(color)) File "/config/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py", line 323, in __draw_on_new_layer__ draw_function(draw) File "/config/custom_components/xiaomi_cloud_map_extractor/common/image_handler.py", line 306, in draw_func w, h = draw.textsize(text, font) ^^^^^^^^^^^^^ AttributeError: 'ImageDraw' object has no attribute 'textsize'
Fixed in v2.2.1
Hi @PiotrMachowski , I'm not sure that the fix works properly. I'm running HA 2023.8.1 with your integration on v2.2.1 and it still can't initialize.
@peterjuras do you have anything in logs? Does the image show anything? Which model do you have?
Hi @PiotrMachowski ,
I have the Roborock S7 (a15). Note: It's called Roomba, because that's how my wife likes to call it via Google Assistant.
This is what my card shows:
My logs don't mention anything specific:
It is a different issue: #422
The fact that the camera displays the text on the image instead of crashing means that current issue is fixed.
I see. For me the addon still stopped working after the update though, it has not recovered since and I can't see entity statuses or the map 😔
Fixed in
v2.2.1
Works perfect now, piece of awesome work!
Checklist
The problem
It is currently unable to retrieve a new map. Might be due to an update of python? See stacktrace below.
What version of an integration has described problem?
v2.2.0
What was the last working version of an integration?
v2.2.0
What vacuum model do you have problems with?
roborock s6
What version of Home Assistant do you use?
2023.8.0
What type of installation are you running?
Home Assistant OS
Camera's configuration
Errors shown in the HA logs (if applicable)
Additional information
No response