Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Add getPosition event with x y and currentSpotAreaID #505

@francescopalma86

Description

@francescopalma86

Is there an existing issue for this?

  • I have searched the existing issues and no issue is describing my feature request or idea

Is your feature request related to a problem?

No response

Suggested solution

My goal is to turn on the light in the room where the robot is cleaning and turn it off when it exits the room. I have studied code and examples online, and I have found that the ecovacs-deebot.js library provides the following information: along with the x and y coordinates, it also has the currentSpotAreaID property.

In vacBot.js -> let currentSpotAreaID = mapTools.isPositionInSpotArea(posX, posY, this.mapSpotAreaInfos[this.currentMapMID]);

After retrieving the polygon of each room and the current position of the robot, the process to calculate the area it is in should be as follows:

  1. Decompress the coordinates with lzma and decode the base64:
    polygon_string = _decompress_7z_base64_data(event.coordinates).decode('utf-8');

  2. Use a function like the following for each room to determine in which polygon the current bot coordinates are located:

import shapely.geometry

def is_point_inside_polygon(x, y, polygon_string):
    coordinates = [tuple(map(float, pair.split(','))) for pair in polygon_string.split(';')]
    polygon = shapely.geometry.Polygon(coordinates)
    return polygon.contains(shapely.geometry.Point(x, y))
  1. Now, you could trigger a new event or modify the value of a new sensor to inform the user that the bot has changed rooms.

Api example request

No response

Alternatives you've considered

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions