elfive / homebridge-petkit-feeder-mini

control your petkit feeder mini from homekit, get full use of iOS automation
Apache License 2.0
31 stars 10 forks source link

After feeding, the DropMeal switch remains on #26

Closed League2EB closed 2 years ago

League2EB commented 3 years ago

After opening the home app and turning on the DropMeal switch, feeding was successful

But the switch does not turn off automatically and displays "no response".

  1. NodeJS version: v14.17.3
  2. Homebridge version: v1.3.4
  3. Plugin version: v2.1.4
  4. Example of configure(REMOVE sensitive info!):
        {
            "log_level": 2,
            "devices": [
                {
                    "headers": [
                        {
                            "key": "X-Session",
                            "value": "xxx"
                        }
                    ],
                    "location": "cn",
                    "model": "FeederMini",
                    "deviceId": "506348",
                    "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",
                    "enable_polling": true,
                    "polling_interval": 60,
                    "enable_desiccant": false,
                    "alert_desiccant_threshold": 7,
                    "enable_autoreset_desiccant": false,
                    "reset_desiccant_threshold": 5,
                    "enable_manualLock": true,
                    "enable_lightMode": true,
                    "reverse_foodStorage_indicator": true,
                    "ignore_battery_when_charging": false,
                    "fast_response": false
                }
            ],
            "platform": "petkit_feeder_mini"
        }
  1. Logs(REMOVE sensitive info and homebridge debug mode):

elfive commented 3 years ago

first, launch Petkit app, and check the feeder status. then I recomand set "fast_response" to true, which should very helpful when feeder have a "bad" network connection.

League2EB commented 3 years ago

first, launch Petkit app, and check the feeder status. then I recomand set "fast_response" to true, which should very helpful when feeder have a "bad" network connection.

@elfive

Thanks for your help. This problem has been eliminated after fast_Response is enabled BTW, is it unavailable in battery mode?

This is a response to battery mode Log !

[
   "DEBUG"
]{
   "result":{
      "createdAt":"2021-08-25T08:05:42.865Z",
      "feed":{
         "deviceId":506348,
         "isExecuted":1,
         "isLock":1,
         "items":[

         ],
         "repeats":"1,2,3,4,5,6,7",
         "suspended":1,
         "userId":"754691"
      },
      "firmware":"1.394",
      "firmwareDetails":[
         {
            "module":"userbin",
            "version":2003001
         }
      ],
      "hardware":1,
      "id":506348,
      "locale":"Asia/Taipei",
      "mac":"3e6105d4b6f2",
      "name":"智能喂食器Mini",
      "relation":{
         "userId":"754691"
      },
      "secret":"026a251456803e72",
      "settings":{
         "desiccantNotify":1,
         "feedNotify":1,
         "foodNotify":1,
         "lightMode":1,
         "lightRange":[
            0,
            1440
         ],
         "manualLock":1,
         "reBatteryNotify":1
      },
      "shareOpen":0,
      "signupAt":"2021-08-25T10:02:29.917Z",
      "sn":"55210419B60065",
      "state":{
         "batteryPower":4,
         "batteryStatus":1,
         "desiccantLeftDays":30,
         "errorPriority":0,
         "feeding":0,
         "food":1,
         "ota":0,
         "overall":6,
         "pim":2,
         "runtime":2130,
         "wifi":{
            "bssid":"244bfe9c9f40",
            "rsq":-49,
            "ssid":"League2eb2.4"
         }
      },
      "timezone":8,
      "type":0,
      "user":{
         "gender":2,
         "id":"754691",
         "nick":"League2eb",
         "point":{
            "endGrowth":50,
            "growth":30,
            "honour":"LV0",
            "icon":"http://img5.petkit.cn/misc/point/s0",
            "icon2":"http://img5.petkit.cn/misc/point/l0",
            "rank":0,
            "startGrowth":0
         }
      }
   }
}

My guess is that the device is dormant in battery mode

League2EB commented 3 years ago

I found out when I got the saveDailyFeed API

'saveDailyFeed': 'http://api.petktasia.com/latest/feeder/save_dailyfeed?deviceId={}&day={}&time={}&amount={}',

In battery mode, cannot set an action less than 10 minutes from the current time ,right ? It is observed that there are certain restrictions on the machine I understand that there is no way to modify an API already written on the machine Is it possible to add feature like this

if battery.status == on {
 currenttime + 10min
 saveDailyFeed
}

Besides, I can't think of a better way thx all !

elfive commented 3 years ago

In battery mode, cannot set an action less than 10 minutes from the current time ,right ? honestly, I did not dig that deep when feeder is in battery mode, maybe there is some restrictions, and unfortunately nothing I can do to avoid that. and I have a question: when device in battery mode, can you perform drop meal "now" using Petkit app?

If you wanna perform drop meal action sometime(e.g. 10 minutes) later after "turning on the DropMeal switch" in homekit when feeder in battery mode, I can publish an update after some code and test done.

League2EB commented 3 years ago

If you wanna perform drop meal action sometime(e.g. 10 minutes) later after "turning on the DropMeal switch" in homekit when feeder in battery mode, I can publish an update after some code and test done.

Ok, I appreciate it very much

But as I understand it, in battery mode

homebridge-petkit-feeder-mini basically doesn't work, right?

homebridge-petkit-feeder-mini only be used in charge mode?

League2EB commented 3 years ago

还是很感谢作者的协助,上面使用英文来做询问是因为希望同时可以协助外国的朋友理解这个情况

这裡还是使用中文做问题的梳理吧

主要是当设备使用电池模式时,api中的time栏位只要不小于当前时间仍然可以触发

但若time栏位的时间小于当前时间的十分钟内,则加餐动作一定失败(但是不會有Error Log)

目前猜测应该是设备端裡面做了阻挡,目的是为了省电

猜测餵食器裡面写了判断「如果是电池模式下,收到的触发时间小于十分钟,那就retuen」

但因为想不到、也不可能去修改餵食器的韧体代码,所以提出「若当前是电池模式,加餐时间必须加10分钟」的需求

再次感谢。

补充:在Petkit的APP应用中,电池模式下亦无法立即加餐,只能预约十分钟后的加餐
elfive commented 3 years ago

需要明确一点的是,插件只用来辅助 Feeder 喂食,并不是旨在替换 Petkit app。 如果是定期的喂食,我依然推荐使用 Petkit app 指定 feed plan 实现而非使用 homekit 自动化。 我个人使用这个插件,只是想实现 siri 语音控制和家里没人时主动出粮这两个功能。

但若time栏位的时间小于当前时间的十分钟内,则加餐动作一定失败(但是不會有Error Log)

插件是向 Petkit 服务器发送指令,不能直接向 Feeder 发送指令。 要验证传送给 Petkit 服务器的指令有没有正确执行,需要插件主动查询,这个操作要求插件记录部分信息,用来核对指令。 加上 Homekit 虽然可以用 indicator 等报告,但是对用户并不友好。所以这个插件并没有实现相关的错误报告功能, 也就不会有指令是否成功执行的结果日志显示。 错误相关的功能,仍然需要使用 Petkit app 去侦测显示。

League2EB commented 3 years ago

@elfive 好的,我理解您制作这款插件的主要用途 我的目的也是使用Siri来作为控制,但您似乎误会我的意思了。

主要是电池模式下您的插件无法运行,而我发现只要在电池模式下把喂食指令的api中的time加上10分钟后即可触发。

这是可以让您实现的吗?就是多加一个判断是否为电池模式。

补充:目前住家状况难以使用充电模式😔

万分感谢!

elfive commented 3 years ago

可以,不过发布前我可能要自己先测试一下,预计最迟周日因该可以发布

elfive commented 3 years ago

after some code and test, I found if device not charging(going offline), I can't change the feeding plan. server will report an error to me: {"error":{"code":1504,"msg":"Device is offline,the feed plan can't be edited."}} so I launched Petkit app, and tried again, I got the same error, which means cannot schedule plans or change plans when device not charging. Maybe my feeder is different from yours, I'm using the very first version of Petkit Feeder mini with plastic food holder, yours i guess comes with stainless steel, but I'm not sure, just say maybe. If you wanna schedule a plan 10 min(s) later anyway, and it tested work fine with your device, let me know, I will publish a release, until then, it's sad that no release will be published. thank you, and looking forward for your reply.

经过一些代码和测试,我发现当喂食器没有充电(进入离线模式),我不能对喂食计划进行任何更改。 在这种情况下,服务器回返回一个错误给我:{"error":{"code":1504,"msg":"Device is offline,the feed plan can't be edited."}} 于是,我打开Petkit应用程式,看看是否能通过应用修改喂食计划,不过我还是得到了一样的错误信息,这可能表示目前没有办法在未充电的情况下修改喂食计划。 可能是由于我的喂食器是最初的那个版本(使用塑料碗),我猜测你的喂食器是搭配的不锈钢碗。当然这只是我的猜测。 如果你依旧想要10分钟以后出食物的功能,并且你可以使用Petkit应用程式在离线模式下配置一个10分钟以后的喂食计划,请告诉我,我会在收到你的答复后发布一个更新版本,不过在此之前,我不会发布这个更新。 谢谢,期待你的回复。