Skip to content

Commit 8bd6724

Browse files
Removed the MQTT_MAX_CONNECTION_ATTEMPTS option and replaced it with a MQTT_ACTIVE option. If MQTT support is activated the script will try to connect to the MQTT broker continously and now also the reconnect is functional.
Started with the README
1 parent 0a47a2a commit 8bd6724

File tree

3 files changed

+254
-156
lines changed

3 files changed

+254
-156
lines changed

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# LedControl
2+
3+
## Wiring
4+
5+
## Installation
6+
```
7+
sudo apt-get install -y python3-pip git
8+
sudo pip3 install adafruit-ws2801
9+
sudo pip3 install paho-mqtt
10+
11+
git clone https://github.com/Tom-Hirschberger/PythonLedControl.git /home/pi/ledcontrol
12+
13+
cd /home/pi/ledcontrol
14+
cp ledcontrol.env.example ledcontrol.env
15+
16+
sudo ln -s /home/pi/ledcontrol/ledcontrol.service /etc/systemd/system/ledcontrol.service
17+
sudo systemctl enable ledcontrol
18+
```
19+
20+
## Configuration
21+
Open the file /home/pi/ledcontrol/ledcontrol.env in your favorit editor. In example:
22+
23+
```
24+
nano /home/pi/ledcontrol/ledcontrol.env
25+
```
26+
27+
### Options ###
28+
| Option | Description | Type | Default |
29+
| ------ | ----------- | ---- | ------- |
30+
| MQTT_ACTIVE | If the script should be run without MQTT support this option can be used (0=disabled, 1=enabled). | Integer | 1 |
31+
| MQTT_CLIENT_NAME | The name the client will be use while connecting to the MQTT Broker | String | "raspled" |
32+
| MQTT_BROKER_ADDRESS | The hostname or ip address of your MQTT Broker | String | "192.168.1.2" |
33+
| MQTT_TOPIC_PREFIX | The ledcontrol service not only reacts on button presses but also on MQTT messages. All these messages will be prefixed with this string | String | "raspled/" |
34+
| LED_BTN_ONE_GPIO | The GPIO number the first button is connected to (GPIO not PIN number!). | Integer | 17 |
35+
| LED_BTN_TWO_GPIO | The GPIO number the second button is connected to (GPIO not PIN number!) | Integer | 27 |
36+
37+
38+
## MQTT Messages ##
39+
The script can be configured during runtime by sending MQTT messages to your MQTT Broker. Be sure to send the messages with the configured prefix. The default is "raspled/" and will be used in the following examples.
40+
41+
### /raspled/output ###
42+
Switch the led strip on or off
43+
44+
"on" -> Switch all leds on
45+
"off" -> Switch all leds off
46+
47+
### /raspled/get_status ###
48+
Fetch the current configuration als MQTT message with the data in json format. The message will be send to the topic "raspled/status"
49+
50+
### /raspled/config ###
51+
### /raspled/color/r ###
52+
### /raspled/color/g ###
53+
### /raspled/color/b ###
54+
### /raspled/pong/num_leds ###
55+
### /raspled/pong/max_wins ###
56+
### /raspled/pong/btn_delay ###
57+
### /raspled/pong/init_delay ###
58+
### /raspled/pong/dec_per_run ###
59+
### /raspled/pong/min_delay ###
60+
### /raspled/pong/tolerance ###
61+
### /raspled/pong/color_r ###
62+
### /raspled/pong/color_g ###
63+
### /raspled/pong/color_b ###
64+
### /raspled/pong/result/color_r ###
65+
### /raspled/pong/result/color_g ###
66+
### /raspled/pong/result/color_b ###
67+
### /raspled/pong/result/delay/during ###
68+
### /raspled/pong/result/delay/after ###

ledcontrol.env.example

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
MQTT_CLIENT_NAME="raspled"
22
MQTT_BROKER_ADDRESS="192.168.1.2"
33
MQTT_TOPIC_PREFIX="raspled/"
4-
MQTT_MAX_CONNECT_ATTEMPTS=15
54
LED_BTN_ONE_GPIO=17
65
LED_BTN_TWO_GPIO=27

0 commit comments

Comments
 (0)