Title: Set countdown timer on plug? · python-kasa/python-kasa · Discussion #284 · GitHub
Open Graph Title: Set countdown timer on plug? · python-kasa/python-kasa · Discussion #284
X Title: Set countdown timer on plug? · python-kasa/python-kasa · Discussion #284
Description: Set countdown timer on plug?
Open Graph Description: I know that there is a branch that has made some progress on implementing schedules. If it is possible yet, I was wondering if any of you wizards could provide an example script to add a countdown ...
X Description: I know that there is a branch that has made some progress on implementing schedules. If it is possible yet, I was wondering if any of you wizards could provide an example script to add a countdown ...
Opengraph URL: https://github.com/python-kasa/python-kasa/discussions/284
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Set countdown timer on plug?","text":"I know that there is a branch that has made some progress on implementing schedules. If it is possible yet, I was wondering if any of you wizards could provide an example script to add a countdown timer to power off a plug after 1 minute. My hope is to run it during shutdown on my raspberry pi, so that it can be automatically powered off after safely shutting down.
","upvoteCount":1,"answerCount":3,"acceptedAnswer":{"@type":"Answer","text":"So I just checked how this works on KP115, and from the looks of it there can only be a single countdown timer and they do not get removed automatically... However, here's what you could do using raw commands to achieve your goal:
\n\n- Create a rule that is disabled for now:
\n
\n$ kasa --host 192.168.xx.xx raw-command count_down add_rule '{\"enable\": 0, \"delay\": 5, \"act\": 0, \"name\": \"test\"}'\nNo --strip nor --bulb nor --plug given, discovering..\n{'id': 'FFCC02F439FFEE7E1D8853935949AA4A'}\n
\nNote down the rule id or perform a query to list available rules, you will need this to modify the rule to activate it later.
\nIf you get an error on already existing rule, you can either delete this by using delete_rule and passing the ID as payload, or re-use the timer by noting down the ID returned by get_rules (see the next step).
\n\n- You can check that the rule exists:
\n
\nkasa --host 192.168.xx.xx raw-command count_down get_rules\nNo --strip nor --bulb nor --plug given, discovering..\n{'rule_list': [{'id': 'FFCC02F439FFEE7E1D8853935949AA4A', 'name': 'foo', 'enable': 0, 'delay': 5, 'act': 0, 'remain': 0}]}\n
\n\n- Start the count down by setting the
enable to 1, you can also adjust other settings if wanted: \n
\nkasa --host 192.168.xx.xx raw-command count_down edit_rule '{\"id\": \"FFCC02F439FFEE7E1D8853935949AA4A\", \"enable\": 1, \"delay\": 5, \"act\": 0, \"name\": \"foo\"}'\n
\ndelay indicates in how many seconds the rule will be executed, act can be either 0 (turn off) or 1 (turn on).
\nThe action will be run after the timer expires, and it will get disabled. You can re-run the same edit_rule command to re-enable it.
","upvoteCount":3,"url":"https://github.com/python-kasa/python-kasa/discussions/284#discussioncomment-1941303"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:a0886c09-4cde-4734-fa2c-91e8f13ff4bb |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | AEB8:3E4E6:1A78805:234CA7D:69814EA9 |
| html-safe-nonce | 73bbed3bb640a77abded246c586ddc7b4cc430e1ea5f2147f7acce6e8051dada |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUI4OjNFNEU2OjFBNzg4MDU6MjM0Q0E3RDo2OTgxNEVBOSIsInZpc2l0b3JfaWQiOiI1Mzk2ODM3ODg5MDg4NzY5NzA2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 672d45208f6da5924962d10dc87daaf8e25151d53a7ee1eeed3d694c6843bca0 |
| hovercard-subject-tag | discussion:3789729 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-kasa/python-kasa/284/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/7b22e67941d410524ec00df3f0fd7971c7fdd6a2d761bd1a395bfc28d8ca6621/python-kasa/python-kasa/discussions/284 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b22e67941d410524ec00df3f0fd7971c7fdd6a2d761bd1a395bfc28d8ca6621/python-kasa/python-kasa/discussions/284 |
| og:image:alt | I know that there is a branch that has made some progress on implementing schedules. If it is possible yet, I was wondering if any of you wizards could provide an example script to add a countdown ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e5c6a4b0d37e7dc8f18034781c9e3e492fdd80eb16410763ec244c3e1caf0805 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-kasa/python-kasa git https://github.com/python-kasa/python-kasa.git |
| octolytics-dimension-user_id | 57733869 |
| octolytics-dimension-user_login | python-kasa |
| octolytics-dimension-repository_id | 221571611 |
| octolytics-dimension-repository_nwo | python-kasa/python-kasa |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 221571611 |
| octolytics-dimension-repository_network_root_nwo | python-kasa/python-kasa |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 906ec698502db8129a94bb04f4413119a1291133 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width