Skip to content

code_login_v4 TypeError: Invalid variable type: value should be str, int or float, got None of type <class 'NoneType'> #536

@tomtomtomtom1994

Description

@tomtomtomtom1994

Hi,

I'm trying to add the roborock integration in home assistant (2025.10.2) but when I enter the login code it says there is an unexpected error.

The logs appear to be complaining about a null parameter. I can see code login uses /api/v1/getUrlByEmail to get the country and country code which are then passed as params to /api/v4/auth/email/login/code.

when I hit getUrlByEmail with my email address I get the following response:

{
	"code": 200,
	"msg": "success",
	"data": {
		"url": "https://euiot.roborock.com",
		"country": null,
		"countrycode": "44"
	}
}

So I suspect the issue is the null value for the country param is causing an exception when building the query string for api/v4/auth/email/login/code

Here are the logs:

2025-10-15 13:01:23.359 ERROR (MainThread) [homeassistant.components.roborock.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/roborock/config_flow.py", line 114, in async_step_code
    user_data = await self._client.code_login_v4(code)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/roborock/web_api.py", line 312, in code_login_v4
    login_response = await login_request.request(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<12 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/roborock/web_api.py", line 652, in request
    async with session.request(method, _url, params=params, data=data, headers=_headers, json=json) as resp:
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 1488, in __aenter__
    self._resp: _RetType = await self._coro
                           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 693, in _request
    req = self._request_class(
        method,
    ...<21 lines>...
        trust_env=self.trust_env,
    )
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_reqrep.py", line 866, in __init__
    url = url.extend_query(params)
  File "/usr/local/lib/python3.13/site-packages/yarl/_url.py", line 1206, in extend_query
    if not (new_query := get_str_query(*args, **kwargs)):
                         ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/yarl/_query.py", line 97, in get_str_query
    return get_str_query_from_sequence_iterable(query.items())
  File "/usr/local/lib/python3.13/site-packages/yarl/_query.py", line 51, in get_str_query_from_sequence_iterable
    f"{quoter(k)}={quoter(v if type(v) is str else query_var(v))}"
                                                   ~~~~~~~~~^^^
  File "/usr/local/lib/python3.13/site-packages/yarl/_query.py", line 33, in query_var
    raise TypeError(
    ...<3 lines>...
    )
TypeError: Invalid variable type: value should be str, int or float, got None of type <class 'NoneType'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions