-
-
Notifications
You must be signed in to change notification settings - Fork 52
Add getPosition event with x y and currentSpotAreaID #505
Description
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:
-
Decompress the coordinates with lzma and decode the base64:
polygon_string = _decompress_7z_base64_data(event.coordinates).decode('utf-8'); -
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))
- 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