Skip to content

Commit

Permalink
Added systemd service file and setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannik Sven Scharrenbach committed Dec 8, 2020
1 parent ee2b6ce commit 0aecae5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ To install the required pip packages run
python3 -m pip install -r requirements.txt
```

To setup `tado-individual-away-control` as a systemd service (and automatically start at boot) place the files to the supposed folder and execute the `setup-service.sh` script. Beforehand the configuration step below needs to be done (otherwise the service will crash)!
To get the state of the service run `sudo systemctl status tado-control`, to restart the service run `sudo systemctl restart tado-control`.
Tested on RasperryPi 3 B (Raspbian GNU/Linux 10 (buster)).

### Configuration

The `config.json` contains all tweakable parameters.
Expand Down
18 changes: 18 additions & 0 deletions setup-service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

echo "Installing pip requirements..."
python3 -m pip install -r requirements.txt || { echo 'pip install failed' ; exit 1; }
echo "Preparing service..."
sed "s#{INSTALL_DIR}#$(pwd)#" tado-control.service > /tmp/tado-control.service_TMP || { echo 'sed command failed' ; exit 1; }

echo "Setting up service..."
sudo cp /tmp/tado-control.service_TMP /etc/systemd/system/tado-control.service || { echo 'copy to /tmp failed' ; exit 1; }
sudo systemctl daemon-reload || { echo 'systemctl reload failed' ; exit 1; }
sudo systemctl start tado-control || { echo 'starting the service failed' ; exit 1; }
sudo systemctl enable tado-control || { echo 'enabling the service failed' ; exit 1; }

rm /tmp/tado-control.service_TMP

sudo systemctl status tado-control

echo "Systemd service created successfully."
14 changes: 14 additions & 0 deletions tado-control.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Tado individual away control
After=syslog.target network-online.target

[Service]
Type=simple
User=root
ExecStart=/usr/bin/python3 {INSTALL_DIR}/start.py
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

0 comments on commit 0aecae5

Please sign in to comment.