bmccluskey / robovac

Add a Eufy RoboVac easily to Home Assistant
Other
115 stars 24 forks source link

Automate cleaning certain rooms #7

Open LewisSpring opened 1 year ago

LewisSpring commented 1 year ago

Hello,

Thanks for making this integration.

I noticed the vacuum has a Cleaning area attribute. I was wondering if it would be possible to use this to automate the vacuum cleaning in certain rooms? EG, Start cleaning in room number 2

Thanks!

Everett115 commented 1 year ago

My 30C Max doesn't support creating rooms but the code for sending the clean room command looks like this.

elif command == "roomClean":
            roomIds = params.get("roomIds", [1])
            count = params.get("count", 1)
            clean_request = {"roomIds": roomIds, "cleanTimes": count}
            method_call = {
                "method": "selectRoomsClean",
                "data": clean_request,
                "timestamp": round(time.time() * 1000),
            }
            json_str = json.dumps(method_call, separators=(",", ":"))
            base64_str = base64.b64encode(json_str.encode("utf8")).decode("utf8")
            _LOGGER.info("roomClean call %s", json_str)
            await self.vacuum.async_set({"124": base64_str}, None)
        await asyncio.sleep(1)
        self.async_update

Looks like there is a variable for room IDs that can be added to the command. I'm not sure what the format of the room IDs are because my vacuum doesnt support this but if you go to the developer services page in home assistant you can try different room IDs in the commands to figure out how it works.

LewisSpring commented 1 year ago

Hi, sorry for the delay and thanks for your reply.

I tried this: image (With and without quotes around "2")

No dice, hoover does nothing and there's no log lines either.

kizza commented 1 year ago

Thanks for the breadcrumb here @LewisSpring (I can't trust all of my rooms to be in a "cleanable" state, so am motivated to get this working for our adhoc auto eufy run). I wasn't sure where to start before finding this 🙏

I was able to pass roomIds as an array (using the square bracket syntax - no quotation marks)

{"roomIds": [1]}

I'm now in the process of shooting different numbers at it to discern which id relates to which room! I expect something like the following to work...

{"roomIds": [2, 5, 7]}

I suspect/hope one day someone'll figure out how to pull a list of rooms from the app - for now a manual list feels manageable. (edit: fwiw, the ids don't feel 1-to-1 with existing rooms, it's possible there are some previously mapped areas corelating to some ids 🤷‍♀️)

LewisSpring commented 1 year ago

Thanks for the breadcrumb here @LewisSpring (I can't trust all of my rooms to be in a "cleanable" state, so am motivated to get this working for our adhoc auto eufy run). I wasn't sure where to start before finding this 🙏

I was able to pass roomIds as an array (using the square bracket syntax - no quotation marks)

{"roomIds": [1]}

I'm now in the process of shooting different numbers at it to discern which id relates to which room! I expect something like the following to work...

{"roomIds": [2, 5, 7]}

I suspect/hope one day someone'll figure out how to pull a list of rooms from the app - for now a manual list feels manageable. (edit: fwiw, the ids don't feel 1-to-1 with existing rooms, it's possible there are some previously mapped areas corelating to some ids 🤷‍♀️)

I've just had chance to come back to this, I've been incrementing 1-11 and i've only found 1 room! Hoping someone can find an API endpoint for room IDs.

Credo102 commented 1 year ago

not sure if this will help you as i am using this for an x8 Hybrid finding the room IDs: I too had issue finding room ids that worked, mine started at 12. I think this is because of how the maps have been created/overwritten over time because when I factory reset my device (because of a different issue) my room ids changed and now start at 1 (weirdly room 0 and room 1 were the same room). So i suggest that you either keep on increasing your room id's until you find moe rooms or reset the device and start a fresh new map.

Regarding automating the cleaning of a specific room: I created scripts for each room (examples of 2 rooms below). where "roomIds" identifies a specific room (found by trial and error) and "count" is how many times i wanted it to clean that room before going back to docking (1, 2 or 3).

x8_09_clean:
  alias: 'X8 Bathroom Clean '
  sequence:
  - service: vacuum.send_command
    data:
      command: roomClean
      params:
        roomIds:
        - 9
        count: 2
    target:
      device_id: <YOUR DEVICE>
  mode: single
  icon: mdi:bathtub
x8_10_clean:
  alias: 'X8 WC Clean '
  sequence:
  - service: vacuum.send_command
    data:
      command: roomClean
      params:
        roomIds:
        - 10
        count: 2
    target:
      device_id:  <YOUR DEVICE>
  mode: single
  icon: mdi:paper-roll
LewisSpring commented 1 year ago

not sure if this will help you as i am using this for an x8 Hybrid finding the room IDs: I too had issue finding room ids that worked, mine started at 12. I think this is because of how the maps have been created/overwritten over time because when I factory reset my device (because of a different issue) my room ids changed and now start at 1 (weirdly room 0 and room 1 were the same room). So i suggest that you either keep on increasing your room id's until you find moe rooms or reset the device and start a fresh new map.

Regarding automating the cleaning of a specific room: I created scripts for each room (examples of 2 rooms below). where "roomIds" identifies a specific room (found by trial and error) and "count" is how many times i wanted it to clean that room before going back to docking (1, 2 or 3).

x8_09_clean:
  alias: 'X8 Bathroom Clean '
  sequence:
  - service: vacuum.send_command
    data:
      command: roomClean
      params:
        roomIds:
        - 9
        count: 2
    target:
      device_id: <YOUR DEVICE>
  mode: single
  icon: mdi:bathtub
x8_10_clean:
  alias: 'X8 WC Clean '
  sequence:
  - service: vacuum.send_command
    data:
      command: roomClean
      params:
        roomIds:
        - 10
        count: 2
    target:
      device_id:  <YOUR DEVICE>
  mode: single
  icon: mdi:paper-roll

That's a good idea, thanks! Mine turned out to be 1,14,16,18,23 and there's an area missing. I just ran it on auto (I normally use Room) and the map is all messed up, and it's finding area that doesn't exist and is driving out of bounds. I think factory reset is due!