-
Notifications
You must be signed in to change notification settings - Fork 0
Linux
Running directly on a host operation system is another way that the Red Reactor program can be ran - since it is packaged as a Python PIP package it can easily be run as so. We will be running the Red Reactor program within a Python Virtual Environment as it is generally considered the more secure method to run a Python program.
Log in to your machine, and open up a terminal and install Python 3, Python 3 PIP and Python 3 Virtual Environment
apt-get install python3 python3-pip python3-venvCreate a Python Virtual Environment
python3 -m venv /var/lib/redreactor/.venvInstall the Red Reactor python package within the virtual environment
/var/lib/redreactor/.venv/bin/python -m pip install redreactorCopy the configuration file into /etc/redreactor/config.yaml. This is a simplified version of the example configuration file that can be found here. Configure your MQTT server settings.
# MQTT Configuration
mqtt:
broker: 127.0.0.1 # MQTT Broker Address
port: 1883 # MQTT Port
user: testing # MQTT Broker username
password: testing # MQTT Broker password
version: 5 # MQTT Version 5 or 3
# Hostname Configuration
hostname:
name: redreactor-pi
pretty: Red Reactor PI
# Home Assistant Configuration
homeassistant:
discovery: true # Enable Home Assistant autodiscovery
topic: homeassistant # Home Assistant discovery topic
discovery_interval: 120 # Discovery configuration push interval
expire_after: 120 # Adds a MQTT expire time to data received by Home Assistant
# System Commands
system:
shutdown: sudo shutdown 0 -h
restart: sudo shutdown 0 -r
# Logging Levels
logging:
console: DEBUG
file: INFONow you should be able to test it working, by running this command.
/var/lib/redreactor/.venv/bin/python -m redreactor --config=/etc/redreactor/config.yaml --log=/etc/redreactor/redreactor.logCreating a systemd service requires you to create a file at /etc/systemd/system/redreactor.service. Copy the contents below into the file.
[Unit]
Description=Red Reactor Service
After=network.target
# Restart if service fails but terminate retries if repeated start-up error
StartLimitIntervalSec=60
StartLimitBurst=5
[Service]
WorkingDirectory=/var/lib/redreactor/
ExecStart=/var/lib/redreactor/.venv/bin/python -m redreactor --config=/etc/redreactor/config.yaml --log=/etc/redreactor/redreactor.log
# Restart on failure after 5 seconds
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetReload the Systemd Daemon
systemctl daemon-reloadStart the Red Reactor service
systemctl start redreactor.serviceDisplay the status of the Red Reactor service - to check that it is running properly without any errors.
systemctl status redreactor.serviceEnable the Systemd service to start after boot
systemctl enable redreactor.serviceThis should start the program running on boot now, as long as there were no errors on startup. You can see the errors that are produced by doing running the command systemctl status redreactor.service. If you'd like to see the logs, then run tail -f /etc/redreactor/redreactor.log and this will follow the live feed of the log created by the Red Reactor service.
If this doesn't work for you let me know by creating a issue here.