home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.04k stars 29.7k forks source link

Tami4 integration - configuration error #121675

Closed tomers closed 1 month ago

tomers commented 1 month ago

The problem

I tried to configure the Tami4 integration, but failed after the SMS verification stage:

image

@Guy293, I would like to help you with debugging this issue. Please feel free to contact me personally (my details should be in my Github profile).

What version of Home Assistant Core has the issue?

core-2024.7.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tami4

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tami4

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

In logs, I see the following entries (I am not sure the first entry is related):

Logger: py.warnings
Source: components/tami4/__init__.py:5
First occurred: 1:56:34 PM (5 occurrences)
Last logged: 1:56:34 PM

/usr/local/lib/python3.12/site-packages/pypasser/utils.py:10: SyntaxWarning: invalid escape sequence '\/' regex = '(?P<endpoint>[api2|enterprise]+)\/anchor\?(?P<params>.*)'
/usr/local/lib/python3.12/site-packages/pydub/utils.py:300: SyntaxWarning: invalid escape sequence '\(' m = re.match('([su]([0-9]{1,2})p?) \(([0-9]{1,2}) bit\)$', token)
/usr/local/lib/python3.12/site-packages/pydub/utils.py:301: SyntaxWarning: invalid escape sequence '\(' m2 = re.match('([su]([0-9]{1,2})p?)( \(default\))?$', token)
/usr/local/lib/python3.12/site-packages/pydub/utils.py:310: SyntaxWarning: invalid escape sequence '\(' elif re.match('(flt)p?( \(default\))?$', token):
/usr/local/lib/python3.12/site-packages/pydub/utils.py:314: SyntaxWarning: invalid escape sequence '\(' elif re.match('(dbl)p?( \(default\))?$', token):

and:

Logger: root
Source: /usr/local/lib/python3.12/site-packages/Tami4EdgeAPI/Tami4EdgeAPI.py:251
First occurred: 1:56:59 PM (1 occurrences)
Last logged: 1:56:59 PM

OTP Submission Failed, response: {'status': 403, 'message': 'invalid_grant', 'description': 'Wrong phone number or verification code.', 'timestamp': '2024-07-10T10:56:59Z'}

and:

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421
First occurred: 1:56:52 PM (5 occurrences)
Last logged: 2:22:50 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 573, in _async_handle_step
    result = await self.async_finish_flow(flow, result.copy())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1403, in async_finish_flow
    title=result["title"],
          ~~~~~~^^^^^^^^^
KeyError: 'title'

Additional information

Note that Tami4EdgeAPI==3.0 library works as expected:

>>> from Tami4EdgeAPI import Tami4EdgeAPI
>>> phone_number = "+972542222222"
>>> Tami4EdgeAPI.request_otp(phone_number)
>>> otp_code = input("Enter OTP: ")
Enter OTP: 981031
>>> refresh_token = Tami4EdgeAPI.submit_otp(phone_number, otp_code)
>>> refresh_token
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>>> edge = Tami4EdgeAPI(refresh_token)
>>> print(f"Bar Name: {edge.device_metadata.name}, Firmware Version: {edge.device_metadata.device_firmware}")
Bar Name: None, Firmware Version: 0.02.018
>>> device = edge.get_device()
>>> for drink in device.drinks:
...   print(drink.name)
... 
Cold Cup
...
>>> water_quality = device.water_quality
>>> water_quality.uv.last_replacement
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'UV' object has no attribute 'last_replacement'
>>> water_quality.uv.upcoming_replacement
datetime.date(2025, 6, 26)
>>> water_quality.uv.installed
True
>>> water_quality.filter.milli_litters_passed
138599
home-assistant[bot] commented 1 month ago

Hey there @guy293, mind taking a look at this issue as it has been labeled with an integration (tami4) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tami4` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tami4` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tami4 documentation tami4 source (message by IssueLinks)

Guy293 commented 1 month ago

Hey @tomers, I've sent you an email.

Guy293 commented 1 month ago

In: https://github.com/Guy293/Tami4EdgeAPI/issues/10 they reported that changing the app's language fixed it, It still works for me in both English and Hebrew.

orenc75 commented 1 month ago

Maybe the problem is related to the number of open profiles in Tami4? I have 4 profiles with 4 phones registered. Just a thought...

Guy293 commented 1 month ago

Maybe the problem is related to the number of open profiles in Tami4? I have 4 profiles with 4 phones registered. Just a thought...

I have a few profiles registered as well, I don't think that's it.

Yehazkel commented 1 month ago

I think it's something related to the previous integration. I can't configure the integration also. Let me know if I can help in any way

Yehazkel commented 1 month ago

Finally got it. It happens when the water bar has no name. Just enter the app, settings, and change the water bar name. @Guy293 added PR https://github.com/home-assistant/core/pull/123156 cc @orenc75

Guy293 commented 1 month ago

Finally got it. It happens when the water bar has no name. Just enter the app, settings, and change the water bar name. @Guy293 added PR #123156 cc @orenc75

Thanks, I will take a look at it.

orenc75 commented 1 month ago

I can confirm that @Yehazkel 's soultion is working for me. Thanks!

Yehazkel commented 1 month ago

@Guy293 No ability to prepare drinks? I know you implemented it in Tami4EdgeAPI but not in the ha integration?

Guy293 commented 1 month ago

@Guy293 No ability to prepare drinks? I know you implemented it in Tami4EdgeAPI but not in the ha integration?

I haven't implement it in the the intergration yet, shouldn't be too hard I just don't have the time.