-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNightMode.cpp
39 lines (29 loc) · 867 Bytes
/
NightMode.cpp
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
#include <iostream>
#include "lightbulb.h"
using namespace std;
int main() {
cout << "Connecting to lights..." << endl;
Lightbulb bulb1("192.168.1.24");
Lightbulb bulb2("192.168.1.25");
Lightbulb lamp("192.168.1.26");
cout << "Transitioning to Night Mode..." << endl;
int duration = 30000;
if (bulb1.getConnected() && bulb1.getState().getIsOn()) {
bulb1.setAllowTimeouts(false);
bulb1.turnOff(duration);
}
if (bulb2.getConnected() && bulb2.getState().getIsOn()) {
bulb2.setAllowTimeouts(false);
bulb2.turnOff(duration);
}
if (lamp.getConnected() && lamp.getState().getIsOn()) {
lamp.setAllowTimeouts(false);
if (lamp.getState().getBrightness() > 50) {
lamp.setHSB(0, 100, 50, duration);
}
else {
lamp.setHSB(0, 100, lamp.getState().getBrightness(), duration);
}
}
cout << "Night mode activated. Good night :)" << endl;
}