Skip to content

Instantly share code, notes, and snippets.

@smockle
Last active December 6, 2018 06:58
Show Gist options
  • Save smockle/b48fd50d6a6cfc3ac3597c0d99d4477e to your computer and use it in GitHub Desktop.
Save smockle/b48fd50d6a6cfc3ac3597c0d99d4477e to your computer and use it in GitHub Desktop.
# Set timezone
sudo timedatectl set-timezone "America/Los_Angeles"

# DNS servers
sudo vi /etc/dhcpcd.conf
# static domain_name_servers=1.1.1.1 1.0.0.1

# Install kelvin
$ mkdir -p ~/Downloads && cd $_
$ wget https://github.com/stefanwichmann/kelvin/releases/download/v1.1.11/kelvin-linux-arm-v1.1.11.tar.gz
$ tar -xvf kelvin-linux-arm-v1.1.11.tar.gz
$ cd kelvin-linux-arm-v1.1.11
$ sudo mkdir -p /var/lib/kelvin
$ sudo cp -Rf * /var/lib/kelvin/

# Create systemd service config files
$ sudo tee /etc/systemd/system/kelvin.service << EOF
[Unit]
Description=Kelvin
ConditionPathExists=/var/lib/kelvin/kelvin
After=syslog.target network-online.target

[Service]
Type=simple
User=kelvin
Group=kelvin

Restart=always
RestartSec=10
StartLimitInterval=60s

WorkingDirectory=/var/lib/kelvin
ExecStart=/var/lib/kelvin/kelvin

[Install]
WantedBy=multi-user.target
EOF

# Create systemd service user
$ sudo useradd --system kelvin

# Enable the `kelvin` systemd service user to access files in /var/lib/kelvin
$ sudo chown -R kelvin:kelvin /var/lib/kelvin

# Enable the systemd service
$ sudo systemctl daemon-reload
$ sudo systemctl enable kelvin
$ sudo systemctl start kelvin
# Start, then press hue button. Restart if necessary

# Restart your Raspberry Pi
$ sudo reboot

# After reconnecting, verify the systemd service started successfully
$ sudo systemctl status kelvin

# View latest systemd service logs
$ sudo journalctl -fu kelvin.service

# Edit kelvin config
$ sudo -u kelvin -e /var/lib/kelvin/config.json
$ sudo systemctl restart kelvin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment