python-kasa / python-kasa

🏠🤖 Python API for TP-Link smarthome products
https://python-kasa.readthedocs.io/en/stable/
Other
1.2k stars 194 forks source link

Implement smart actions (smartlife.iot.sensor_trigger) #456

Open rytilahti opened 1 year ago

rytilahti commented 1 year ago

Some devices support device-based triggers which are not currently implemented by this library.

For example:

It might be worth mentioning that the offending default rule is one of what TP-Link calls "Smart Control" rules, which are managed by the smartlife.iot.sensor_trigger module. The following command will probably delete the offending rule:

{"smartlife.iot.sensor_trigger": {"delete_weekday_routine": {"id": "0"}}}

Note, to really do it properly, you shouldn't assume that the id of the rule will be "0". Instead, you should call get_weekday_routine and iterate over the returned array to find the id of each existing rule, which you can then pass in turn to delete_weekday_routine. On my KS200M, the one allowed Smart Control rule is always given "id": "0", but that seems to be an anomaly, as all other rule sets in the Kasa API (that I've encountered at least) use random hex strings as rule identifiers.

_Originally posted by @whitslack in https://github.com/python-kasa/python-kasa/pull/453#discussion_r1196842677_

whitslack commented 1 year ago

Quoting @rytilahti:

If you have a packet capture of the communications with that module, it would be helpful to create a new issue with the available commands

Thanks to your gentle nudge, I finally got off my lazy rump and have published my Kasa Smart API documentation and tool that I've been working on for a while. I think you might benefit from the API document, as it details many methods that I believe your library is lacking.

rytilahti commented 10 months ago

Just a friendly ping, #541 adds a link to your repository, @whitslack :-)