- Make model exclude region for `iot` devices. This is consistent with `smart` and `smartcam` devices.
- Make region it's own attribute on `Device`.
- Ensure that devices consistently use `_get_device_info` static methods for all information relating to device models.
- Fix issue with firmware and hardware being the wrong way round for `smartcam` devices.
Clean up and consolidate the processing of raw component query responses and simplify the code paths for creating smartcam child devices when supported.
Different devices and different firmwares report overheated status in
different ways.
Some devices indicate support for `overheat_protect` component, but
there are devices that report `overheat_status` even when it is not
listed.
Some other devices use `overheated` boolean that was already previously
supported, but this PR adds support for much more devices that use
`overheat_status` for reporting.
The "overheated" feature is moved into its own module, and uses either
of the ways to report this information.
This will also rename `REQUIRED_KEY_ON_PARENT` to `SYSINFO_LOOKUP_KEYS`
and change its logic to check if any of the keys in the list are found
in the sysinfo.
```
tpr@lumipyry ~/c/p/tests (fix/overheated)> ag 'overheat_protect' -c|wc -l
15
tpr@lumipyry ~/c/p/tests (fix/overheated)> ag 'overheated' -c|wc -l
38
tpr@lumipyry ~/c/p/tests (fix/overheated)> ag 'overheat_status' -c|wc -l
20
```
---------
Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
This PR implements a clear-text, token-based transport protocol seen on
RV30 Plus (#937).
- Client sends `{"username": "email@example.com", "password":
md5(password)}` and gets back a token in the response
- Rest of the communications are done with POST at `/app?token=<token>`
---------
Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
Python 3.11 ships with latest Debian Bookworm.
pypy is not that widely used with this library based on statistics. It could be added back when pypy supports python 3.11.
This PR will make `__repr__` also work on smartdevices where only
discovery data is available by modifying the `model` property to
fallback to the data found in the discovery payloads.
No devices in `fixtures/smart/child` support the `get_device_time` or
`get_device_usage` methods so this PR tests for whether the device is a
hub child and marks those modules/methods as not supported. This
prevents features being erroneously created on child devices.
It also moves the logic for getting the time from the parent module
behind getting it from the child module which was masking the creation
of these unsupported modules.
Re-query failed modules after some delay instead of immediately disabling them.
Changes to features so they can still be created when modules are erroring.
Expose reboot through the feature interface.
This can be useful in situations where one wants to reboot the device,
e.g., in recent cases where frequent update calls will render the device
unresponsive after a specific amount of time.
Addresses stability issues on older hw device versions
- Handles module timeout errors better by querying modules individually on errors and disabling problematic modules like Firmware that go out to the internet to get updates.
- Addresses an issue with the Led module on P100 hardware version 1.0 which appears to have a memory leak and will cause the device to crash after approximately 500 calls.
- Delays updates of modules that do not have regular changes like LightPreset and LightEffect and enables them to be updated on the next update cycle only if required values have changed.
Ensures that all modules try to access their data in `_post_update_hook` in a safe manner and disable themselves if there's an error.
Also adds parameters to get_preset_rules and get_on_off_gradually_info to fix issues with recent firmware updates.
[#1033](https://github.com/python-kasa/python-kasa/issues/1033)
Adds a new decorator that adds child options to a command and gets the
child device if the options are set.
- Single definition of options and error handling
- Adds options automatically to command
- Backwards compatible with `--index` and `--name`
- `--child` allows for id and alias for ease of use
- Omitting a value for `--child` gives an interactive prompt
Implements private `_update` to allow the CLI to patch a child `update`
method to call the parent device `update`.
Example help output:
```
$ kasa brightness --help
Usage: kasa brightness [OPTIONS] [BRIGHTNESS]
Get or set brightness.
Options:
--transition INTEGER
--child, --name TEXT Child ID or alias for controlling sub-
devices. If no value provided will show an
interactive prompt allowing you to select a
child.
--child-index, --index INTEGER Child index controlling sub-devices
--help Show this message and exit.
```
Fixes#769
Required for the P300 firmware update with `auto_off` module on child
devices. Will query child modules for parent devices that are not hubs.
Coverage will be fixed when the P300 fixture is added
https://github.com/python-kasa/python-kasa/pull/915
Replaces the logic to skip adding child modules to parent devices based
on whether a device is a wall switch and instead relies on the
`_check_supported` method. Is more future proof and will fix issue with
the P300 with child `auto_off` modules
https://github.com/python-kasa/python-kasa/pull/915 not supported on the
parent.
Adds light preset common module for switching to presets and saving presets.
Deprecates the `presets` attribute and `save_preset` method from the `bulb`
interface in favour of the modular approach. Allows setting preset for `iot`
which was not previously supported.
Address the inconsistent naming of smart modules by removing all "Module" suffixes and aligning filenames with class names. Removes the casting of modules to the correct module type now that is is redundant. Update the adding of iot modules to use the ModuleName class rather than a free string.
Passing in a string still works and returns either `IotModule` or
`SmartModule` type when called on `IotDevice` or `SmartDevice`
respectively. When calling on `Device` will return `Module` type.
Passing in a module type is then typed to that module, i.e.:
```py
smartdev.get_module(FanModule) # type is FanModule
smartdev.get_module("FanModule") # type is SmartModule
```
Only thing this doesn't do is check that you can't pass an `IotModule`
to a `SmartDevice.get_module()`. However there is a runtime check which
will return null if the passed `ModuleType` is not a subclass of
`SmartModule`.
Many thanks to @cdce8p for helping with this.
Support the `light_effect` module which allows setting the effect to Off
or Party or Relax. Uses the new `Feature.Type.Choice`. Does not
currently allow editing of effects.
Brings consistency to the api across Smart and Iot so the interfaces can be used for their specialist methods as well as the device methods (e.g. turn_on/off).