-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add python script
- Loading branch information
Showing
5 changed files
with
44 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# services.yaml | ||
vacuum_room: | ||
description: Vacuum specific room(s) | ||
fields: | ||
entity_id: | ||
description: The vacuum to use for cleaning | ||
example: vacuum.roborock | ||
area: | ||
description: A string of rooms to be selected for cleaning | ||
example: "kitchen and the hallway" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Vacuum a specific room | ||
|
||
roomConfig = { | ||
16: ["hallway"], | ||
17: ["bedroom"], | ||
18: ["entrance"], | ||
19: ["kitchen"], | ||
20: ["nursery", "kids room"], | ||
22: ["living room"], | ||
23: ["office"] | ||
} | ||
|
||
entity_id = data.get("entity_id") | ||
area = data.get("area").lower() | ||
|
||
roomsToClean = [] | ||
|
||
for roomNumber, roomNames in roomConfig.items(): | ||
for name in roomNames: | ||
if name in area: | ||
roomsToClean.append(int(roomNumber)) | ||
continue | ||
|
||
if entity_id is not None and len(roomsToClean) > 0: | ||
service_data = {"entity_id": entity_id, "command": "app_segment_clean", "params": roomsToClean} | ||
hass.services.call("vacuum", "send_command", service_data, False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters