homebridge-petkit-pet-feeder
v3.2.2
Published
control all your types of petkit pet feeders from homekit, get full use of iOS automation.
Downloads
47
Maintainers
Readme
homebridge-petkit-pet-feeder
1) Description
control your petkit pet feeder from homekit, get full use of iOS automation.
features
- uses a fan speed to control the meal amount;
- uses a switch to commit the drop;
- uses a switch to control the Petkit pet feeder light mode;
- uses a switch to control the Petkit pet feeder manual lock;
- uses a occupancy to indicate food storage status;
- uses a filter maintenance to indicate desiccant status(include auto reset desiccant left days, this may not show in homekit);
- uses a battery service to indicate device power status(include power level, charging status and low battery alert in Homekit)
- can fetch device info from Petkit server and shows in Homekit.
limitations
- currently this plugin for homebridge just tested with Petkit feeder Element SOLO (official store link), and this plugin currently only tested and works in Asia(include China mainland), United States and Europe, other area may need more work.
- to continuously use this plugin you should login Petkit app and never logoff, this plugin uses session id from the app and it will change every time you logoff and relogin.
- because version >= 2.x.x is developed on a dynamic platform plugin, and not implement auto remove deleted device(s), so you may need to delete cached accessories manually.
- ......
2) How to setup
Firstly, setup your Petkit mobile app.
Goto App Store, download Petkit mobile app, register, login, add device. before use this plugin you MUST make sure the app works fine with you.
- for China mainland users, download “小佩宠物”
- for those Asia users outside China mainland, you should download "PetKit(International)"
- for users not from Asia, like United States, Europe, etc. you also should download "PetKit(International)", but the API url address may not the same, this plugin may or may not works with you, if you are experienced in network, you could use "Quantumult X" to capture app network records, submit the api address to me or just create a PR or just modify this plugin for your own.
Secondly, prepare to capture Petkit app http request.
Please goto this wiki page to find more detail.
Finally, retrieve infomation.
you should provide one critical infomation to this plugin: X-Session, if you have more than one Petkit feeder mini device, then you should alse provide deviceId in the header field of the config.json file.
Be aware of that, to minimize the effect to the Petkit server with unnecessary http requests, the plugin just update device status more than 10s interval, which means the status will bufferd at lease 10s.
- X-Session: this value will change every time you login you Petkit app, so do not logoff your Petkit app unless necessary.
- deviceId: this value indicate which device you wanna to control. If you just have one Petkit feeder device, you can ignore this value.
here is a example of Quantumult X capture data page:
3) Configure
config.json fields
| field name | type | required | default | range | description | | :----------: | :----: | :------: | :------------------: | :------------------: | :----------------------------------------------------------- | | platform | string | yes | 'petkit_pet_feeder' | 'petkit_pet_feeder' | Must be 'petkit_pet_feeder' in order to use this plugin. | | log_level | int | no | 2 | 1,2,3,4,9 | one of these values:- 1: Debug- 2: Info- 3: Warn- 4: Error- 9: None | | devices | object | yes | --- | --- | Petkit Feeder device config.See more detail info at devices field below. |
devices field
| field name | type | required | default | range | description | | :-------------------------------: | :----: | :------: | :----------------------------------------: | :---------------------------------: | ------------------------------------------------------------ | | location | string | yes | 'international' | 'cn','asia','international' | China users:'cn';Asia users: 'asia';International (United States/Europe) users: 'international';other location because lack of infomation, not sure it will work.You can find more info here. | | model | string | no | 'D4' | 'FeederMini','Feeder','D4','D3' | Petkit Feeder Mini: 'FeederMini'Petkit Feeder Element: 'Feeder'Petkit Feeder Element SOLO: 'D4'Petkit Feeder Element Infiniti: 'D3' | | deviceId | string | tbd | --- | --- | your Petkit feeder element SOLO Id, which is buildin your device, will never change. If you just have one Petkit feeder device, you can ignore this value.If you just have more than one Petkit Feeder device, you must set this value. | | headers | array | yes | --- | --- | http request headers.See more detail info at headers field below. | | enable_http_retry | | no | false | true/false | Enable or disable HTTP retry function, useful when your device or homebridge has a bad internet connection. | | http_retry_count | int | no | 3 | 1 to 5 | max retry times when a http request failed. | | DropMeal_name | string | no | 'DropMeal' | --- | name of DropMeal switch in HomeKit. | | MealAmount_name | string | no | 'MealAmount' | --- | name of MealAmount fan speed in HomeKit. | | FoodStorage_name | string | no | 'FoodStorage_Empty'or'FoodStorage' | --- | name of FoodStorage indicator in HomeKit.Note: if reverse_foodStorage_indicator value is set to true, then the default name is 'FoodStorage_Empty', otherwise 'FoodStorage' | | DesiccantLevel_name | string | no | 'DesiccantLevel' | --- | name of DesiccantLevel indicator in HomeKit. | | ManualLock_name | string | no | 'ManualLock' | --- | name of ManualLock switch in HomeKit. | | LightMode_name | string | no | 'LightMode' | --- | name of LightMode switch in HomeKit. | | Battery_name | string | no | 'Battery' | --- | name of Battery indicator in HomeKit. | | BlockDoor_name | string | no | 'BlockDoor' | --- | name of BlockDoor indicator in HomeKit. | | enable_polling | bool | no | true | true/false | Automatically update device info from Petkit server. | | polling_interval | int | no | 60 | 60 to 3600 | update device info interval from Petkit server(s). | | enable_manualLock | bool | no | false | true/false | if enabled, a switch will show in homekit to control the manual lock of the feeder. | | enable_lightMode | bool | no | false | true/false | if enabled, a switch will show in homekit to control the lighe mode of the feeder. | | reverse_foodStorage_indicator | bool | no | false | true/false | normally, the occupancy will show an alert in homekit when there is enough food in the feeder, in which situation may not so recognizable, so you can reverse the status but set this value to true, so when there is not much food, it can show an alert in homekit. | | ignore_battery_when_charging | bool | no | false | true/false | Ignore battery low level alerm when device connected to a power source.And battery function is disabled when using a Petkit Feeder Element device. | | fast_response | bool | no | false | true/false | if set to true, then when received a Homekit set request, return immediately, ignore the result.this is useful when your homebridge or Petkit device has a bad internet connection. | | meal_amount | int | yes | 8 | 0 to 10 | Meal amount set defaults. | | feed_daily_list | array | no | --- | --- | feed daily list.See more detail info at feed daily list field below. | | enabled_daily_feeds | bool | no | true | true/false | enable/disable feed daily plan.(the choice is for every day of the week. | | overwrite_daily_feeds | bool | no | false | true/false | overwite feed daily plan with the data of this plugin. |
headers field
| field name | type | required | default | range | description | | :-----------: | :----: | :------: | :------: | :-------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | X-Session | string | yes | --- | --- | Tell server who you are. This changes everytime you login Petkit app. | | X-Api-Version | string | prefer | '7.18.1' | --- | For China mainland users, this field is not necessary, but for users outside China mainland, this field is optional, if not provided, then the default value will be used. but we recommand to fufill this field. | | X-Timezone | int | no | 8 | -12 to 12 | Your local timezone offset, UTC time. If autoDeviceInfo is set to true, it will overwrited with the timezone of your device, which is set in your Petkit app. |
we recomand you entered all the headers you captured. If you don't want to do so, please ensure header "X-Session" is correctly entered.
feed daily list field
| field name | type | required | default | range | description |
| :-----------: | :----: | :------: | :------: | :-------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name | string | no | --- | --- | food name. |
| amount | int | no | 1 | 1-10 | amount food dispensed. |
| time | int | no | 1 | 1 to 86400 | time in seconds the food will be dispensed. |
example of config.json file
"platforms": [{
"log_level": 2,
"devices": [
{
"headers": [
{
"key": "X-Session",
"value": "xxxxxx"
}
],
"location": "international",
"model": "D4",
"enable_http_retry": false,
"http_retry_count": 3,
"DropMeal_name": "DropMeal",
"MealAmount_name": "MealAmount",
"FoodStorage_name": "FoodStorage",
"DesiccantLevel_name": "DesiccantLevel",
"ManualLock_name": "ManualLock",
"LightMode_name": "LightMode",
"Battery_name": "Battery",
"BlockDoor_name": "BlockDoor",
"enable_polling": true,
"polling_interval": 60,
"enable_desiccant": true,
"alert_desiccant_threshold": 7,
"enable_autoreset_desiccant": true,
"reset_desiccant_threshold": 5,
"enable_manualLock": true,
"enable_lightMode": true,
"reverse_foodStorage_indicator": true,
"fast_response": true,
"meal_amount": 8,
"enabled_daily_feeds": true,
"overwrite_daily_feeds": true,
"feed_daily_list": [
{
"name": "Desayuno",
"amount": 8,
"time": 25200
},
{
"name": "Comida",
"amount": 6,
"time": 46800
},
{
"name": "Cena",
"amount": 8,
"time": 72000
}
]
}
],
"platform": "petkit_pet_feeder"
}]
4) How to contribute
everyone is welcome to contribute to this plugin. PR/issue/debug all are welcome.
or you can send me an e-mail: [email protected]
5) Buy me a coffee
if you think my work helps you, and wanna thank me, please consider buy me a coffee: https://paypal.me/jubepue