Commit Graph

669 Commits

Author SHA1 Message Date
Teemu Rytilahti
64eed4fbdd Fix update for smart devices 2024-08-31 15:31:25 +02:00
sdb9696
06c5e55ac6 Merge remote-tracking branch 'upstream/master' into feat/device_update 2024-05-14 18:35:23 +01:00
Steven B
67b5d7de83
Update cli to use common modules and remove iot specific cli testing (#913) 2024-05-14 08:38:21 +01:00
Steven B
ef49f44eac
Deprecate is_something attributes (#912)
Deprecates the is_something attributes like is_bulb and is_dimmable in favour of the modular approach.
2024-05-13 18:52:08 +01:00
Steven B
33d839866e
Make Light and Fan a common module interface (#911) 2024-05-13 17:34:44 +01:00
Steven B
d7b00336f4
Rename bulb interface to light and move fan and light interface to interfaces (#910)
Also rename BulbPreset to LightPreset.
2024-05-11 19:40:08 +01:00
Steven B
f259a8f162
Make module names consistent and remove redundant module casting (#909)
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.
2024-05-11 19:28:18 +01:00
Steven B
9473d97ad2
Create common interfaces for remaining device types (#895)
Introduce common module interfaces across smart and iot devices and provide better typing implementation for getting modules to support this.
2024-05-10 19:29:28 +01:00
Teemu R
7d4dc4c710
Improve smartdevice update module (#791)
* 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
2024-05-09 01:43:07 +02:00
Teemu R
1e8e289ac7
Move contribution instructions into docs (#901)
Moves the instructions away from README.md to keep it simpler, and
extend the documentation to be up-to-date and easier to approach.

---------

Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
2024-05-08 15:25:22 +02:00
Teemu R
353e84438c
Add support for contact sensor (T110) (#877)
Initial support for T110 contact sensor & T110 fixture by courtesy of @ngaertner.
2024-05-07 20:58:18 +02:00
Teemu R
7f98acd477
Add 'battery_percentage' only when it's available (#906)
At least some firmware versions of T110 are known not to report this.
2024-05-07 20:56:24 +02:00
Teemu R
b66a337f40
Add H100 1.5.10 and KE100 2.4.0 fixtures (#905) 2024-05-07 20:56:03 +02:00
Teemu Rytilahti
fc122eac6b Fix issues after rebasing 2024-05-07 17:55:14 +02:00
Teemu Rytilahti
6dcc2758d7 Add update interface for iot and expose it through cli 2024-05-07 17:46:59 +02:00
Teemu Rytilahti
3429821b25 Fix linting 2024-05-07 17:46:17 +02:00
Teemu Rytilahti
06fe4e71cf Improve smartdevice update module
* Expose current and latest firmware as features
* Implement update loop that blocks until the update is complete
2024-05-07 17:45:52 +02:00
Teemu Rytilahti
39e6aac63b Fix after rebasing 2024-05-07 17:41:38 +02:00
Teemu Rytilahti
fd8689123f Fix linting 2024-05-07 17:37:21 +02:00
Teemu Rytilahti
e9dfdf6cf7 Improve smartdevice update module
* Expose current and latest firmware as features
* Implement update loop that blocks until the update is complete
2024-05-07 17:36:07 +02:00
Teemu R
253287c7b7
Add warning about tapo watchdog (#902) 2024-05-07 14:46:59 +02:00
Teemu R
55653d0346
Improve categorization of features (#904)
This updates the categorization of features and makes the id mandatory for features
2024-05-07 10:13:35 +01:00
Teemu R
50b5107f75
Add missing alarm volume 'normal' (#899)
Also logs a warning in feature repr if value not in choices and fixes the returned string to be consistent with valid values.
2024-05-07 09:38:09 +01:00
Steven B
f063c83378
Add child devices from hubs to generated list of supported devices (#898)
Updates generate_supported hook to include child devices of hubs in the list of supported devices.
2024-05-07 07:48:47 +01:00
Steven B
c5d65b624b
Make get_module return typed module (#892)
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.
2024-05-03 17:01:21 +02:00
Teemu R
530fb841b0
Add fixture for waterleak sensor T300 (#897)
Fixture by courtesy of @ngaertner
(https://github.com/python-kasa/python-kasa/issues/875#issuecomment-2091484438)
2024-05-03 15:24:34 +02:00
Teemu R
88381f270f
Use Path.save for saving the fixtures (#894)
This might fix saving of fixture files on Windows, but it's a good
practice to use pathlib where possible.
2024-05-03 13:57:43 +02:00
Steven B
5b486074e2
Add LightEffectModule for dynamic light effects on SMART bulbs (#887)
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.
2024-05-02 16:31:12 +02:00
Teemu R
5ef81f4669
Improve feature setter robustness (#870)
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.
2024-05-02 15:32:06 +02:00
Teemu R
9dcd8ec91b
Improve temperature controls (#872)
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.
2024-05-02 13:05:26 +00:00
Steven B
28d41092e5
Update interfaces so they all inherit from Device (#893)
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).
2024-05-02 13:55:08 +01:00
Steven B
b2194a1c62
Update ks240 fixture with child device query info (#890)
The fixture now includes the queries returned directly from the child devices which is stored under child_devices along with valid device ids.

Also fixes a bug in the test_cli.py::test_wifi_scan which fails with more than 9 networks.
2024-05-01 16:05:37 +01:00
Steven B
3fc131dfd2
Fix wifi scan re-querying error (#891) 2024-05-01 15:56:43 +01:00
Teemu R
46338ee21d
Use pydantic.v1 namespace on all pydantic versions (#883)
With https://github.com/pydantic/pydantic/pull/9042 being shipped with
[1.10.15](https://docs.pydantic.dev/latest/changelog/#v11015-2024-04-03),
we can clean up the imports a bit until we make decisions how to move
onward with or without pydantic.

---------

Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
2024-05-01 15:59:35 +02:00
Steven B
16f17a7729
Add Fan interface for SMART devices (#873)
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.
2024-04-30 17:42:53 +01:00
Teemu R
7db989e2ec
Fix --help on subcommands (#886)
Pass a dummy object as context object as it will not be used by --help
anyway.

Also, allow defining --help anywhere in the argv, not just in the last
place.
2024-04-30 18:30:03 +02:00
Teemu R
5599756d28
Add support for waterleak sensor (T300) (#876) 2024-04-30 17:31:47 +02:00
Teemu R
300d823895
Implement choice feature type (#880)
Implement the choice feature type allowing to provide a list of choices that can be set.

Co-authored-by: sdb9696
2024-04-30 07:56:09 +01:00
Steven B
d3544b4989
Move SmartBulb into SmartDevice (#874) 2024-04-29 18:19:44 +01:00
Steven B
cb11b36511
Put modules back on children for wall switches (#881)
Puts modules back on the children for `WallSwitches` (i.e. ks240) and
makes them accessible from the `modules` property on the parent.
2024-04-29 18:34:20 +02:00
Steven B
6724506fab
Update dump_devinfo to print original exception stack on errors. (#882) 2024-04-29 14:33:46 +01:00
Steven B
e7553a7af4
Fix smartprotocol response list handler to handle null reponses (#884) 2024-04-29 14:24:30 +01:00
Teemu R
d7a36fe071
Add precision_hint to feature (#871)
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.
2024-04-29 13:31:42 +02:00
Steven B
fe6b1892cc
Fix pypy39 CI cache on macos (#868) 2024-04-25 15:57:08 +01:00
Teemu R
1ff3162112
Expose IOT emeter info as features (#844)
Exposes IOT emeter information using features, bases on #843 to allow
defining the units.


---------

Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
2024-04-25 14:59:17 +02:00
Steven B
724dad02f7
Do not try coverage upload for pypy (#867)
Do not try to upload coverage for pypy which is run without coverage.
2024-04-25 14:02:17 +02:00
Steven B
6e55c8d989
Add runner.arch to cache-key in CI (#866) 2024-04-25 13:02:00 +01:00
Steven B
9efcc0d19f
Fix broken CI due to missing python version on macos-latest (#864) 2024-04-25 08:05:51 +01:00
Teemu R
10629f2db9
Be more lax on unknown SMART devices (#863) 2024-04-25 07:36:30 +01:00
Steven B
53b84b7683
Handle paging of partial responses of lists like child_device_info (#862)
When devices have lists greater than 10 for child devices only the first
10 are returned. This retrieves the rest of the items (currently with
single requests rather than multiple requests)
2024-04-24 20:32:30 +02:00