Skip to content

"offset must be a timedelta" error when provisioning HS103 #1767

Description

@jasondunsmore

I'm trying to provision a new HS103 according to the instructions. I've connected to the open wifi network from my computer. If I run the discover command, 0 devices are found.

> uv run kasa discover
Discovering devices on 255.255.255.255 for 10 seconds
Found 0 devices

However, if I run kasa --host 192.168.0.1 wifi scan or kasa --host 192.168.0.1 state, I see the following error:

> uv run kasa --host 192.168.0.1 state --debug
Discovering device 192.168.0.1 for 10 seconds
Raised error: offset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24), not
datetime.timedelta(days=-9760, seconds=9900).
Traceback (most recent call last):
  File "/tmp/python-kasa/python-kasa/.venv/bin/kasa", line 10, in <module>
    sys.exit(cli())
             ~~~^^
  File "/tmp/python-kasa/python-kasa/kasa/cli/common.py", line 282, in __call__
    asyncio.run(self.main(*args, **kwargs))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/tmp/python-kasa/python-kasa/.venv/lib/python3.13/site-packages/asyncclick/core.py", line 1549, in main
    rv = await self.invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/python-kasa/python-kasa/kasa/cli/common.py", line 270, in invoke
    _handle_exception(self._debug, exc)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/tmp/python-kasa/python-kasa/kasa/cli/common.py", line 268, in invoke
    return await super().invoke(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/python-kasa/python-kasa/.venv/lib/python3.13/site-packages/asyncclick/core.py", line 2072, in invoke
    await super().invoke(ctx)
  File "/tmp/python-kasa/python-kasa/.venv/lib/python3.13/site-packages/asyncclick/core.py", line 1412, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/python-kasa/python-kasa/.venv/lib/python3.13/site-packages/asyncclick/core.py", line 965, in invoke
    rv = await rv
         ^^^^^^^^
  File "/tmp/python-kasa/python-kasa/kasa/cli/main.py", line 369, in cli
    await dev.update()
  File "/tmp/python-kasa/python-kasa/kasa/iot/iotdevice.py", line 326, in update
    await module._post_update_hook()
  File "/tmp/python-kasa/python-kasa/kasa/iot/modules/time.py", line 68, in _post_update_hook
    self._timezone = await _guess_timezone_by_offset(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        rounded, when_utc=now_utc, dst_expected=dst_expected
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/tmp/python-kasa/python-kasa/kasa/iot/iottimezone.py", line 161, in _guess_timezone_by_offset
    return timezone(offset)
ValueError: offset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24), not datetime.timedelta(days=-9760, seconds=9900).

I've tried factory resetting the device, to no avail. Is this a bug in python-kasa or the device? Is there a workaround? Thanks in advance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions