Fixes issue with unpaired devices reporting light effect as `softAP`
reported in https://github.com/python-kasa/python-kasa/pull/972. I don't
think we need to handle that effect properly so just reports as off.
Adds an implementation of `_check_supported` to the light transition module so it is
not added to a parent device that reports it but doesn't support it, i.e. ks240.
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.
Picked this up while updating the [Fan platform
PR](https://github.com/home-assistant/core/pull/116605) for HA. The
smart fan module was not correctly deriving from the common interface
and the speed_level is reported as >0 when off.
For power strips, the autooff data needs to be requested from the
children.
Until we do that, we should not create these features to avoid crashing
during switch platform initialization.
This also ports the module to use `_initialize_features` and add tests.
PR contains a number of fixes from testing with HA devices:
- Fixes a bug with turning the light on and off via `set_state`
- Aligns `set_brightness` behaviour across `smart` and `iot` devices
such that a value of 0 is off.
- Aligns `set_brightness` behaviour for `IotDimmer` such that setting
the brightness turns on the device with a transition of 1ms. ([HA
comment](https://github.com/home-assistant/core/pull/117839#discussion_r1608720006))
- Fixes a typing issue in `LightState`.
- Adds `ColorTempRange` and `HSV` to `__init__.py`
- Adds a `state` property to the interface returning `LightState` for
validating `set_state` changes.
- Adds tests for `set_state`
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.
Deprecates the attributes at device level for light, light effects, and led. i.e. device.led, device.is_color. Will continue to support consumers using these attributes and emit a warning.
Implements the `light_strip_lighting_effect` components for
`smart` devices. Uses a new list of effects captured from a L900 which
are similar to the `iot` effects but include some additional properties
and a few extra effects.
Assumes that a device only implements `light_strip_lighting_effect` or
`light_effect` but not both.
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.
* Expose current and latest firmware as features
* Provide API to get information about available firmware updates (e.g., changelog, release date etc.)
* Implement updating the firmware
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.
This adds a test to check that all feature.set_value() calls will cause
a query, i.e., that there are no self.call()s that are not awaited, and
fixes existing code in this context.
This also fixes an issue where it was not possible to print out the
feature if the value threw an exception.
This improves the temperature control features to allow implementing
climate platform support for homeassistant.
Also adds frostprotection module, which is also used to turn
the thermostat on and off.
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).
Enables the Fan interface for devices supporting that component.
Currently the only device with a fan is the ks240 which implements it as
a child device. This PR adds a method `get_module` to search the child
device for modules if it is a WallSwitch device type.
This can be used to hint how the sensor value should be rounded when
displaying it to users.
The values are adapted from the values used by homeassistant.
In order to support the ks240 which has children for the fan and light
components, this PR adds those modules at the parent level and hides the
children so it looks like a single device to consumers. It also decides
which modules not to take from the child because the child does not
support them even though it say it does. It does this for now via a
fixed list, e.g. `Time`, `Firmware` etc.
Also adds fixtures from two versions and corresponding tests.
Moves `FeatureType` into `Feature` to make it easier to use the API.
This also enforces that no invalid types are accepted (i.e.,
`Category.Config` cannot be a `Sensor`)
If `--verbose` is used with the cli tool, some extra information is
displayed for features when in the state command.
Adds `FeatureType.Action` making it possible to expose features like
"reboot", "test alarm", "pair" etc.
The `attribute_getter` is no longer mandatory, but it will raise an
exception if not defined for other types than actions.
Trying to read returns a static string `<Action>`.
This overloads the `set_value` to call the given callable on any value.
This also fixes the `play` and `stop` coroutines of the alarm module to
await the call.
Initial implementation for feature categories to help downstreams and
our cli tool to categorize the data for more user-friendly manner. As
more and more information is being exposed through the generic features
interface, it is necessary to give some hints to downstreams about how
might want to present the information to users.
This is not a 1:1 mapping to the homeassistant's mental model, and it
will be necessary to fine-tune homeassistant-specific parameters by
other means to polish the presentation.
Devices not connected to the internet will either error when querying
firmware queries (e.g. P300) or return misleading information (e.g.
P100). This PR adds the cloud connect query to the initial queries and
bypasses the firmware module if not connected.
Add SMART.KASAHUB to the map of supported devices.
This also adds fixture files for KH100, KE100, and T310, and adapts affected modules and their tests accordingly.
---------
Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>