Skip to content

Commit 29b75d7

Browse files
committed
Tests
1 parent 17652a6 commit 29b75d7

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Diff for: README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Programmable Timer for MQTT messaging.
44

5+
[![mqtt-smarthome](https://img.shields.io/badge/mqtt-smarthome-blue.svg?style=flat-square)](https://github.com/mqtt-smarthome/mqtt-smarthome)
56
[![Build/Test](https://github.com/Legobas/mqtt-timer/actions/workflows/go.yml/badge.svg)](https://github.com/Legobas/mqtt-timer/actions/workflows/go.yml)
67
[![CI/CD](https://github.com/Legobas/mqtt-timer/actions/workflows/build.yml/badge.svg)](https://github.com/Legobas/mqtt-timer/actions/workflows/build.yml)
78
[![Go Report Card](https://goreportcard.com/badge/github.com/Legobas/mqtt-timer)](https://goreportcard.com/report/github.com/Legobas/mqtt-timer)
@@ -11,19 +12,22 @@ Programmable Timer for MQTT messaging.
1112

1213
A timer is one of the most important parts of a home automation system.
1314
It tells lights, thermostats and other devices to adjust at certain times of the day or at specific days of the week.
14-
But in addition to fixed times, a timer must also know the sunrise and sunset times, because they change every day.
15+
But in addition to fixed times, a timer must also know the sunrise and sunset times, as they are different each day.
1516
This is possible by providing the longitude and latitude coordinates.
16-
Because it is not always dark at the sunset time a timer needs to wait a certain period of time before or after sunrise/sunset.
17-
In some situations it is desirable to wait a random number of seconds or minutes.
17+
18+
Because it is not always dark at the sunset time a timer needs to wait a certain period of time before or after sunrise/sunset.
19+
In some situations it is desirable to wait a random number of seconds or minutes before sending the event.
1820
This can for example give the impression that someone is home switching the lights on every day at a different time.
21+
1922
Apart from these configurable timers, timers need to be programmable.
2023
An example is the activation of a dimmable light if motion is detected, where the light percentages will go down in the minutes after the detected movement.
21-
Another requirement is option to disable or cancel a timer.
22-
MQTT-Timer aims to meet these needs.
24+
25+
It must be possible to disable, re-enable or cancel a timer.
26+
MQTT-Timer aims to meet these requirements.
2327

2428
In a MQTT based home automation environment a timer independent from home control software like node-red or Home Assistant increases the stability of the whole system.
2529
It follows the Unix/Linux philosophy: do one thing, and do it well.
26-
If for example node-red crashes the timers will continue to send messages at desired times.
30+
If for example node-red crashes the timers will continue to send messages at the specified times.
2731

2832
## Installation
2933

Diff for: config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func Test_validate(t *testing.T) {
2323
{
2424
name: "Timer ID",
2525
args: args{
26-
config: Config{true, 0, 0, Mqtt{"url", "", "", 0, true}, []Timer{{}}},
26+
config: Config{0, 0, Mqtt{"url", "", "", 0, true}, []Timer{{}}},
2727
},
2828
wantErr: true,
2929
},

Diff for: mqtt-timer_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func Test_offsetDuration(t *testing.T) {
6565
}
6666
for _, tt := range tests {
6767
t.Run(tt.name, func(t *testing.T) {
68-
if got := offsetDuration(tt.args.timer); got != tt.want {
68+
if got := offsetDuration(&tt.args.timer); got != tt.want {
6969
t.Errorf("offsetDuration() = %v, want %v", got, tt.want)
7070
}
7171
})
@@ -117,7 +117,7 @@ func Test_timeBefore(t *testing.T) {
117117
}
118118
for _, tt := range tests {
119119
t.Run(tt.name, func(t *testing.T) {
120-
if got := timeBefore(tt.args.timer); !reflect.DeepEqual(got, tt.want) {
120+
if got := timeBefore(&tt.args.timer, tt.args.timer.Time); !reflect.DeepEqual(got, tt.want) {
121121
t.Errorf("timeWithOffset() = %v, want %v", got, tt.want)
122122
}
123123
})
@@ -148,7 +148,7 @@ func Test_offsetDescr(t *testing.T) {
148148
}
149149
for _, tt := range tests {
150150
t.Run(tt.name, func(t *testing.T) {
151-
if got := offsetDescr(tt.args.timer); got != tt.want {
151+
if got := offsetDescr(&tt.args.timer); got != tt.want {
152152
t.Errorf("offsetDescr() = %v, want %v", got, tt.want)
153153
}
154154
})

0 commit comments

Comments
 (0)