1
- # mqtt-timer
1
+ # MQTT-Timer
2
2
3
- Programmable Timer for MQTT
3
+ Programmable Timer for MQTT messaging.
4
4
5
5
[ ![ Build/Test] ( https://github.com/Legobas/mqtt-timer/actions/workflows/go.yml/badge.svg )] ( https://github.com/Legobas/mqtt-timer/actions/workflows/go.yml )
6
6
[ ![ CI/CD] ( https://github.com/Legobas/mqtt-timer/actions/workflows/build.yml/badge.svg )] ( https://github.com/Legobas/mqtt-timer/actions/workflows/build.yml )
@@ -9,9 +9,18 @@ Programmable Timer for MQTT
9
9
[ ![ Docker Stars] ( https://badgen.net/docker/stars/legobas/mqtt-timer?icon=docker&label=stars )] ( https://hub.docker.com/r/legobas/mqtt-timer )
10
10
[ ![ Docker Image Size] ( https://badgen.net/docker/size/legobas/mqtt-timer?icon=docker&label=image%20size )] ( https://hub.docker.com/r/legobas/mqtt-timer )
11
11
12
- MQTT-Timer is a programmable timer for MQTT messaging.
13
- Common daily or weekly timers can be specified in the configuration.
14
- Any timers can be added by MQTT JSON messages.
12
+ ## Features
13
+
14
+ * Standard timers are configurable
15
+ * Timers can fire daily or at specific days of the week
16
+ * Timers can use daily sunrise & sunset times based on the latitude/longitude coordinates
17
+ * Timers can have a fixed offset before or after a timestamp
18
+ * Timers can have a random offset before or after a timestamp
19
+ * Timers can be removed/reset
20
+ * Programmable timers can be specified by MQTT JSON Messages
21
+ * Programmable timers are repeatable
22
+ * Programmable timers can wait for a random number of seconds/minutes before being fired
23
+ * A range of programmable timers can be set with one MQTT message
15
24
16
25
## Installation
17
26
@@ -21,51 +30,57 @@ $ go get -u github.com/Legobas/mqtt-timer
21
30
22
31
# Configuration
23
32
24
- MQTT-Timer can be configured with the ` config.yml ` yaml configuration file.
25
-
26
-
27
- | Config item | Description |
28
- | ------------------------- | ------------------------------------------------------------- |
29
- | latitude/longitude | GPS location used for Sunrise/Sunset |
30
- | MQTT |
31
- | URL | MQTT Server URL |
32
- | Username/Password | MQTT Server Credentials |
33
- | QOS | MQTT Server Quality Of Service |
34
- | Retain | MQTT Server Retain messages |
35
- | Timers |
36
- | id | Unique ID for this message (mandatory) |
37
- | time | Time in 15:04 or 15:04:05 format |
38
- | cron | Cron in '30 7 * * * ' or '15 30 7 * * * ' (with seconds) format |
39
- | topic | MQTT Topic |
40
- | message | simple string or JSON |
41
- | before, after | offset: fixed number of second or minutes |
42
- | randomBefore, randomAfter | offset: random number of second or minutes |
33
+ MQTT-Timer can be configured with the ` mqtt-timer.yml ` yaml configuration file.
34
+ The ` mqtt-timer.yml ` file has to exist in one of the following locations:
35
+
36
+ * A config directory in de filesystem root: ` /config/mqtt-timer.yml `
37
+ * A .config directory in the user home directory ` ~/.config/mqtt-timer.yml `
38
+ * The current working directory
39
+
40
+ ## Configuration options
41
+
42
+ | Config item | Description |
43
+ | ------------------------- | ----------------------------------------------------------------- |
44
+ | latitude/longitude | GPS location used for Sunrise/Sunset |
45
+ | ** MQTT** | |
46
+ | URL | MQTT Server URL |
47
+ | Username/Password | MQTT Server Credentials |
48
+ | QOS | MQTT Server Quality Of Service |
49
+ | Retain | MQTT Server Retain messages |
50
+ | ** Timers** | |
51
+ | id | Unique ID for this message (mandatory) |
52
+ | time | Time in ` 15:04 ` or ` 15:04:05 ` format |
53
+ | cron | Cron in '` 30 7 * * * ` ' or '` 15 30 7 * * * ` ' (with seconds) format |
54
+ | topic | MQTT Topic |
55
+ | message | simple string or JSON |
56
+ | before, after | offset: fixed number of seconds or minutes |
57
+ | randomBefore, randomAfter | offset: random number of seconds or minutes |
43
58
44
59
Example config.yml:
45
60
46
61
``` yml
47
- latitude : 51.50722
48
- longitude : -0.1275
49
-
50
- mqtt :
51
- url : " tcp://<MQTT SERVER>:1883"
52
- username : <MQTT USERNAME>
53
- password : <MQTT PASSWORD>
54
- qos : 0
55
- retain : false
56
-
57
- timers :
58
- - id : 001
59
- time : 22:30
60
- description : Light outside on at 22:30
61
- topic : shellies/Shelly1/relay/0/command
62
- message : on
63
- - id : 002
64
- time : sunrise
65
- before : 20 minutes
66
- description : Light outside off 20 minutes before sunrise
67
- topic : shellies/Shelly1/relay/0/command
68
- message : off
62
+ latitude : 51.50722
63
+ longitude : -0.1275
64
+
65
+ mqtt :
66
+ url : " tcp://<MQTT SERVER>:1883"
67
+ username : <MQTT USERNAME>
68
+ password : <MQTT PASSWORD>
69
+ qos : 0
70
+ retain : false
71
+
72
+ timers :
73
+ - id : 001
74
+ time : 22:30
75
+ description : Light outside on at 22:30
76
+ topic : shellies/Shelly1/relay/0/command
77
+ message : on
78
+ - id : 002
79
+ time : sunrise
80
+ before : 20 minutes
81
+ description : Light outside off 20 minutes before sunrise
82
+ topic : shellies/Shelly1/relay/0/command
83
+ message : off
69
84
` ` `
70
85
71
86
See also: [example/config.yml](example/config.yml)
@@ -77,25 +92,23 @@ See also: [example/config.yml](example/config.yml)
77
92
` ` ` json
78
93
{
79
94
" id " : " msg001" ,
80
- " description " : " Dim light from now every 10 min." ,
81
- " start " : " 15:03:00" ,
82
- " repeat " : " 1 min" ,
83
- " repeatTimes " : 10,
95
+ " description " : " Dim light" ,
96
+ " start " : " now" ,
84
97
" randomAfter " : " 1 min" ,
85
- " topic " : " homeassistant/light04/dimmer" ,
98
+ " topic " : " / homeassistant/light04/dimmer" ,
86
99
" message " : " 10%" ,
87
- " messages " : ["100%", "80%", "60%", "20%", "0%"]
88
100
}
89
-
101
+ ```
90
102
91
103
## Timezone
92
104
93
105
By default all the times will be in the timezone of the server.
94
106
In a docker environment the timezone can be specified by the TZ environment variable.
107
+
95
108
For example:
96
109
97
110
``` bash
98
- $ docker run -e TZ=Europe/London mqtt-timer
111
+ $ docker run -e TZ=America/New_York mqtt-timer
99
112
```
100
113
101
114
## Credits
0 commit comments