mirror of
https://github.com/sudoxnym/roomba_rest980.git
synced 2026-07-13 15:38:19 +00:00
Dynamic icon
This commit is contained in:
parent
fdb079e3af
commit
8d62f4b534
2 changed files with 12 additions and 4 deletions
|
|
@ -11,7 +11,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN, regionTypeMappings
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -622,7 +622,9 @@ class RoombaMapCamera(Camera):
|
||||||
if coord:
|
if coord:
|
||||||
# Transform coordinate to map image space
|
# Transform coordinate to map image space
|
||||||
img_x = coord[0] * scale + offset_x
|
img_x = coord[0] * scale + offset_x
|
||||||
img_y = MAP_HEIGHT - (coord[1] * scale + offset_y) # Flip Y axis
|
img_y = MAP_HEIGHT - (
|
||||||
|
coord[1] * scale + offset_y
|
||||||
|
) # Flip Y axis
|
||||||
polygon_coords.append([int(img_x), int(img_y)])
|
polygon_coords.append([int(img_x), int(img_y)])
|
||||||
|
|
||||||
if len(polygon_coords) >= 3:
|
if len(polygon_coords) >= 3:
|
||||||
|
|
@ -635,10 +637,16 @@ class RoombaMapCamera(Camera):
|
||||||
center_x = int(x_sum / len(room_outline))
|
center_x = int(x_sum / len(room_outline))
|
||||||
center_y = int(y_sum / len(room_outline))
|
center_y = int(y_sum / len(room_outline))
|
||||||
|
|
||||||
|
# Get the appropriate icon based on region type
|
||||||
|
region_type = region.get("region_type", "default")
|
||||||
|
icon = regionTypeMappings.get(
|
||||||
|
region_type, regionTypeMappings.get("default")
|
||||||
|
)
|
||||||
|
|
||||||
# Create room configuration similar to the vacuum card format
|
# Create room configuration similar to the vacuum card format
|
||||||
rooms_dict[room_id] = {
|
rooms_dict[room_id] = {
|
||||||
"name": room_name,
|
"name": room_name,
|
||||||
"icon": "mdi:broom",
|
"icon": icon,
|
||||||
"x": center_x,
|
"x": center_x,
|
||||||
"y": center_y,
|
"y": center_y,
|
||||||
"outline": room_outline,
|
"outline": room_outline,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
"@ia74"
|
"@ia74"
|
||||||
],
|
],
|
||||||
"version": "1.7.0",
|
"version": "1.7.1",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"dhcp": [
|
"dhcp": [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue