Giter Site home page Giter Site logo

smart_switch's Introduction

Smart Switch

Install

  1. Setup static dev device Ref: linux - How to bind USB device under a static name? - Unix & Linux Stack Exch…

    Plugin your arduino smart switch

    Find out your device info (assuming it’s on /dev/ttyUSB0 at the moment).

    udevadm info -a -p  $(udevadm info -q path -n /dev/ttyUSB0)
        

    Enter a rule in /lib/udev/rules.d/60-persistent-iot.rules

    ACTION=="add", ATTRS{idVendor}=="1d6b", ATTRS{idProduct}=="0002", SYMLINK+="smart_switch"
        

    (Change 1d6b and 0002 with your idVendor and idProduct)

    Now replug in your smart switch and it should have a symlink as /dev/smart_switch. This is what is used in this program.

  2. Add your user to dialout group Edit the /etc/group and add your user then relogin.
  3. Start rails server
    rails s -b 10.1.1.10
        

Setup shortcuts

On my remote I’ve setup in Flirc.tv the shortcuts

Ctrl + Super + c = computer (tv + amp) Ctrl + Super + l = light

Shortcuts

Light toggle

curl http://10.1.1.10:3000/buttons/3/toggle

TV toggle

curl http://10.1.1.10:3000/buttons/2/toggle

I use the package ‘xbindkeys’ to set the shortcuts and then I can control it with the remote

Add the following to ~/.xbindkeysrc

“curl http://10.1.1.10:3000/buttons/2/toggle” Control+Mod4 + c

“curl http://10.1.1.10:3000/buttons/3/toggle” Control+Mod4 + l

This depends on what windows manager you use. I’m using LXQT on my media center.

LXQt -> Preferences -> LXQt Settings -> Session Settings.

In here you can add more autostart items such as;

xbindkeys
cd ~/code/smart_switch;rails s -b 10.1.1.10

Adding to startup

Add the following to /lib/systemd/system/smart_switch.service

[Unit]
Description=Smart Switch
Requires=network.target
 
[Service]
Type=simple
User=kodi
Group=kodi
WorkingDirectory=/home/kodi/code/smart_switch
ExecStart=/bin/bash -lc 'bundle exec rails server --bind 10.1.1.10'
TimeoutSec=30
RestartSec=15s
Restart=always
 
[Install]
WantedBy=multi-user.target

Now type the following

sudo systemctl enable smart_switch.service
sudo service smart_switch start

smart_switch's People

Contributors

map7 avatar

Watchers

 avatar James Cloos 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.