{"id":15779715,"url":"https://github.com/aldaviva/poweroverinternet","last_synced_at":"2025-08-01T10:38:32.884Z","repository":{"id":70211944,"uuid":"499767173","full_name":"Aldaviva/PowerOverInternet","owner":"Aldaviva","description":"🌩️ Turn on and off power to an electrical outlet using an HTTP API request","archived":false,"fork":false,"pushed_at":"2023-10-10T01:33:31.000Z","size":394,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T07:08:33.464Z","etag":null,"topics":["home-automation","smart-outlets","smart-plug","smarthome","smartplug"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aldaviva.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://paypal.me/aldaviva"]}},"created_at":"2022-06-04T08:22:23.000Z","updated_at":"2024-11-25T17:00:03.000Z","dependencies_parsed_at":"2024-10-04T18:21:16.188Z","dependency_job_id":null,"html_url":"https://github.com/Aldaviva/PowerOverInternet","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerOverInternet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerOverInternet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerOverInternet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2FPowerOverInternet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aldaviva","download_url":"https://codeload.github.com/Aldaviva/PowerOverInternet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246492241,"owners_count":20786333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["home-automation","smart-outlets","smart-plug","smarthome","smartplug"],"created_at":"2024-10-04T18:21:12.546Z","updated_at":"2025-08-01T10:38:32.873Z","avatar_url":"https://github.com/Aldaviva.png","language":"C#","funding_links":["https://paypal.me/aldaviva"],"categories":[],"sub_categories":[],"readme":"🌩️ PowerOverInternet\n===\n\n[![GitHub Actions](https://img.shields.io/github/actions/workflow/status/Aldaviva/PowerOverInternet/dotnet.yml?branch=master\u0026logo=github)](https://github.com/Aldaviva/PowerOverInternet/actions/workflows/dotnet.yml) [![Testspace](https://img.shields.io/testspace/tests/Aldaviva/Aldaviva:PowerOverInternet/master?passed_label=passing\u0026failed_label=failing\u0026logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4NTkgODYxIj48cGF0aCBkPSJtNTk4IDUxMy05NCA5NCAyOCAyNyA5NC05NC0yOC0yN3pNMzA2IDIyNmwtOTQgOTQgMjggMjggOTQtOTQtMjgtMjh6bS00NiAyODctMjcgMjcgOTQgOTQgMjctMjctOTQtOTR6bTI5My0yODctMjcgMjggOTQgOTQgMjctMjgtOTQtOTR6TTQzMiA4NjFjNDEuMzMgMCA3Ni44My0xNC42NyAxMDYuNS00NFM1ODMgNzUyIDU4MyA3MTBjMC00MS4zMy0xNC44My03Ni44My00NC41LTEwNi41UzQ3My4zMyA1NTkgNDMyIDU1OWMtNDIgMC03Ny42NyAxNC44My0xMDcgNDQuNXMtNDQgNjUuMTctNDQgMTA2LjVjMCA0MiAxNC42NyA3Ny42NyA0NCAxMDdzNjUgNDQgMTA3IDQ0em0wLTU1OWM0MS4zMyAwIDc2LjgzLTE0LjgzIDEwNi41LTQ0LjVTNTgzIDE5Mi4zMyA1ODMgMTUxYzAtNDItMTQuODMtNzcuNjctNDQuNS0xMDdTNDczLjMzIDAgNDMyIDBjLTQyIDAtNzcuNjcgMTQuNjctMTA3IDQ0cy00NCA2NS00NCAxMDdjMCA0MS4zMyAxNC42NyA3Ni44MyA0NCAxMDYuNVMzOTAgMzAyIDQzMiAzMDJ6bTI3NiAyODJjNDIgMCA3Ny42Ny0xNC44MyAxMDctNDQuNXM0NC02NS4xNyA0NC0xMDYuNWMwLTQyLTE0LjY3LTc3LjY3LTQ0LTEwN3MtNjUtNDQtMTA3LTQ0Yy00MS4zMyAwLTc2LjY3IDE0LjY3LTEwNiA0NHMtNDQgNjUtNDQgMTA3YzAgNDEuMzMgMTQuNjcgNzYuODMgNDQgMTA2LjVTNjY2LjY3IDU4NCA3MDggNTg0em0tNTU3IDBjNDIgMCA3Ny42Ny0xNC44MyAxMDctNDQuNXM0NC02NS4xNyA0NC0xMDYuNWMwLTQyLTE0LjY3LTc3LjY3LTQ0LTEwN3MtNjUtNDQtMTA3LTQ0Yy00MS4zMyAwLTc2LjgzIDE0LjY3LTEwNi41IDQ0UzAgMzkxIDAgNDMzYzAgNDEuMzMgMTQuODMgNzYuODMgNDQuNSAxMDYuNVMxMDkuNjcgNTg0IDE1MSA1ODR6IiBmaWxsPSIjZmZmIi8%2BPC9zdmc%2B)](https://aldaviva.testspace.com/spaces/192613) [![Coveralls](https://img.shields.io/coveralls/github/Aldaviva/PowerOverInternet?logo=coveralls)](https://coveralls.io/github/Aldaviva/PowerOverInternet?branch=master)\n\n*Web service with an HTTP API for turning smart power outlets on and off*\n\n\u003c!-- MarkdownTOC autolink=\"true\" bracket=\"round\" autoanchor=\"true\" levels=\"1,2\" bullets=\"1.,-,-,-\" --\u003e\n\n1. [Prerequisites](#prerequisites)\n1. [Installation](#installation)\n1. [Usage](#usage)\n1. [API Reference](#api-reference)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\u003ca id=\"prerequisites\"\u003e\u003c/a\u003e\n## Prerequisites\n\n- [ASP.NET Core Runtime 8 or later](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)\n- [Kasa smart outlet](https://www.kasasmart.com/us/products/smart-plugs)\n    - Verified with [EP10](https://www.kasasmart.com/us/products/smart-plugs/kasa-smart-plug-mini-ep10), [KP125](https://www.kasasmart.com/us/products/smart-plugs/kasa-smart-plug-slim-energy-monitoring-kp125), and [EP40](https://www.kasasmart.com/us/products/smart-plugs/kasa-smart-wi-fi-outdoor-plug)\n    - Probably [compatible](https://github.com/Aldaviva/Kasa#prerequisites) with most other models\n\n\u003ca id=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nFor additional hosting and deployment scenarios not covered in this section, such as `HTTP.sys` and Windows services, refer to [Host and deploy ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/?view=aspnetcore-6.0).\n\n### IIS\n\n1. Install the [.NET Core Hosting Bundle](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/hosting-bundle?view=aspnetcore-8.0) for IIS.\n1. Copy the build files from the [latest release of this project](https://github.com/Aldaviva/PowerOverInternet/releases/latest) to a folder on your server.\n1. In IIS Manager, add a new Website to your server's Sites.\n1. Choose a name and binding for the site.\n1. Make a new empty Application Pool for the site.\n1. Choose that folder as the site's physical path.\n\nFor more information, refer to [Host ASP.NET Core on Windows with IIS](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-8.0) and [Publish an ASP.NET Core app to IIS](https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-8.0\u0026tabs=netcore-cli).\n\n\n![Add Website](https://raw.githubusercontent.com/Aldaviva/PowerOverInternet/master/.github/images/iis-new-site.png)\n\n### Standalone\n\n1. Copy the build files from the [latest release of this project](https://github.com/Aldaviva/PowerOverInternet/releases/latest) to a folder on your server.\n1. In that folder, run `PowerOverInternet.exe`.\n\n```ps1\n\u003e .\\PowerOverInternet.exe\n\n\ninfo: Microsoft.Hosting.Lifetime[14]\n      Now listening on: http://localhost:5000\ninfo: Microsoft.Hosting.Lifetime[14]\n      Now listening on: https://localhost:5001\ninfo: Microsoft.Hosting.Lifetime[0]\n      Application started. Press Ctrl+C to shut down.\ninfo: Microsoft.Hosting.Lifetime[0]\n      Hosting environment: Production\ninfo: Microsoft.Hosting.Lifetime[0]\n      Content root path: C:\\Program Files\\PowerOverInternet\\\n```\n\n\u003ca id=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\n### Turn on an outlet\n\n```http\nPUT /power?outletHostname=192.168.1.100\u0026turnOn=true\nHost: myserver.com\n```\n\n### Turn off an outlet\n\n```http\nPUT /power?outletHostname=192.168.1.100\u0026turnOn=false\nHost: myserver.com\n```\n\n### Toggle an outlet\n\n```http\nPUT /power?outletHostname=192.168.1.100\u0026turnOn=toggle\nHost: myserver.com\n```\n\n### Turn off an outlet after 30 seconds\n\n```http\nPUT /power?outletHostname=192.168.1.100\u0026turnOn=false\u0026delaySec=30\nHost: myserver.com\n```\n\n### Turn on the second socket of a multi-socket outlet\n\n```http\nPUT /power?outletHostname=192.168.1.101\u0026socketId=1\u0026turnOn=true\nHost: myserver.com\n```\n\n### Shut down and power off Cisco endpoint using macro\n\nThis [Cisco macro](https://gist.github.com/Aldaviva/bccd766099e2d7807da086feacf2c18a#file-shutdown-button-js-L22) cuts power to the endpoint after a confirmation prompt and a 33 second graceful shutdown delay.\n\n```js\nawait xapi.Command.HttpClient.Put({\n    Url: \"https://thor.aldaviva.com:8444/power?outletHostname=sx20.outlets.aldaviva.com\u0026turnOn=false\u0026delaySec=33\" //it takes the SX20 about 28 seconds to shut down\n}, \"\");\n```\n\n### Phone charger control\n\nThis [Automate](https://llamalab.com/automate/) flow turns off a phone charger when the phone is ≥80% charged, and turns it back on when it's ≤20% charged.\n\n[**Download flow**](.github/files/charging-limiter.flo)\n\nThis flow requires the [Automate legacy extension](https://llamalab.com/automate/doc/extensions.html) app to be installed so that it can show the battery percentage in the status bar while it's charging, and hide it when it's discharging.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\".github/images/charging-limiter.png\" alt=\"Automate flow\" height=\"640\" /\u003e\u003c/p\u003e\n\n\u003ca id=\"api-reference\"\u003e\u003c/a\u003e\n## API Reference\n\n### `PUT /power`\n\n|Parameter|Required|Location|Example|Description|\n|---|---|---|---|---|\n|`outletHostname`|🛑\u0026nbsp;required|❔\u0026nbsp;query|`192.168.1.100`|The IP address or FQDN of your smart outlet, visible in router DHCP list or [`nmap`](https://nmap.org/) scan.|\n|`turnOn`|🛑\u0026nbsp;required|❔\u0026nbsp;query|`true`|`true` to turn the outlet on, `false` to turn it off, or `toggle` to change its state.|\n|`delaySec`|🟢\u0026nbsp;optional|❔\u0026nbsp;query|`30`|Number of seconds to wait after receiving the request before changing the outlet's power state. Defaults to `0` if omitted.|\n|`socketId`|🟢\u0026nbsp;optional|❔\u0026nbsp;query|`0`|If your Kasa smart outlet has multiple electrical sockets (such as the EP40), you can specify which socket to turn on or off, starting from `0`. Defaults to `0` if omitted, which also works with single-socket outlets like the EP10.|\n\n**Response status:** `204 No Content`\n\nThe response is sent immediately, not after waiting for `delaySec` seconds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fpoweroverinternet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldaviva%2Fpoweroverinternet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fpoweroverinternet/lists"}