RobertD502 / home-assistant-petkit

Home Assistant integration for PetKit devices
MIT License
156 stars 24 forks source link

Pet weight rounded on pura max #51

Closed override80 closed 6 months ago

override80 commented 6 months ago

Hi,

for some reason the sensor for my cats weight is rounded since a few days ago (3400g, 3800g, etc).

Screenshot_20231223-210503

Do you have any hint? I am attaching the debug log.

2023-12-21 06:22:43.428 DEBUG (MainThread) [custom_components.petkit] Found the following PetKit devices/pets: PetKitData(user_id='xx', feeders={}, litter_boxes={100019620: LitterBox(id=100019620, device_detail={'id': xxx, 'mac': 'xx', 'sn': 'xx', 'secret': 'xx', 'createdAt': '2022-11-25T11:18:18.029+0000', 'name': 'PETKIT PURA MAX', 'hardware': 1, 'firmware': '1.456', 'firmwareDetails': [{'module': 'userbin', 'version': 2310010}, {'module': 'pics', 'version': 2220001}, {'module': 'lans', 'version': 2245001}], 'timezone': 1.0, 'signupAt': '2023-12-19T08:49:05.573+0000', 'locale': 'Europe/Rome', 'user': {'id': 'xxx', 'nick': 'xxxx', 'gender': 2, 'avatar': 'http://sandbox.img5.petkit.cn/banner/2022/10/13/6347d75a44ad08000b011e7dDzwc693i5', 'point': {'honour': 'LV0', 'rank': 0, 'growth': 17, 'icon': 'http://img5-us.petkit.cn/misc/point/n0', 'icon2': 'http://img5-us.petkit.cn/misc/point/l0', 'startGrowth': 0, 'endGrowth': 50}}, 'shareOpen': 1, 'autoUpgrade': 1, 'relation': {'userId': '100454792'}, 'withK3': 1, 'k3Id': 100028385, 'btMac': 'xxx', 'settings': {'litterFullNotify': 1, 'lackSandNotify': 1, 'workNotify': 0, 'petInNotify': 0, 'lackLiquidNotify': 1, 'deodorantNotify': 1, 'sandType': 2, 'manualLock': 0, 'lightMode': 1, 'lightRange': [0, 1440], 'autoWork': 1, 'fixedTimeClear': 0, 'fixedTimeRefresh': 0, 'downpos': 1, 'deepRefresh': 0, 'weightPopup': 1, 'autoIntervalMin': 1800, 'stillTime': 120, 'unit': 0, 'language': 'en_US', 'languageFollow': 0, 'softMode': 0, 'avoidRepeat': 0, 'underweight': 0, 'kitten': 0, 'kittenTipsTime': 0, 'stopTime': 600, 'languages': ['zh_CN', 'zh_TW', 'en_US', 'es_ES', 'ko_KR', 'it_IT', 'ja_JP', 'pt_PT', 'de_DE', 'fr_FR', 'ru_RU'], 'kittenPercent': 0.8, 'dumpSwitch': 1, 'autoRefresh': 0, 'disturbMode': 0, 'disturbRange': [1320, 360], 'relateK3Switch': 1, 'lightest': 2720, 'deepClean': 0, 'lightConfig': 2, 'bury': 0, 'lightMultiRange': [[360, 1320]], 'disturbConfig': 2, 'distrubMultiRange': [[1200, 420]], 'controlSettings': 0}, 'k3Device': {'id': 100028385, 'mac': 'a4c1388410d8', 'sn': '20220326M40469', 'secret': '7d70a1b6b1ba', 'createdAt': '2022-11-25T11:19:30.000+0000', 'updateAt': '2023-12-21T03:01:21.000+0000', 'userId': '100454792', 'name': 'The Smart Spray', 'hardware': 1, 'firmware': 39, 'settings': {'liquidLackSwitch': 1, 'fixedTimeRefresh': 0}, 'timezone': 1.0, 'relation': {'userId': '100454792'}, 'relateT4': 100019620, 'battery': 90, 'liquid': 100, 'refreshing': -1, 'lighting': -1, 'voltage': 0, 'liquidLack': 3}, 'petOutTip': 1, 'multiConfig': True, 'state': {'wifi': {'ssid': 'xxxx', 'bssid': 'xxxx', 'rsq': -32}, 'pim': 1, 'ota': 0, 'overall': 1, 'sandCorrect': 0, 'liquidReset': 0, 'sandWeight': 5731, 'sandPercent': 89, 'usedTimes': 0, 'sandType': 2, 'sandStatus': 1, 'box': 0, 'liquid': 100, 'battery': 90, 'petInTime': 0, 'power': 1, 'petError': False, 'deodorantLeftDays': 13, 'liquidLack': False, 'boxFull': False, 'liquidEmpty': False, 'sandLack': False, 'lowPower': False}, 'lastOutTime': 28, 'petOutRecords': [[14151, 28]], 'inTimes': 1, 'totalTime': 3463, 'specialLitterAd': {'adDetailUrl': 'http://m.petkit.com/app/cat_litter.html', 'adSwitch': 0, 'adLinkUrl': 'https://m.tb.cn/h.f8XZ8IM?sm=846b3a', 'label': '跨年', 'labelUrl': 'http://sandbox.img5.petkit.cn/post/2021/12/7/61af3624a8c9cc16b23736e8ywX6LUO8P', 'labelName': '专用猫砂'}, 'maintenanceTime': 1702625399, 'petInTipLimit': 15}, device_record=[{'deviceId': xxx, 'eventType': 10, 'timestamp': 1703127379, 'content': {'timeIn': 1703127351, 'timeOut': 1703127379, 'autoClear': 1, 'interval': 2, 'petWeight': 3426}, 'enumEventType': 'pet_out', 'userId': 'xxx', 'petId': '100640035', 'subContent': [{'deviceId': xxx, 'eventType': 5, 'timestamp': 1703127680, 'content': {'startTime': 1703127501, 'startReason': 0, 'litterPercent': 89, 'box': 0, 'result': 0, 'boxFull': False}, 'enumEventType': 'clean_over', 'userId': '100454792', 'subContent': []}], 'avatar': 'http://img5-us.petkit.cn/pavatar/2022/11/26/63811ccd6a5dff000bec207dcgg89kmEi', 'petName': 'Nespola'}], statistics={'statisticTime': '20231221', 'totalTime': 28, 'times': 1, 'avgTime': 28, 'statisticInfo': [{'statisticDate': '20231221', 'petTimes': 1, 'petTotalTime': 28, 'petWeight': 3426, 'petId': 'xxx', 'petName': 'Nespola', 'xTime': 14151}], 'petIds': [{'id': 'xxx', 'name': 'Nespola'}]}, type='t4', manually_paused=False, manual_pause_end=None)}, water_fountains={}, pets={100640033: Pet(id='100640033', data={'activeDegree': 0, 'avatar': 'http://img5-us.petkit.cn/pavatar/2022/11/26/63811cb8b6fc7f000cef8a05EbNK27Txp', 'birth': '2013-07-20', 'category': {'avatar': 'http://img2.petkit.cn/dogavatar/ljm_-gPOorp5C4PK', 'id': 10042, 'name': 'Mix'}, 'createdAt': '2022-11-25T11:14:58.000Z', 'deviceCount': 0, 'emotion': 0, 'familyId': xxxx, 'femaleState': 2, 'gender': 2, 'id': 'xxxx', 'isRoyalCaninPet': 0, 'maleState': 0, 'name': 'Vaniglia', 'owner': {'deviceCount': 0, 'id': '100454792', 'petCount': 0, 'userCount': 0}, 'size': {'id': 1, 'name': 'Standard'}, 'states': [], 'type': {'id': 2, 'name': 'Cat'}, 'updatedAt': '2023-11-15T21:47:07.000Z', 'weight': 3.579, 'weightControl': 3, 'weightControlTips': {}, 'weightLabel': 'Normal'}, type='Cat'), 100640034: Pet(id='100640034', data={'activeDegree': 0, 'avatar': 'http://img5-us.petkit.cn/pavatar/2022/11/26/63811c9db6fc7f000cef8a02Kg3tlQBuN', 'birth': '2013-07-20', 'category': {'avatar': 'http://img2.petkit.cn/dogavatar/ljm_-gPOorp5C4PK', 'id': 10042, 'name': 'Mix'}, 'createdAt': '2022-11-25T11:16:21.000Z', 'deviceCount': 0, 'emotion': 0, 'familyId': 100454792, 'femaleState': 2, 'gender': 2, 'id': '100640034', 'isRoyalCaninPet': 0, 'maleState': 0, 'name': 'Cannella', 'owner': {'deviceCount': 0, 'id': '100454792', 'petCount': 0, 'userCount': 0}, 'size': {'id': 1, 'name': 'Standard'}, 'states': [], 'type': {'id': 2, 'name': 'Cat'}, 'updatedAt': '2023-12-20T14:12:06.000Z', 'weight': 3.919, 'weightControl': 3, 'weightControlTips': {}, 'weightLabel': 'Normal'}, type='Cat'), 100640035: Pet(id='100640035', data={'activeDegree': 0, 'avatar': 'http://img5-us.petkit.cn/pavatar/2022/11/26/63811ccd6a5dff000bec207dcgg89kmEi', 'birth': '2013-06-21', 'category': {'avatar': 'http://img2.petkit.cn/dogavatar/ljm_-gPOorp5C4PK', 'id': 10042, 'name': 'Mix'}, 'createdAt': '2022-11-25T11:16:57.000Z', 'deviceCount': 0, 'emotion': 0, 'familyId': 100454792, 'femaleState': 2, 'gender': 2, 'id': '100640035', 'isRoyalCaninPet': 0, 'maleState': 0, 'name': 'Nespola', 'owner': {'deviceCount': 0, 'id': '100454792', 'petCount': 0, 'userCount': 0}, 'size': {'id': 1, 'name': 'Standard'}, 'states': [], 'type': {'id': 2, 'name': 'Cat'}, 'updatedAt': '2023-12-20T05:51:10.000Z', 'weight': 3.4, 'weightControl': 3, 'weightControlTips': {}, 'weightLabel': 'Normal'}, type='Cat')}, purifiers={})
2023-12-21 06:22:43.428 DEBUG (MainThread) [custom_components.petkit] Finished fetching petkit data in 0.875 seconds (success: True)
RobertD502 commented 6 months ago

The native state returned is in kilograms (this is obtained by dividing the petWeight by 1000 and rounding to 1 decimal). In your log it would be 3426 / 1000 = 3.4 Kg. If you are displaying the weight in grams the 3.4 Kg gets reported as 3400 grams.

[{'statisticDate': '20231221', 'petTimes': 1, 'petTotalTime': 28, 'petWeight': 3426, 'petId': 'xxx', 'petName': 'Nespola', 'xTime': 14151}]

override80 commented 6 months ago

OK, because i am pretty sure that I displayed 3426 or whatever weight with grams precision at a certain point. Just asking because I have 2 of my cats whose weight is pretty close, having precision at gram level could help.

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.