tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
882 stars 207 forks source link

Add support for Ped Feeder device category cwwsq #581

Open kbromberger opened 3 years ago

kbromberger commented 3 years ago

Device normal info

Device info: 2021-10-15 11:14:31 DEBUG (SyncWorker_1) [tuya iot] Response: { "result": [ { "active_time": 1634256116, "biz_type": 0, "category": "cwwsq", "create_time": 1634172057, "icon": "smart/icon/ay1541472742486ZYDmd/dcb839f4a543a7bd03f8353bc3d96c91.jpg", "id": "xxxxd29xx96", "ip": "", "lat": "", "local_key": "", "lon": "", "model": "", "name": "WiFi Feeder", "online": true, "owner_id": "52314000", "product_id": "4gz4aqezetbmevao", "product_name": "WiFi Feeder", "status": [ { "code": "meal_plan", "value": "fwYACAF/EAAIAQ==" }, { "code": "manual_feed", "value": 4 }, { "code": "feed_state", "value": "standby" }, { "code": "factory_reset", "value": false }, { "code": "feed_report", "value": 8 } ], "sub": false, "time_zone": "-07:00", "uid": "***", "update_time": 1634294135, "uuid": "11f8b7e7661148cd" } ], "success": true, "t": 1634321671510 }

Device specifications : 2021-10-15 11:14:31 DEBUG (SyncWorker_1) [tuya iot] Request: method = GET, url = https://openapi.tuyaus.com/v1.0/devices/xxxx29xx96/specifications, params = None, body = None, t = 1634321671534 2021-10-15 11:14:31 DEBUG (Thread-20) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_xxxx8345b2f8' 2021-10-15 11:14:31 DEBUG (SyncWorker_1) [tuya iot] Response: { "result": { "category": "cwwsq", "functions": [ { "code": "meal_plan", "type": "Raw", "values": "{}" }, { "code": "manual_feed", "type": "Integer", "values": "{\"min\":1,\"max\":12,\"scale\":0,\"step\":1}" }, { "code": "factory_reset", "type": "Boolean", "values": "{}" } ], "status": [ { "code": "meal_plan", "type": "Raw", "values": "{}" }, { "code": "manual_feed", "type": "Integer", "values": "{\"min\":1,\"max\":12,\"scale\":0,\"step\":1}" }, { "code": "feed_state", "type": "Enum", "values": "{\"range\":[\"standby\",\"feeding\"]}" }, { "code": "factory_reset", "type": "Boolean", "values": "{}" }, { "code": "feed_report", "type": "Integer", "values": "{\"min\":0,\"max\":12,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1634321671640 }

DivanX10 commented 1 year ago

There is no feed button, there are only sliders. When you change the number in the Feed slider, then the feed is poured, and where is the button? Can you add a feed button?

image

Seth10001 commented 1 year ago

How is meal_plan decoded? There isn't any good documentation on how to decode this

Seth10001 commented 1 year ago

Actually just realized it's base64 encoded!

binascii.hexlify(base64.standard_b64decode('QAAAAgE='), '/')

# '40/00/00/02/01'
# 'occurance/hour/minute/portions/enable'
DivanX10 commented 1 year ago

In IT Tuya, I looked at the functions of the auto feeder and did not see the button. As a result, I made my own button. The button works with the history. pressed the button, the manual_feed slider is set to 1 and after 2 seconds returns to where it was, as a result, the feed is poured perfectly. Of course, I don't understand the developers why they didn't implement a normal button

{ "result": { "category": "cwwsq", "functions": [ { "code": "meal_plan", "type": "Raw", "values": "{}" }, { "code": "manual_feed", "type": "Integer", "values": "{\"unit\":\"\",\"min\":1,\"max\":6,\"scale\":0,\"step\":1}" }, { "code": "slow_feed", "type": "Boolean", "values": "{}" }, { "code": "voice_times", "type": "Integer", "values": "{\"min\":0,\"max\":10,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "meal_plan", "type": "Raw", "values": "{}" }, { "code": "manual_feed", "type": "Integer", "values": "{\"unit\":\"\",\"min\":1,\"max\":6,\"scale\":0,\"step\":1}" }, { "code": "slow_feed", "type": "Boolean", "values": "{}" }, { "code": "voice_times", "type": "Integer", "values": "{\"min\":0,\"max\":10,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 0000000000, "tid": "xxxxxxxxxxxxxxxxxxxxxxxxxx" }

DivanX10 commented 1 year ago

Through the integration of LocalTuya recognized almost all the functions, and some sensors are missing in the cloud. Below is the entity table for the Smart Feeder S36 CWWSQ auto feeder. It should be added. For some reason, there is more function in LocalTuya than in cloud Tuya

image