Skip to content

hasscc/petkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Petkit for HomeAssistant

⚠️ I don't have more time to maintain this repo, RobertD502/home-assistant-petkit is a better integration, please switch to it.


Installing

Download and copy custom_components/petkit folder to custom_components folder in your HomeAssistant config folder

OR

# Auto install via terminal shell
wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | DOMAIN=petkit REPO_PATH=hasscc/petkit ARCHIVE_TAG=main bash -

After installing, confirm that the custom_components/petkit folder exists in your HomeAssistant config folder.

Config

It is recommended to use another account credentials for this integration.

Add the following to your configuration.yaml:

# configuration.yaml

petkit:
  # Single account
  username: 86-18866668888 # Username of Petkit APP (小佩宠物), important to use country code
  password: abcdefghijklmn # MD5 or Raw password
  api_base:       # Optional, default is China server: http://api.petkit.cn/6/
  scan_interval:  # Optional, default is 00:02:00
  feeding_amount: # Optional, default is 10(g), also can be input_number entity id.

  # Multiple accounts
  accounts:
    - username: [email protected]
      password: password1
      api_base: http://api.petktasia.com/latest/ # Asia server
      feeding_amount: 20
    - username: [email protected]
      password: password2
      api_base: http://api.petkt.com/latest/     # America server
      feeding_amount: input_number.your_feeding_amount_entity_id # min:10, step:10

For a simple test to ensure integration added correctly, the following works as well:

# configuration.yaml

petkit:
  # Single account
  username: [email protected] # Username of Petkit APP (小佩宠物), important to use country code
  password: your_password # MD5 or Raw password
  api_base: http://api.petkt.com/latest/     # America server - this can be changed to any other server

To check if integration successful:

  1. Go to Settings -> Devices & Services -> Entities
  2. Search for petkit (you should see new entities with Integration label Petkit)

If integration not successful:

  1. Check your home-assistant.log file
  2. Search for petkit in the file
  3. There should be an error message related to your issue
  4. Use Google translate

Example error message:

  • 2023-06-01 14:58:08.450 ERROR (MainThread) [custom_components.petkit] Petkit login [email protected] failed: {'error': {'code': 125, 'msg': '手机号未注册'}}
  • 2023-06-01 14:58:08.501 WARNING (MainThread) [custom_components.petkit] Got petkit devices for [email protected] failed: {'error': {'code': 5, 'msg': '登录会话期,请重新登录'}}

Services

service: petkit.request_api
target:
  entity_id: sensor.d4_xxxxxx_state # Any sensor entity in the account: the Petkit sensor entity ID shown in Settings -> Devices & Services -> Entities
data:
  api: /discovery/device_roster
  params:
    key: val