pypetkitapi 0.2.1__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pypetkitapi/client.py CHANGED
@@ -101,11 +101,16 @@ class PetKitClient:
101
101
  await self._get_api_server_list()
102
102
  _LOGGER.debug("Finding region server for region: %s", self.region)
103
103
 
104
+ if self.region == "china":
105
+ self._base_url = PetkitURL.CHINA_SRV
106
+ return
107
+
104
108
  regional_server = next(
105
109
  (
106
110
  server
107
111
  for server in self._servers_list
108
112
  if server.name.lower() == self.region
113
+ or server.id.lower() == self.region
109
114
  ),
110
115
  None,
111
116
  )
pypetkitapi/const.py CHANGED
@@ -35,6 +35,7 @@ class PetkitURL(StrEnum):
35
35
  """Petkit URL constants"""
36
36
 
37
37
  REGION_SRV = "https://passport.petkt.com/v1/regionservers"
38
+ CHINA_SRV = "https://api.petkit.cn/6/"
38
39
 
39
40
 
40
41
  class Client(StrEnum):
pypetkitapi/containers.py CHANGED
@@ -26,7 +26,7 @@ class SessionInfo(BaseModel):
26
26
  id: str
27
27
  user_id: str = Field(alias="userId")
28
28
  expires_in: int = Field(alias="expiresIn")
29
- region: str
29
+ region: str | None = None
30
30
  created_at: str = Field(alias="createdAt")
31
31
 
32
32
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pypetkitapi
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: Python client for PetKit API
5
5
  Home-page: https://github.com/Jezza34000/pypetkit
6
6
  License: MIT
@@ -19,10 +19,6 @@ Description-Content-Type: text/markdown
19
19
 
20
20
  ---
21
21
 
22
- # WIP - UNDER DEVELOPMENT
23
-
24
- ---
25
-
26
22
  [![PyPI](https://img.shields.io/pypi/v/pypetkitapi.svg)][pypi_]
27
23
  [![Python Version](https://img.shields.io/pypi/pyversions/pypetkitapi)][python version]
28
24
 
@@ -72,29 +68,29 @@ logging.basicConfig(level=logging.DEBUG)
72
68
 
73
69
  async def main():
74
70
  client = PetKitClient(
75
- username="username", # Your PetKit account username
71
+ username="username", # Your PetKit account username or id
76
72
  password="password", # Your PetKit account password
77
- region="France", # Your region
73
+ region="France", # Your region or country code (e.g. FR, US, etc.)
78
74
  timezone="Europe/Paris", # Your timezone
79
75
  )
80
76
 
81
77
  # To get the account and devices data attached to the account
82
78
  await client.get_devices_data()
79
+
83
80
  # Read the account data
84
81
  print(client.account_data)
82
+
85
83
  # Read the devices data
86
84
  print(client.device_list)
87
85
 
88
- # client.device_list[0] is the first device in the list in this example it's a Feeder
89
- # Get the Feeder from the device list
90
- my_feeder = client.device_list[0]
91
-
92
86
  # Send command to the devices
93
87
  ### Example 1 : Turn on the indicator light
94
- await client.send_api_request(my_feeder, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})
88
+ ### Device_ID, Command, Payload
89
+ await client.send_api_request(012346789, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})
95
90
 
96
91
  ### Example 2 : Feed the pet
97
- await client.send_api_request(my_feeder, FeederCommand.MANUAL_FEED, {"amount": 1})
92
+ ### Device_ID, Command, Payload
93
+ await client.send_api_request(0123467, FeederCommand.MANUAL_FEED, {"amount": 1})
98
94
 
99
95
 
100
96
  if __name__ == "__main__":
@@ -1,13 +1,13 @@
1
1
  pypetkitapi/__init__.py,sha256=eVpyGMD3tkYtiHUkdKEeNSZhQlZ4woI2Y5oVoV7CwXM,61
2
- pypetkitapi/client.py,sha256=xfdhNAW3jsq9xQWgnEZTc2fAH7z4GHA3jtZlwDlmgCc,14635
2
+ pypetkitapi/client.py,sha256=yb7RWlr_F1yrmmYRvQNKEt2Zd6PClsctRZYa0nRVtH0,14791
3
3
  pypetkitapi/command.py,sha256=ibJ0zenONy-FBvUvyIA_IvUnYEUezLpPxhC_9XZ6SwM,9282
4
- pypetkitapi/const.py,sha256=49NMRaCGok20P-qfzlL6PH7QN9-QDuAsPh2Fejqf2iE,2945
5
- pypetkitapi/containers.py,sha256=GQqZKaDgemQM4UDnugWYDP7N01anpJwO4VjQy2Gla3E,3109
4
+ pypetkitapi/const.py,sha256=XKiybtizB115OwVo7l9d2bZyVfkFjYWEtt9mBwYLcDk,2988
5
+ pypetkitapi/containers.py,sha256=XhNbRUztnBpIr9cypDoyE3MHojic831G5GSisK9B7kU,3123
6
6
  pypetkitapi/exceptions.py,sha256=f9QY1EME9ha_vJJx4DuL_OBNpoynYVdtMFtVZbdfook,1129
7
7
  pypetkitapi/feeder_container.py,sha256=IGXeAEbLkZhOTCzF2MhwqadIAKXg6jHbfU037dt6byY,10985
8
8
  pypetkitapi/litter_container.py,sha256=aLAvcB8K_nx7iBRkAarZs-48HAj2NkG7XjJFonWMuME,8948
9
9
  pypetkitapi/water_fountain_container.py,sha256=LcCTDjk7eSbnF7e38xev3D5mCv5wwJ6go8WGGBv-CaU,5278
10
- pypetkitapi-0.2.1.dist-info/LICENSE,sha256=4FWnKolNLc1e3w6cVlT61YxfPh0DQNeQLN1CepKKSBg,1067
11
- pypetkitapi-0.2.1.dist-info/METADATA,sha256=mb2SmQx9J0Vx-N5ukYHAlUodTLrU0M1TYc0psdIb57E,3700
12
- pypetkitapi-0.2.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
13
- pypetkitapi-0.2.1.dist-info/RECORD,,
10
+ pypetkitapi-0.3.0.dist-info/LICENSE,sha256=4FWnKolNLc1e3w6cVlT61YxfPh0DQNeQLN1CepKKSBg,1067
11
+ pypetkitapi-0.3.0.dist-info/METADATA,sha256=FaCJfahbgxUuDf8kfEeVhwn22vDPWu9bEfvmVRO43sk,3611
12
+ pypetkitapi-0.3.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
13
+ pypetkitapi-0.3.0.dist-info/RECORD,,