-
Notifications
You must be signed in to change notification settings - Fork 7
/
timer-switch-sonoff-switch-rule.txt
71 lines (64 loc) · 1.06 KB
/
timer-switch-sonoff-switch-rule.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Timer-Clock rule file for ITEAD Sonoff Smart Switch
// https://www.itead.cc/sonoff-wifi-wireless-switch.html
on System#Boot do
// Number of LED on/off to show system is ready
event LedOn
event LedOff
event LedOn
event LedOff
event LedOn
event LedOff
// Trigger Rules#Timer=1 after 5 seconds
timerSet,1,5
endon
// Allow local Button switch
on Button#State do
if [Relay#State]=1
event RelayOff
else
event RelayOn
endif
endon
// LED off/on on relay state
on Relay#State=0 do
event LedOff
endon
on Relay#State=1 do
event LedOn
endon
// Relay off/on
on RelayOff do
gpio,12,0
endon
on RelayOn do
gpio,12,1
endon
// LED off/on
on LedOff do
gpio,13,1
endon
on LedOn do
gpio,13,0
endon
// Timer Clock
on Clock#Time=All,12:00 do
event RelayOn
endon
on Clock#Time=All,22:00 do
event RelayOff
endon
// Set switch state triggered after boot
on Rules#Timer=1 do
if %systime% < 12:00
event RelayOff
else
event CheckDayTime
endif
endon
on CheckDayTime do
if %systime% > 22:00
event RelayOff
else
event RelayOn
endif
endon