flifloo / ha_petlibro

PETLIBRO Home Assistant integration
GNU General Public License v3.0
17 stars 14 forks source link

[Region]: Add Japan region #17

Open marcelocf opened 4 days ago

marcelocf commented 4 days ago

Device model name

Granary Feeder

Device model number

PLAF103

Device type

Feeder

What state, statistic or control do you want to be reported in the integration ?

Hello there; sorry for using the wrong template and butchering the title. There wasn't a template for a new region and this is not exactly a bug.

I am registered in the Japan region and as such it would be nice to have it added to the integration. It is understandable if this is too much hassle, in which case I guess I can reset it all and set it up as US (although I would really rather have it set up in my actual country of residence).

When checking the DNS logs for what the app queries, I found both a1.tuyaus.com and m1.tuyaus.com (the later apparently being the MQTT address for Tuya). Oddly enough nothing like api.jp.petlibro.com , which is what I would expect.

Also please let me know if I can be of help.

The feeder I have is the only one supported by the platform currently.

Thank you.

Available to help integrate the new device

marcelocf commented 4 days ago

Quick update.

On my first tests (when in Japan region in the petlibro app) I remember (memory might be playing tricks on me) receiving "user doesn't exist" type of error. So I factory reset the device, logout and then tried making a new account in US region. The app complained about me having an account already so I logged in, using US region this time, and re-added the device.

My tablet that was still logged in Japan region, and was able to communicate with the device after re-adding.

This time, in the integration, I got Unexpected Error message in the interface, but in the logs:

Logger: custom_components.petlibro.config_flow
Source: custom_components/petlibro/config_flow.py:97
integration: PETLIBRO ([documentation](https://github.com/flifloo/ha_petlibro))
First occurred: 7:17:31 PM (3 occurrences)
Last logged: 9:35:19 PM

    Unexpected exception: Code: 1002, Message: 邮箱格式错误
    Unexpected exception: Code: 1101, Message: MEMBER_NOT_EXIST

Traceback (most recent call last):
  File "/config/custom_components/petlibro/config_flow.py", line 97, in _validate_input
    self.token = await api.login(data[CONF_EMAIL], data[CONF_PASSWORD])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/petlibro/api.py", line 123, in login
    data = await self.session.post("/member/auth/login", json={
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/petlibro/api.py", line 77, in post
    return await self.request("POST", path, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/petlibro/api.py", line 71, in request
    raise PetLibroAPIError(f"Code: {data.get('code')}, Message: {data.get('msg')}")
custom_components.petlibro.exceptions.PetLibroAPIError: Code: 1002, Message: 邮箱格式错误

According to google "邮箱格式错误" means email format error in Chinese (this doesn't look Japanese to me indeed).

So maybe this is a bug?