Giter Club home page Giter Club logo

kasa-controller's Introduction

Kasa Smart Plug Controller

After cloning the repository, create the virtual environment

Please note, this readme assumes the repository was cloned to /var/bin/kasa-controller

python3 -m venv lc
source lc/bin/activate
pip install -r requirements.txt

This repository was tested on Python 3.9, but an earlier of python should work. Make sure that the virtual environment is named lc since that is what the startup script uses.

To inject this into the system path, edit /etc/profile and add the following line below the existing PATH manipulation:

PATH="$PATH:/var/bin/kasa-controller";export PATH

To make the script run after the last uesr logs out, you need to edit /etc/pam.d/sshd. Add the following line:

# Execute the login/logoff scripts
session    optional     pam_exec.so quiet /etc/pam_session.sh

Then, symlink the pam_session.sh file in this repository to /etc/pam_session.sh:

ln -s /var/bin/kasa-controller/pam_session.sh /etc/pam_session.sh

Lastly, make sure that both kasa and pam_session.sh are given executable permissions:

chmod a+x kasa pam_session.sh

The main Python file, KasaControl.py takes in one positional argument and one optional argument. The positional argument tells the program whether to turn the device on or off. The optional argument tells the program what level of debugging to provide. Additionally, an IP address can be provided with the -ip flag. If an IP address is not provided, the program will read the environment variable KASA_DEVICE_IP_ADDR. You can optionally make a .env file in the repository directory:

echo KASA_CONTROL_IP_ADDR=XX.XX.XX.XX >> .env # replace XX.XX.XX.XX with your IP address
usage: kasa [-h] [--verbose] [-ip IP] {on,off}

positional arguments:
  {on,off}

optional arguments:
  -h, --help     show this help message and exit
  --verbose, -v
  -ip IP         IP address of smart plug

kasa-controller's People

Contributors

dgaiero avatar

Watchers

James Cloos avatar  avatar

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.