- 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.
- Add your user to dialout group Edit the /etc/group and add your user then relogin.
- Start rails server
rails s -b 10.1.1.10
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
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