FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

HS300 Child State - Time Module Error · Issue #1445 · python-kasa/python-kasa · GitHub

Repository navigation

HS300 Child State - Time Module Error #1445

Closed

Description

I noticed while checking some things, I get a Time Module Error when using the following command, does the same with the --child flag, but not when getting the device state
kasa --debug --host 192.168.1.30 device --child-index 0 state

Raised error: 'Time'
Traceback (most recent call last):
File "/var/lib/homebridge/kasa-python/.venv/bin/kasa", line 8, in
sys.exit(cli())
^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/kasa/cli/common.py", line 253, in call
asyncio.run(self.main(*args, **kwargs))
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/asyncclick/core.py", line 1126, in main
rv = await self.invoke(ctx)
^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/kasa/cli/common.py", line 241, in invoke
_handle_exception(self._debug, exc)
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/kasa/cli/common.py", line 239, in invoke
return await super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/asyncclick/core.py", line 1750, in invoke
return await _process_result(await sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/asyncclick/core.py", line 1750, in invoke
return await _process_result(await sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/asyncclick/core.py", line 1496, in invoke
return await ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/asyncclick/core.py", line 829, in invoke
rv = await rv
^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/kasa/cli/common.py", line 132, in wrapper
return await ctx.invoke(wrapped_function, dev, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/asyncclick/core.py", line 829, in invoke
rv = await rv
^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/kasa/cli/device.py", line 43, in state
echo(f"Time: {dev.time} (tz: {dev.timezone})")
^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/kasa/iot/iotdevice.py", line 61, in wrapped
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/var/lib/homebridge/kasa-python/.venv/lib/python3.11/site-packages/kasa/iot/iotdevice.py", line 498, in time
return self.modules[Module.Time].time
~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'Time'

Activity

  1. rytilahti commented on Jan 23, 2025

    Member

    The cause is that the IotStripPlug is not registering the time module (and its properties, like on_since, simply use the parent's time).

  2. ZeliardM commented on Jan 24, 2025

    CollaboratorAuthor

    I gotcha. I use the parent properties for the most part, but just wanted to pass this along. Thanks!

  3. rytilahti commented on Jan 24, 2025

    Member

    Sure thing, thanks for reporting, it's still worth fixing at some point so let's keep this open!

  4. ZeliardM commented on Oct 2, 2025

    CollaboratorAuthor

    @rytilahti While I'm working on the other timezone issues, I'm going to look at this as well for the child devices on older IOT devices to make sure that they are using the parent time module correctly.

  5. Allowencer commented on Oct 6, 2025

    I'm actively using a HS300 in a use-case; I can quickly test a PR / beta / test release at any point if you'd like.

  6. ZeliardM commented on Oct 6, 2025

    CollaboratorAuthor

    @Allowencer Great, once I have something to test, I'll let you know.

  7. Allowencer commented on Oct 7, 2025

    Do you need any stack traces or do you have everything you need currently?

  8. ZeliardM commented on Oct 7, 2025

    CollaboratorAuthor

    I think I have everything I need, working on several different PR's at the moment, so trying to work through them one at a time right now.

  9. Allowencer commented on Oct 7, 2025

    Cool. Happy and willing to help as needed!

  10. ZeliardM commented on Oct 7, 2025

    CollaboratorAuthor

    Once I have a PR ready, I'll let you know so you can pull it and test on your end.

  11. ZeliardM commented on Oct 8, 2025

    CollaboratorAuthor

    @Allowencer I have PR[#1584] ready. Do you know how to pull it down and checkout the PR use uv to run the PR code to test on your local environment?

    @rytilahti I've tested this on my end and things look good. I'll fix the couple of Copilot comments and then it should be good to go.

  12. Allowencer commented on Oct 9, 2025

    Looking good!

    uv run pytest -q tests/iot/test_iotstrip.py

    warning: The `tool.uv.dev-dependencies` field (used in `pyproject.toml`) is deprecated and will be removed in a future release; use `dependency-groups.dev` instead
    warning: `VIRTUAL_ENV=.venv-pr` does not match the project environment path `.venv` and will be ignored; use `--active` to target the active environment instead
    Test session starts (platform: linux, Python 3.12.3, pytest 8.3.4, pytest-sugar 1.0.0)
    rootdir: /tmp/python-kasa
    configfile: pyproject.toml
    plugins: asyncio-0.25.3, anyio-4.8.0, socket-0.7.0, xdist-3.6.1, xdoctest-1.2.0, pytest_freezer-0.4.9, timeout-2.3.1, sugar-1.0.0, cov-6.0.0, mock-3.14.0
    asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=function
    Testing against fixtures.
    
     tests/iot/test_iotstrip.py s✓ssssssssss✓ssssssssssss✓✓✓✓sssssssssssssssssssssssssssss✓✓✓✓✓✓✓✓sssssssssssssss✓ssssssssss✓ssssssssssss✓✓✓✓sssssssssssssssssssssssssssss✓✓✓✓✓✓✓✓sssssssssssssssss 68% ██████▊   
                                ssssssssssssssssssssss✓✓✓✓sssssssssssssssssssssssssssssssssssssssssssssssssss                                                                                      100% ██████████
    Results (0.54s):
          32 passed
         208 skipped
    

    (.venv-pr) :/tmp/python-kasa$ uv run kasa --host 192.168.xxx.xx state --child-index 0

    warning: The `tool.uv.dev-dependencies` field (used in `pyproject.toml`) is deprecated and will be removed in a future release; use `dependency-groups.dev` instead
    warning: `VIRTUAL_ENV=.venv-pr` does not match the project environment path `.venv` and will be ignored; use `--active` to target the active environment instead
    Discovering device 192.168.xxx.xxx for 10 seconds
    Targeting child device Plug 1
    == Plug 1 - Socket for HS300(US) ==
    Host: 192.168.xxx.xxx
    Port: 9999
    Device state: True
    Time:         2025-10-08 21:39:00-05:00 (tz: EST)
    Hardware:     2.0 (US)
    Firmware:     1.0.12 Build 220121 Rel.175814
    MAC (rssi):   DC:62:79:9D:CE:60 (-36)
    
    == Primary features ==
    State (state): True
    Current consumption (current_consumption): 7.2 W
    Voltage (voltage): 120.3 V
    Current (current): 0.15 A
    
    == Information ==
    On since (on_since): 2025-10-01 17:22:51-05:00
    Today's consumption (consumption_today): 0.163 kWh
    This month's consumption (consumption_this_month): 1.716 kWh
    Total consumption since reboot (consumption_total): 5.051 kWh
    
    == Configuration ==
    
    == Debug ==
    

    (.venv-pr) :/tmp/python-kasa$ uv run kasa --host 192.168.xxx.xxx state --child-index 1

    warning: The `tool.uv.dev-dependencies` field (used in `pyproject.toml`) is deprecated and will be removed in a future release; use `dependency-groups.dev` instead
    warning: `VIRTUAL_ENV=.venv-pr` does not match the project environment path `.venv` and will be ignored; use `--active` to target the active environment instead
    Discovering device 192.168.xxx.xxx for 10 seconds
    Targeting child device Plug 2
    == Plug 2 - Socket for HS300(US) ==
    Host: 192.168.xxx.xxx
    Port: 9999
    Device state: False
    Time:         2025-10-08 21:39:03-05:00 (tz: EST)
    Hardware:     2.0 (US)
    Firmware:     1.0.12 Build 220121 Rel.175814
    MAC (rssi):   DC:62:79:9D:CE:60 (-36)
    
    == Primary features ==
    State (state): False
    Current consumption (current_consumption): 0.0 W
    Voltage (voltage): 121.3 V
    Current (current): 0.0 A
    
    == Information ==
    On since (on_since): None
    Today's consumption (consumption_today): 0.0 kWh
    This month's consumption (consumption_this_month): 0.0 kWh
    Total consumption since reboot (consumption_total): 0.0 kWh
    
    == Configuration ==
    
    == Debug ==
    

    (.venv-pr) :/tmp/python-kasa$ uv run kasa --host 192.168.xxx.xxx state

    warning: The `tool.uv.dev-dependencies` field (used in `pyproject.toml`) is deprecated and will be removed in a future release; use `dependency-groups.dev` instead
    warning: `VIRTUAL_ENV=.venv-pr` does not match the project environment path `.venv` and will be ignored; use `--active` to target the active environment instead
    Discovering device 192.168.xxx.xxx for 10 seconds
    == TP-LINK_Power Strip_CE60 - HS300 ==
    Host: 192.168.xxx.xxx
    Port: 9999
    Device state: True
    Time:         2025-10-08 21:39:08-05:00 (tz: EST)
    Hardware:     2.0 (US)
    Firmware:     1.0.12 Build 220121 Rel.175814
    MAC (rssi):   DC:62:79:9D:CE:60 (-36)
    
    == Primary features ==
    State (state): True
    Current consumption (current_consumption): 15.8 W
    Voltage (voltage): 121.2 V
    Current (current): 0.3 A
    
    == Information ==
    On since (on_since): 2025-10-01 17:22:51-05:00
    Cloud connection (cloud_connection): True
    Today's consumption (consumption_today): 0.379 kWh
    This month's consumption (consumption_this_month): 2.8 kWh
    Total consumption since reboot (consumption_total): 6.41 kWh
    
    == Configuration ==
    LED (led): True
    
    == Debug ==
    RSSI (rssi): -36 dBm
    Reboot (reboot): <Action>
    
    == Children ==
    
            == Plug 1 (Socket for HS300(US)) ==
    
            == Primary features ==
            State (state): True
            Current consumption (current_consumption): 6.0 W
            Voltage (voltage): 120.6 V
            Current (current): 0.14 A
    
            == Information ==
            On since (on_since): 2025-10-01 17:22:51-05:00
            Today's consumption (consumption_today): 0.163 kWh
            This month's consumption (consumption_this_month): 1.716 kWh
            Total consumption since reboot (consumption_total): 5.051 kWh
    
            == Configuration ==
    
            == Debug ==
    
            == Plug 2 (Socket for HS300(US)) ==
    
            == Primary features ==
            State (state): False
            Current consumption (current_consumption): 0.0 W
            Voltage (voltage): 121.4 V
            Current (current): 0.0 A
    
            == Information ==
            On since (on_since): None
            Today's consumption (consumption_today): 0.0 kWh
            This month's consumption (consumption_this_month): 0.0 kWh
            Total consumption since reboot (consumption_total): 0.0 kWh
    
            == Configuration ==
    
            == Debug ==
    
            == Plug 3 (Socket for HS300(US)) ==
    
            == Primary features ==
            State (state): False
            Current consumption (current_consumption): 0.0 W
            Voltage (voltage): 121.6 V
            Current (current): 0.0 A
    
            == Information ==
            On since (on_since): None
            Today's consumption (consumption_today): 0.0 kWh
            This month's consumption (consumption_this_month): 0.0 kWh
            Total consumption since reboot (consumption_total): 0.0 kWh
    
            == Configuration ==
    
            == Debug ==
    
            == Plug 4 (Socket for HS300(US)) ==
    
            == Primary features ==
            State (state): False
            Current consumption (current_consumption): 0.0 W
            Voltage (voltage): 120.6 V
            Current (current): 0.0 A
    
            == Information ==
            On since (on_since): None
            Today's consumption (consumption_today): 0.0 kWh
            This month's consumption (consumption_this_month): 0.0 kWh
            Total consumption since reboot (consumption_total): 0.0 kWh
    
            == Configuration ==
    
            == Debug ==
    
            == Plug 5 (Socket for HS300(US)) ==
    
            == Primary features ==
            State (state): False
            Current consumption (current_consumption): 0.0 W
            Voltage (voltage): 121.6 V
            Current (current): 0.0 A
    
            == Information ==
            On since (on_since): None
            Today's consumption (consumption_today): 0.0 kWh
            This month's consumption (consumption_this_month): 0.0 kWh
            Total consumption since reboot (consumption_total): 0.0 kWh
    
            == Configuration ==
    
            == Debug ==
    
            == Plug 6 (Socket for HS300(US)) ==
    
            == Primary features ==
            State (state): True
            Current consumption (current_consumption): 9.8 W
            Voltage (voltage): 121.5 V
            Current (current): 0.16 A
    
            == Information ==
            On since (on_since): 2025-10-06 08:52:01-05:00
            Today's consumption (consumption_today): 0.216 kWh
            This month's consumption (consumption_this_month): 1.084 kWh
            Total consumption since reboot (consumption_total): 1.359 kWh
    
            == Configuration ==
    
            == Debug ==
    
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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL