Added install script
This commit is contained in:
parent
f1506a45f5
commit
ea7097a016
23
install.sh
Executable file
23
install.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
rm -rfv /usr/share/zigbee-opener/
|
||||||
|
|
||||||
|
mkdir -p /usr/share/zigbee-opener/
|
||||||
|
mkdir -p /var/run/zigbee-opener/
|
||||||
|
|
||||||
|
cp -v main.py /usr/share/zigbee-opener/
|
||||||
|
cp -v settings.py /usr/share/zigbee-opener/
|
||||||
|
chmod +x /usr/share/zigbee-opener/main.py
|
||||||
|
|
||||||
|
cp -f zigbee-opener.service /etc/systemd/system/
|
||||||
|
|
||||||
|
python -m venv /usr/share/zigbee-opener/.venv/
|
||||||
|
source /usr/share/zigbee-opener/.venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Installed into /usr/share/zigbee-opener/"
|
||||||
|
echo "with service zigbee-opener"
|
||||||
|
echo ""
|
||||||
|
echo "Configure in /usr/share/zigbee-opener/settings.py"
|
5
main.py
5
main.py
@ -1,4 +1,4 @@
|
|||||||
#!/bin/env python
|
#!./.venv/bin/python
|
||||||
import zigate
|
import zigate
|
||||||
from zigate import dispatcher
|
from zigate import dispatcher
|
||||||
import time
|
import time
|
||||||
@ -42,10 +42,11 @@ def trigger_closing():
|
|||||||
global is_opening
|
global is_opening
|
||||||
global is_closing
|
global is_closing
|
||||||
|
|
||||||
if is_opening:
|
if is_closing:
|
||||||
return
|
return
|
||||||
|
|
||||||
is_closing = True
|
is_closing = True
|
||||||
|
is_opening = False
|
||||||
|
|
||||||
for i in range(0, CLOSING_TRIGGER_DELAY):
|
for i in range(0, CLOSING_TRIGGER_DELAY):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -13,5 +13,5 @@ OPENING_TRIGGER_DELAY = 30
|
|||||||
# Delay to wait before marking room as closed
|
# Delay to wait before marking room as closed
|
||||||
CLOSING_TRIGGER_DELAY = 5
|
CLOSING_TRIGGER_DELAY = 5
|
||||||
|
|
||||||
LOL_OPENED_CMD = "ln -f -s a.txt test/status.txt"
|
LOL_OPENED_CMD = """echo "opened" > /var/run/zigbee-opener/status """
|
||||||
LOL_CLOSED_CMD = "ln -f -s b.txt test/status.txt"
|
LOL_CLOSED_CMD = """echo "closed" > /var/run/zigbee-opener/status """
|
@ -1 +1 @@
|
|||||||
a.txt
|
b.txt
|
9
uninstall.sh
Executable file
9
uninstall.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
rm -rfv /usr/share/zigbee-opener/
|
||||||
|
rm -rfv /var/run/zigbee-opener/
|
||||||
|
rm -fv /etc/systemd/system/zigbee-opener.service
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Uninstalled"
|
12
zigbee-opener.service
Normal file
12
zigbee-opener.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Zigbee LOL opening detection system
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
ExecStart=/usr/share/zigbee-opener/main.py
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/usr/share/zigbee-opener/
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user