Git Product home page Git Product logo

poweroverinternet's Introduction

🌩️ PowerOverInternet

GitHub Actions Testspace Coveralls

Web service with an HTTP API for turning smart power outlets on and off

  1. Prerequisites
  2. Installation
  3. Usage
  4. API Reference

Prerequisites

Installation

For 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.

IIS

  1. Install the .NET Core Hosting Bundle for IIS.
  2. Copy the build files from the latest release of this project to a folder on your server.
  3. In IIS Manager, add a new Website to your server's Sites.
  4. Choose a name and binding for the site.
  5. Choose that folder as the site's physical path.

For more information, refer to Host ASP.NET Core on Windows with IIS and Publish an ASP.NET Core app to IIS.

Add Website

Standalone

  1. Copy the build files from the latest release of this project to a folder on your server.
  2. In that folder, run PowerOverInternet.exe.
> .\PowerOverInternet.exe


info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Program Files\PowerOverInternet\

Usage

Turn on an outlet

PUT /power?outletHostname=192.168.1.100&turnOn=true
Host: myserver.com

Turn off an outlet

PUT /power?outletHostname=192.168.1.100&turnOn=false
Host: myserver.com

Turn off an outlet after 30 seconds

PUT /power?outletHostname=192.168.1.100&turnOn=false&delaySec=30
Host: myserver.com

Shut down and power off Cisco endpoint using macro

This Cisco macro cuts power to the endpoint after a confirmation prompt and a 33 second graceful shutdown delay.

await xapi.Command.HttpClient.Put({
    Url: "https://thor.aldaviva.com:8444/power?outletHostname=sx20.outlets.aldaviva.com&turnOn=false&delaySec=33" //it takes the SX20 about 28 seconds to shut down
}, "");

Phone charger control

This Automate flow turns off a phone charger when the phone is ≥80% charged, and turns it back on when it's ≤20% charged.

Download flow

This flow requires the Automate legacy extension 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.

Automate flow

API Reference

PUT /power

Parameter Required Location Example Description
outletHostname 🛑 required ❔ query 192.168.1.100 The IP address or FQDN of your smart outlet, visible in router DHCP list or nmap scan.
turnOn 🛑 required ❔ query true true to turn the outlet on, or false to turn it off.
delaySec 🟢 optional ❔ query 30 Number of seconds to wait after receiving the request before changing the outlet's power state. Defaults to 0 if omitted.

Response status: 204 No Content

The response is sent immediately, not after waiting for delaySec seconds.

poweroverinternet's People

Contributors

aldaviva avatar dependabot[bot] avatar

Watchers

 avatar  avatar

poweroverinternet's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.