Skip to content

Commit

Permalink
Merge pull request #4 from RobertD502/dev
Browse files Browse the repository at this point in the history
Add support for Pura MAX, set base_url according to account region, add ServerError Exception
  • Loading branch information
RobertD502 authored Jun 2, 2023
2 parents e028b98 + 629f834 commit eaf4d49
Show file tree
Hide file tree
Showing 8 changed files with 721 additions and 192 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

Asynchronous Python library for PetKit's API.

This is PetKit's undocumented API. With that said, future changes made by PetKit may break this library. All API calls are made to PetKit's USA servers.
This is PetKit's undocumented API. With that said, future changes made by PetKit may break this library. The API endpoint used is determined based on the region your account is locked to. Although support has been added for the PetKit Asia API endpoint, I have not personally tested it.

## **Currently Supported Devices**:
- [D3 Feeder (Fresh Element Infinity)](https://www.amazon.com/PETKIT-Automatic-Stainless-Programmable-Dispenser/dp/B09JFK8BCQ)
- [D4 Feeder (Fresh Element Solo)](https://www.amazon.com/PETKIT-Automatic-Dispenser-Compatible-Freeze-Dried/dp/B09158J9PF/)
- [Mini Feeder](https://www.amazon.com/PETKIT-Automatic-Stainless-Indicator-Dispenser-2-8L/dp/B08GS1CPHH/)
- [W5 Water Fountain (Eversweet 3 Pro)](https://www.amazon.com/PETKIT-Wireless-Fountain-Stainless-Dispenser/dp/B09QRH6L3M/)
- [T3 Litter Box (Pura X)](https://www.amazon.com/PETKIT-Self-Cleaning-Scooping-Automatic-Multiple/dp/B08T9CCP1M)
- [T4 Litter Box (Pura MAX) with/without Pura Air](https://www.amazon.com/PETKIT-Self-Cleaning-Capacity-Multiple-Automatic/dp/B09KC7Q4YF)

## Important

Expand Down Expand Up @@ -72,7 +73,7 @@ from petkitaio.constants import FeederSetting

# Enabling child lock on a D4 feeder. Note: Mini Feeders use a different setting.
# Reusing retrieved devices from above.
await client.update_feeder_settings(feeder=devices.feeders[feederid], setting=FeederSetting.CHILDLOCK, value=1)
await client.update_feeder_settings(feeder=devices.feeders[feederid], setting=FeederSetting.CHILD_LOCK, value=1)
```

### Reset Feeder Desiccant
Expand Down
194 changes: 194 additions & 0 deletions petkitaio/Event Types/Pura MAX Event Types.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
#### Event Type 5: clean_over ####

Result 0: {
start_reason 0: 'Auto cleaning completed.'
start_reason 1: Periodic cleaning completed.
start_reason 2: 'Manual cleaning completed.'
start_reason 3: 'Manual cleaning completed.'
}

Result 1: {
start_reason 0: Automatic cleaning terminated
start_reason 1: Periodic cleaning terminated
start_reason 2: Manual cleaning terminated
start_reason 3: Manual cleaning terminated
}

Result 2: {
start_reason 0: {
error = "full": Automatic cleaning failed, waste collection bin is full, please empty promptly.
error = "hallT": Automatic cleaning failure, the litter box's upper cupper cover is not placed properly, please check.
error = "falldown": Automatic cleaning failure, the litter box has been knocked down, please check.
all else = "Automatic cleaning failure, device malfunction, please check."
}
start_reason 1: {
error = "full": Scheduled cleaning failed, waste collection bin is full, please empty promptly.
error = "hallT": Scheduled cleaning failure, the litter box\'s upper cupper cover is not placed properly, please check.
error = "falldown": Scheduled cleaning failure, the litter box has been knocked down, please check.
all else = "Scheduled cleaning failure, device malfunction, please check."
}
start_reason 2/3: {
error = "full": Manual cleaning failed, waste collection bin is full, please empty promptly
error = "hallT": Manual cleaning failure, the litter box\'s upper cupper cover is not placed properly, please check.
error = "falldown": Manual cleaning failure, the litter box has been knocked down, please check.
all else = "Manual cleaning failure, device malfunction, please check."
}
}

Result 3: {
start_reason 0: Automatic cleaning cancelled, device in operation.
start_reason 1: Periodic cleaning cancelled, device in operation.
start_reason 2: Manual cleaning cancelled, device in operation.
start_reason 3: Manual cleaning cancelled, device in operation.
}

Result 4: {
start_reason 0: Automatic cleaning failed, waste collection bin is full, please empty promptly.
start_reason 1: Scheduled cleaning failed, waste collection bin is full, please empty promptly.
start_reason 2/3: Manual cleaning failed, waste collection bin is full, please empty promptly.
}

Result 5: {
start_reason 0: Automatic cleaning failed, the device is in maintenance mode
start_reason 1: Periodically cleaning failed, the device is in maintenance mode
}

Result 7: {
start_reason 0: Kitten mode is enabled, auto cleaning is canceled
start_reason 1: Kitten mode is enabled, periodically cleaning is canceled




#### Event Type 6: dumping_over ####

Result 0: {
Cat litter empty completed
}

Result 1: {
Cat litter empty terminated
}

Result 2: {
error = "full": Cat litter empty failed, waste collection bin is full, please empty promptly.
error = "hallT": Cat litter empty failure, the litter box\'s cupper cover is not placed properly, please check.
error = "falldown": Cat litter empty failure, the litter box has been knocked down, please check.
all else = Cat litter empty failure, device malfunction, please check.
}


#### Event Type 7: reset_over ####

Result 0: {
Device reset completed
}

Result 1: {
Device reset terminated
}

Result 2: {
error = "full": Device reset failed, waste collection bin is full, please empty promptly.
error = "hallT": Device reset failure, the litter box\'s cupper cover is not placed properly, please check.
error = "falldown": Device reset failure, the litter box has been knocked down, please check.
all else: Device reset failure, device malfunction, please check.
}

Result 5: {
Maintenance Mode
}


#### Event Type 8: spray_over ####

Result 0: {
reason 0: Deodorant FINISHED
reason 1: Periodic odor removal completed
reason 2/3: Manual odor removal completed
}

Result 2: {
reason 0: Automatic odor removal failed, odor eliminator error
reason 1: Periodic odor removal failure, odor eliminator malfunction.
reason 2/3: Manual odor removal failure, odor eliminator malfunction.
}

Result 1: {
reason 0: Automatic odor removal has been terminated.
reason 1: Periodic odor removal terminated.
reason 2/3: Manual odor removal terminated.
}

Result 4: {
reason 0: Automatic odor removal has been cancelled, the device is running.
reason 1: Periodic odor removal canceled. Litter Box is working.
reason 2/3: Manual odor removal canceled. Litter Box is working.
}

Result 5: {
reason 0: Automatic odor removal failed, no smart spray is connected.
reason 1: Periodic odor removal failed. Odor Removal Device disconnected.
reason 2/3: Manual odor removal failed. Odor Removal Device disconnected.
}

Result 6: {
reason 0: Automatic odor removal failed, please confirm that the battery of smart spray is sufficient.
reason 1: Periodic odor removal failed. Please make sure the Odor Removal Device has sufficient battery.
reason 2/3: Manual odor removal failed. Please make sure the Odor Removal Device has sufficient battery.
}

Result 7: {
reason 0: Automatic odor removal failed, battery is low
reason 1: Periodic odor removal failed. Odor Removal Device battery low.
reason 2/3: Manual odor removal failed. Odor Removal Device battery low.
}

Result 8: {
reason 0: Deodorant FINISHED
reason 1: Periodic odor removal completed
reason 2/3: Manual odor removal completed
}

Result 9: {
Your cat is using the litter box, deodorization has been canceled
}


#### Event Type 10: pet_out ####

There are no result and reason for this one....list the pet name and weight instead



#### Event Type 17: light_over

if content key is None:
"The light is ON"
else:

Result 0: {
The light is ON
}

Result 1: {
The light is on. There is no need to turn on again.
}

Result 2: {
Failing to turn on the light. Device malfunction, please check.
}

Result 5: {
Failing to turn on the light. Please bind the odor removal device first.
}

Result 6: {
Failing to turn on the light. Please check the battery capacity of the odor removal device.
}

Result 7: {
Failing to turn on the light. Low battery capacity of odor removal device.
}


152 changes: 152 additions & 0 deletions petkitaio/Event Types/Pura MAX workState.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
## workMode 9: Maintenance Mode
workProcess of 10 = start maintenance mode
workProcess of 30 = end maintenance mode
If end maintenance mode is pause:
workProcess will change from 30 to 40
If then you resume ending maintenance mode:
workProcess will change from 40 to 30


// Disregard
if current work process / 10 = 3 --> pause maintenance and set workProcess of 40; else set workProcess to 20
if current work process / 10 = 4 --> re-end maintenance mode and set workProcess to 30; else set workProcess to 10
// Disregard


## workMode 9: Maintenance Mode

if workProcess / 10 == 1:
"In maintenance mode"
if round_down(workProcess / 10) == 2:
if workProcess % 10 == 2:
if safeWarn in workState:
if safeWarn !=0:
if safeWarn == 1:
"Maintenance mode paused: Pet entered while in operation, anti-pinch sensors activated, device stopped working. Please check the device ASAP.
if safeWarn == 3:
"Maintenance mode paused: The top cover is not installed, operation paused"
else:
"Maintenance mode paused: System error, operation paused"
if safeWarn == 0:
if petInTime == 0:
"Maintenance mode paused: Your cat is approaching, operation paused"
else:
"Maintenance mode paused: Your cat is using the device, operation paused"
else:
"Maintenance mode paused"
if workProcess / 10 == 3:
"Exiting maintenance mode"
if rounded_down(workProcess / 10) == 4:
if workProcess % 10 == 2:
if safeWarn in workState:
if safeWarn !=0:
if safeWarn == 1:
"Maintenance mode exiting paused: Pet entered while in operation, anti-pinch sensors activated, device stopped working. Please check the device ASAP."
if safeWarn == 3:
"Maintenance mode exiting paused: The top cover is not installed, operation paused"
else:
"Maintenance mode exiting paused: System error, operation paused"
if safeWarn == 0:
if petInTime == 0:
"Maintenance mode exiting paused: Your cat is approaching, operation paused"
else:
"Maintenance mode exiting paused: Your cat is using the device, operation paused"
else:
"Maintenance mode exiting paused"



## workMode 0: Start Cleaning

if workProcess / 10 == 1:
"Cleaning litter box"
if rounded_down(workProcess / 10) == 2:
if workProcess % 10 = 2:
if safeWarn in workState:
if safeWarn !=0:
if safeWarn == 1:
"Litter box cleaning paused: Pet entered while in operation, anti-pinch sensors activated, device stopped working. Please check the device ASAP."
else:
"Litter box cleaning paused: System error, operation paused"
if safeWarn == 0:
if petInTime == 0:
"Litter box cleaning paused: Your cat is approaching, operation paused"
else:
"Litter box cleaning paused: Your cat is using the device, operation paused"
else:
"Litter box cleaning paused"
if workProcess / 10 == 3:
"Resetting device"
if rounded_down(workProcess / 10) == 4:
if workProcess % 10 == 2:
if safeWarn in workState:
if safeWarn != 0:
if safeWarn == 1:
"Litter box paused: Pet entered while in operation, anti-pinch sensors activated, device stopped working. Please check the device ASAP."
else:
"Litter box paused: System error, operation paused"
if safeWarn == 0:
if petInTime == 0:
"Litter box paused: Your cat is approaching, operation paused"
else:
"Litter box paused: Your cat is using the device, operation paused"
else:
"Litter box paused"



## workMode 1: Dump Cat litter

if workProcess / 10 == 1:
"Dumping cat litter"
if rounded_down(workProcess / 10) == 2:
if workProcess % 10 == 2:
if safeWarn in workState:
if safeWarn !=0:
if safeWarn == 1:
"Dumping cat litter paused: Pet entered while in operation, anti-pinch sensors activated, device stopped working. Please check the device ASAP."
else:
"Dumping cat litter paused: System error, operation paused"
if safeWarn == 0:
if petInTime == 0:
"Dumping cat litter paused: Your cat is approaching, operation paused"
else:
"Dumping cat litter paused: Your cat is using the device, operation paused"
else:
"Dumping cat litter paused"
if workProcess % 10 = 3:
"Resetting device"
if rounded_down(workProcess / 10) == 4:
if workProcess % 10 = 2:
if safeWarn in workState:
if safeWarn != 0:
if safeWarn == 1:
"Litter box paused: Pet entered while in operation, anti-pinch sensors activated, device stopped working. Please check the device ASAP."
else:
"Litter box paused: System error, operation paused"
if safeWarn == 0:
if petInTime == 0:
"Litter box paused: Your cat is approaching, operation paused"
else:
"Litter box paused: Your cat is using the device, operation paused"
else:
"Litter box paused"



## workMode 3: Dump Cat litter
"Resetting"


## workMode 4: Leveling cat litter
"Leveling cat litter, please wait."


## workMode 5: Calibrating

"Calibrating litter box, please wait."


if refreshState key in state:
if workProcess = 1:
"Odor removal in operation. Please wait."
Loading

0 comments on commit eaf4d49

Please sign in to comment.