hasscc / petkit

🐱 Petkit feeder components for HomeAssistant
Apache License 2.0
117 stars 16 forks source link

translate Chinese messages in states.petkit_device_state.attributes.desc #16

Open rethamazur opened 2 years ago

rethamazur commented 2 years ago

Hello everyone, I recently began to use Home Assistant, so please forgive my inexperience.

I successfully installed this custom component (btw, great work!) but I'm struggling to find a way to translate the messages from the devices I have (3 fresh element mini feeders and a pura max litter box).

On the feeders this message is "Next feeding time" followed by hh:mm time, and on the pura max it reports "last utilization", again followed by time in hh:mm format. From midnight until the first daily visit from a cat the reported message is like "Cat litter level ok"

Does anybody have a suggestion?

pura max. after midnight, BEFORE the first utilization image

pura max, after the first cat's visit of the day image

on the fresh element mini image

al-one commented 2 years ago

The descriptions are from the petkit cloud server and this component cannot translate them.

rethamazur commented 2 years ago

ok, thank you for the explanation. Could it be possible to make a simple translating-ish script? Example: if text from Desc attribute is "chinese_words_for_next_feeding_time hh:mm" than set the value to "Next Feeding: hh:mm"

Of course this would be useless if the problem with petkit's server persists.

igorsantos07 commented 1 year ago

I'd rather call this sort of a bug/feature request... It's possible to add X-Locale: en_US to the requests and responses come in English - at least error messages do. This could be a config option, if there's interest in keeping the Chinese messages for those who want it, but I'd default to English since that's the standard language in which HA is documented and such.

I discovered this by fiddling with https://reqbin.com/vljzzpwl (trying to find wether lack of P3 details is an API issue or missing implementation) and some reversed-engineering docs from https://github.com/morganpartee/pyPetKit (which do not have any docs on P3, but I would suggest the developer to join forces with @morganpartee since he seems to be interested in integrating some stuff in HA as well :)