-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpirthing1_off.php
More file actions
executable file
·38 lines (32 loc) · 1.3 KB
/
pirthing1_off.php
File metadata and controls
executable file
·38 lines (32 loc) · 1.3 KB
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
<?php
# A simple, non-conditional script for PIRThing (https://github.com/kenkl/pirthing). PIRThing, based on
# MotionNightlight (https://github.com/kenkl/MotionNightlight), is an ESP8266 that has a PIR sensor and will call an on or
# off script here based on its logic/timings. Which unit(s) it affects are then expressed here, letting PIRThing control
# different lights with different behaviours without reflashing PIRThing itself.
# Lets put time-of-day conditionals here as needed - no point in turning on a nightlight-thing at 15:30.
include 'functions.php';
include 'pirthing1_vars.php';
if(ison($tl1)) { #if it's not already on (this would be odd), let's not do anything.
if(activetime()) {
echo "{$nowtime} - Do.\n";
if (checkState($tl1)) { #we don't actually care about the state, just that it's there
oneOff($tl1); # restoreState here will flash (~400ms) the PREVIOUS state. Just turn it off, please.
clearState($tl1);
}
else {
echo "no statefile found. NOOP.\n";
}
}
else {
echo "{$nowtime} - Do not.\n";
}
}
else {
# light is off. bail.
echo "light is off. no.\n";
}
# The bathroom nightlight thing.
oneState('false',10,1,0,254);
# AIO hook - track activation behaviour
setToggle("testtoggle", 0);
?>