🐱 Petkit feeder components for HomeAssistant

Overview

Petkit for HomeAssistant

Installing

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

# 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 bash -

Config

Recommend sharing devices to another account

# 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
Comments
  • Request: Petkit Pura X integration

    Request: Petkit Pura X integration

    Request: It would be nice if this could also gather the sensors of the petkit pura x smart litter box. I think it uses the same API as my installation shows online and I do not have the feeder.

    enhancement 
    opened by fhornrudd 51
  • api调用结果跟代码里不太一样啊

    api调用结果跟代码里不太一样啊

    我调用代码里的API的响应:

    "data": {
    	  "name": "喂食器Mini",
    	  "createdAt": "2019-11-07T10:01:18.521Z",
    	  "id": 100000,
    	  "state": 1,
    	  "dailyFeed": {
    		  "amount": 80,
    		  "day": 20211104,
    		  "deviceId": 0,
    		  "items": [],
    		  "realAmount": 85
    	  },
    	  "relation": {
    		  "petIds": [
    			  "xxxxx",
    			  "xxxxx"
    		  ],
    		  "userId": "xxxxxx"
    	  },
    	  "status": {
    		  "batteryPower": 4,
    		  "batteryStatus": 0,
    		  "desiccantLeftDays": 29,
    		  "errorPriority": 0,
    		  "feeding": 0,
    		  "food": 1,
    		  "ota": 0,
    		  "overall": 1,
    		  "pim": 1,
    		  "runtime": 35263,
    		  "wifi": {
    			  "bssid": "xxxxxxx",
    			  "rsq": -64,
    			  "ssid": "xxx"
    		  }
    	  },
    	  "desc": "下次出粮时间: 23:00"
      },
      "type": "FeederMini"
    
    
    opened by yangtfu 8
  • Config error  `ConfigEntryNotReady`

    Config error `ConfigEntryNotReady`

    As of today I'm getting this error:

    2022-09-14 19:55:00 ERROR (MainThread) [homeassistant.setup] Error during setup of component petkit
    Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
    self.data = await self._async_update_data()
    File "/config/custom_components/petkit/__init__.py", line 239, in _async_update_data
    dls = await self.account.get_devices()
    File "/config/custom_components/petkit/__init__.py", line 216, in get_devices
    rsp = await self.request(api)
    File "/config/custom_components/petkit/__init__.py", line 163, in request
    req = await self.http.request(method, url, **kws)
    File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 559, in _request
    await resp.start(conn)
    File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 913, in start
    self._continue = None
    File "/usr/local/lib/python3.9/site-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
    asyncio.exceptions.TimeoutError
    The above exception was the direct cause of the following exception:
    Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/setup.py", line 235, in _async_setup_component
    result = await task
    File "/config/custom_components/petkit/__init__.py", line 86, in async_setup
    await coordinator.async_config_entry_first_refresh()
    File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in async_config_entry_first_refresh
    raise ex
    homeassistant.exceptions.ConfigEntryNotReady
    

    Before this error is thrown this warning is raised:

    Logger: homeassistant.setup
    Source: /usr/local/lib/python3.9/asyncio/events.py:80
    First occurred: 19:54:49 (1 occurrences)
    Last logged: 19:54:49
    
    Setup of petkit is taking over 10 seconds.
    
    opened by nivv 6
  • Unable to login in the United States

    Unable to login in the United States

    Hi -- awesome to see the work! I am based in the United States, per the app, I login with an email/password. I don't see any other username in the app. Putting email/password in the config doesn't seem to work. Any thoughts? Thanks for the work

    documentation 
    opened by yieldhog 6
  • Attempt to decode JSON with unexpected mimetype

    Attempt to decode JSON with unexpected mimetype

    petkit:
      # Single account
      username: ***@gmail.com # Username of Petkit APP (小佩宠物), important to use country code
      password: ***** # MD5 or Raw password
      api_base: http://api.petkt.com/latest/
    

    2022-02-14 19:19:54 ERROR (MainThread) [homeassistant.setup] Error during setup of component petkit Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/petkit/init.py", line 239, in _async_update_data dls = await self.account.get_devices() File "/config/custom_components/petkit/init.py", line 216, in get_devices rsp = await self.request(api) File "/config/custom_components/petkit/init.py", line 164, in request return await req.json() or {} File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1103, in json raise ContentTypeError( aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('http://api.petkt.com/latest/discovery/device_roster')

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 227, in _async_setup_component result = await task File "/config/custom_components/petkit/init.py", line 86, in async_setup await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 161, in async_config_entry_first_refresh raise ex homeassistant.exceptions.ConfigEntryNotReady: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('http://api.petkt.com/latest/discovery/device_roster')

    opened by Anian-igor 4
  • Error: 登录会话过期 - Session expired

    Error: 登录会话过期 - Session expired

    Hi. I was able to use the custom component for 1 day. After that, I received this error: Got petkit devices for *********@gmail.com failed: {'error': {'code': 8, 'msg': '登录会话过期,请重新登录'}} Translated to: Session expired, please login again. Even restarting HASS doesn't help. How can I fix this? Thanks.

    bug fixed 
    opened by MinhHTML5 2
  • Additional sensors for the fresh element infinity feeder (d3)

    Additional sensors for the fresh element infinity feeder (d3)

    Thanks for the integration, I submitted PR #9 that adds a few additional sensors for the d3 type of feeder

    • weight of the bowl
    • amount of food eaten
    • number of times eaten
    • fixed number of feed times

    Here's now everything I get out of my feeder Screen Shot 2022-01-23 at 12 23 34 PM

    enhancement 
    opened by ksheumaker 1
  • Added and fixed some sensors for d3 type of feeder

    Added and fixed some sensors for d3 type of feeder

    I fixed the feed_count sensor and added a few additional sensors the d3 offers, like the number of times the pet has eaten, and the total eaten amount, and weight of the bowl

    Here's what I get in HA from my D3 feeder now:

    Screen Shot 2022-01-23 at 12 23 34 PM
    opened by ksheumaker 1
  • Set feed amount on request

    Set feed amount on request

    Hello,

    Thanks for this integration, I got my two feeders connected and working. However, I have two cats and they don't eat the same amount of food at each serving.

    Is it possible to set the amount when making the call to the switch entity?

    opened by nivv 1
  • Error: Unable to import component

    Error: Unable to import component

    Hello together,

    thanks for the petkit integration for homeassistant. unfortunately i get the following error after i install the package in the custom components folder and add petkit to the configuration:

    Setup failed for petkit: Unable to import component: cannot import name 'CoordinatorEntity' from 'homeassistant.helpers.update_coordinator' (/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/update_coordinator.py)"

    What am I doing wrong?

    Thank you Kai

    opened by khkl 1
  • FRESH ELEMENT food state doesn't change to

    FRESH ELEMENT food state doesn't change to "Problem" when there is insufficient food.

    The Eversweet fountain state works fine (it changes to "Problem" when the water is almost finished) and the Pura Max also does this when the waste bin is full, but strangely the Fresh Element food_state doesn't change to Problem when there is no more food in the reservoir.

    Screenshot_20221218_194116_Chrome Screenshot_20221218_194200_Home Assistant

    Can you please check if this is a problem on the integration's end or with the API?

    Thanks!

    opened by Lxxrxns 0
  • Beginners Guide Request

    Beginners Guide Request

    Hello,

    I recently bought a Petkit Pura Max and I really appreciate your work of managing to integrate it in home assistant. It would be great if I could create some automations so my lightbulbs would light in different colors depending on the litter/trash state. However, although I tried to put together all the information I could find about this plugin, in the end I wasn't able to set it up. I only have basic skills when it comes to coding so apart from installing it and trying to edit the config.yaml file, I could not make it show in integrations.

    Would any of you be kind enough to make a step by step guide/tutorial that I could follow? It would be very much appreciated, maybe there are more people trying to set this up.

    Thank you

    opened by petrutghita 0
  • Pura Max can't use

    Pura Max can't use "cleanup" and "continue"

    if i select "cleanup", not thing happent, no error log output. if select "continue", get error log

    
    此错误来自自定义集成。
    
    Logger: custom_components.petkit
    Source: custom_components/petkit/__init__.py:769
    Integration: Petkit (documentation, issues)
    First occurred: 04:01:43 (1 occurrences)
    Last logged: 04:01:43
    
    Petkit device control failed: [{'id': 171881, 'type': 'continue', 'kv': '{"continue_action":0}'}, {'error': {'code': 2105, 'msg': '设备已停止运行,无法完成操作'}}]
    
    
    opened by Chiunownow 0
  • pet_weight in Puramax is set only the very first time of a day

    pet_weight in Puramax is set only the very first time of a day

    Hi,

    I just noticed that the sensor sensor.t4_XXXXXXXX_pet_weight is evaluated only once a day. This means that if my cats enter the litter multiple times, i just get the weight of the pet entering the litter first after midnight.

    Is it something that can be fixed? How can I help?

    Screenshot_20221203-091134

    opened by override80 1
  • pet_weight

    pet_weight "unknown" for brief period every scan interval

    Hi,

    On our PURA X and PURA MAX, every 2 minutes, the pet_weight entity is set to "unknown" for a very short period before being set back to its previous value. It only lasts a fraction of a session, but it results in two extra state changes every two minutes where nothing has actually changed. (It of course only changes the value if a cat uses the box.)

    As noted above, it's occurring on both of our petkit litter boxes. I use the default scan_interval, and both boxes show the problem at the same time, so I'm guessing it's happening every scan. I spot checked the "action" and "liquid" entities and they are not exhibiting this behavior; I didn't check the rest.

    Happy to provide additional info if it would be helpful. Thanks for any suggestions and for making this integration!

    opened by jef-pearlman 1
  • Feature Request: Petkit Water Fountain Support

    Feature Request: Petkit Water Fountain Support

    Hello, I have this service up and running on my Pura X litterbox and petkit feeder - it's probably the killer integration for me for home assistant! so Thankyou.

    I have recently bought the Petkit EVERSWEET 3 PRO water fountain, the API is exposing the following information:

    • desiccant
    • feed_amount
    • feed_times
    • state
    • food_state
    • feeding

    I presume these attributes would need assigning some form of type to be able to be used by home assistant.

    full disclosure I am a notice at coding but anything I can do to help provide support or diagnostics guidance I would be more than up for learning here.

    Thanks

    opened by cjattard 2
Owner
null
HomeAssistant - Polyaire AirTouch 4 Integration

HomeAssistant - Polyaire AirTouch 4 Integration Custom integration to add an AirTouch 4 AC Controller Installation: Copy contents of custom_components

null 7 Aug 5, 2022
A python script for Homeassistant that counts down the days to birthdays, anniversaries etc

Date Countdown A python script for Homeassistant that counts down the days to birthdays, anniversaries etc Important note I no longer use homeassistan

Marc Forth 21 Mar 12, 2022
Python Wrapper for Homeassistant's REST API

HomeassistantAPI Python Wrapper for Homeassistant's REST API Please ⭐️ the repo if you find this project useful or cool! Here is a quick example. from

Nate 29 Dec 31, 2022
Create (templateable) cameras that display qr codes in homeassistant

QRCam This custom component creates cameras displaying qrcodes. The QRCodes can be static or generated from templates. If you use a template as conten

Jannes Müller 5 Oct 6, 2022
Home Assistant custom components MPK-Lodz

MPK Łódź sensor This sensor uses unofficial API provided by MPK Łódź. Configuration options Key Type Required Default Description name string False MP

Piotr Machowski 3 Nov 1, 2022
A lightweight script for updating custom components for Home Assistant

Updater for Home Assistant This is a lightweight script for updating custom components for Home Assistant. If for some reason you do not want to use H

Alex X 12 Sep 21, 2022
Easyeda2kicad.py - Convert any LCSC components (including EasyEDA) to KiCad library

easyeda2kicad.py A Python script that convert any electronic components from LCSC or EasyEDA to a Kicad library Installation git clone https://github.

uPesy Electronics 150 Jan 6, 2023
Custom Plotly Dash components based on Mantine React Components library

Dash Mantine Components Dash Mantine Components is a Dash component library based on Mantine React Components Library. It makes it easier to create go

Snehil Vijay 239 Jan 8, 2023
This project is for a Twitter bot that monitors a bird feeder in my backyard. Any detected birds are identified and posted to Twitter.

Backyard Birdbot Introduction This is a silly hobby project to use existing ML models to: Detect any birds sighted by a webcam Identify whic

Chi Young Moon 71 Dec 25, 2022
Discord feeder for AIL

ail-feeder-discord Discord feeder for AIL Warning! Automating user accounts is technically against TOS, so use at your own risk! Discord API https://d

ail project 6 Mar 9, 2022
Cow Feeder is a bot automatically execute trade on cowswap

Cow Feeder is a bot automatically execute trade on cowswap, includes functions: Monitoring Ethereum network gas price and execute trade whe

null 6 Apr 20, 2022
HomeAssistant - Polyaire AirTouch 4 Integration

HomeAssistant - Polyaire AirTouch 4 Integration Custom integration to add an AirTouch 4 AC Controller Installation: Copy contents of custom_components

null 7 Aug 5, 2022
HomeAssistant Linux Companion

Application to run on linux desktop computer to provide sensors data to homeasssistant, and get notifications as if it was a mobile device.

Javier Lopez 10 Dec 27, 2022
A python script for Homeassistant that counts down the days to birthdays, anniversaries etc

Date Countdown A python script for Homeassistant that counts down the days to birthdays, anniversaries etc Important note I no longer use homeassistan

Marc Forth 21 Mar 12, 2022
Python Wrapper for Homeassistant's REST API

HomeassistantAPI Python Wrapper for Homeassistant's REST API Please ⭐️ the repo if you find this project useful or cool! Here is a quick example. from

Nate 29 Dec 31, 2022
Create (templateable) cameras that display qr codes in homeassistant

QRCam This custom component creates cameras displaying qrcodes. The QRCodes can be static or generated from templates. If you use a template as conten

Jannes Müller 5 Oct 6, 2022
A simple Python module for parsing human names into their individual components

Name Parser A simple Python (3.2+ & 2.6+) module for parsing human names into their individual components. hn.title hn.first hn.middle hn.last hn.suff

Derek Gulbranson 574 Dec 20, 2022
PyTorch3D is FAIR's library of reusable components for deep learning with 3D data

Introduction PyTorch3D provides efficient, reusable components for 3D Computer Vision research with PyTorch. Key features include: Data structure for

Facebook Research 6.8k Jan 1, 2023
Ranger deep learning optimizer rewrite to use newest components

Ranger21 - integrating the latest deep learning components into a single optimizer Ranger deep learning optimizer rewrite to use newest components Ran

Less Wright 266 Dec 28, 2022
unofficial library for discord components(on development)

discord.py-buttons unofficial library for discord buttons(on development) Install pip install --upgrade discord_buttons Example from discord import Cl

kiki7000 129 Dec 31, 2022