miercuri, 16 noiembrie 2022

Configure a Tuya pet feeder with Home Assistant and LocalTuya



Today I got myself a WiFi pet feeder for my cat, so I can control her food portions while I am not at home. The device is marketed as Grunluft PP003 but underneath is just a Tuya device, so we should be able to use it with the LocalTuya integration for Home Assistant. Just... it doesn't work. The device is detected by the integration, but when we try to add it it throws an error saying Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists. Let's see how can we fix that.

I will assume that you went through the steps to configure LocalTuya and you already have your Client ID and Client Secret. You will also need to add the device into the Devices tab of your Tuya IoT project and get the device's local key by installing the tinytuya Python module and running python3 -m tinytuya wizard to query and configure local Tuya devices.

After installing localtuya through HACS or by manually adding it to custom_components, add a new LocalTuya integration in Home Assistants integration page and check Do not configure a Cloud API account, since we already have everything we need to set up the integration. After the integration is added, click on the Configure button and select Add a new device in the LocalTuya Configuration popup. Select your device and in the next step replace the Device ID field's value with the value of the "id" field returned by tinytuya:


Also, fill the "key" value returned by tinytuya into the Local key field and give your device a nice name. Leave 3.3 selected for the protocol and for Manual DPS add 101, which is the indicator light status datapoint, and 239, which is the empty/full status of the food bucket. There are many other datapoints for night mode, memory card status and so on, if you're interested into getting the DPs for those see the Zigbee2MQTT great documentation about finding them.

After submitting the form, select switch as a platform for the newly created entity type, then in the next step make sure 101 is selected for the ID, give it a suggestive name, e.g. Indicator Light. Submit this and for the next entity select binary_sensor, make sure to uncheck Do not add any more entities, give it again a name (e.g. Food Bucket Empty), for the On Value set less and for the Off Value set full. Finally, click on Submit and you should now have a new device with a switch entity and a binary sensor available. Don't worry about the Food Bucket Empty sensor being unavailable, it will be updated as soon as it gets updated (you can check this by covering/uncovering the sensors inside the bucket).

Triggering the feeding motor require to manually set a value for the 245 datapoint. For that, go to Services tab in Developer tools (/developer-tools/service) and call the localtuya.set_dp service with the following data:

device_id: <your_device_id>
dp: 245
value: 1


You can adjust the value for the number of portions to be served. Be aware that the datapoint's ID might be different in your case, I found mine in the Tuya's IoT platform dashboard, under Device Debugging with a chinese name, 喂食下发.

That's it! I hope I didn't forgot anything. Feel free to experiment with any other DPs and maybe leave a comment about your discoveries so others can also profit from them.


2 comentarii :

Anonim spunea...

Did you manage to make the camera and speaker working?

Ovidiu spunea...

Camera stream can be accessed via RTSP at rtsp://admin:admin@DEVICE_IP:554/1. I never tried to make the speaker working.