Skip to content

Commit 9dd4b36

Browse files
ilcatoaentinger
authored andcommitted
Types for home automation
1 parent ff7b2c9 commit 9dd4b36

File tree

7 files changed

+352
-0
lines changed

7 files changed

+352
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
//
2+
// This file is part of ArduinoCloudThing
3+
//
4+
// Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of ArduinoCloudThing.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
18+
#ifndef CLOUDCOLOREDLIGHT_H_
19+
#define CLOUDCOLOREDLIGHT_H_
20+
21+
/******************************************************************************
22+
INCLUDE
23+
******************************************************************************/
24+
25+
#include <math.h>
26+
#include <Arduino.h>
27+
#include "../CloudColor.h"
28+
29+
/******************************************************************************
30+
CLASS DECLARATION
31+
******************************************************************************/
32+
33+
class ColoredLight : public Color {
34+
public:
35+
bool swi;
36+
ColoredLight(bool swi, float h, float s, float b): swi(swi), Color(h, s, b) {
37+
}
38+
39+
bool operator==(ColoredLight & aLight) {
40+
return Color::operator==(aLight) && aLight.swi == swi;
41+
}
42+
43+
bool operator!=(ColoredLight & aLight) {
44+
return !(operator==(aLight));
45+
}
46+
47+
};
48+
49+
class CloudColoredLight : public CloudColor {
50+
protected:
51+
ColoredLight _value,
52+
_cloud_value;
53+
public:
54+
CloudColoredLight() : _value(false, 0, 0, 0), _cloud_value(false, 0, 0, 0) {}
55+
CloudColoredLight(bool swi, float hue, float saturation, float brightness) : _value(swi, hue, saturation, brightness), _cloud_value(swi, hue, saturation, brightness) {}
56+
57+
virtual bool isDifferentFromCloud() {
58+
59+
return _value != _cloud_value;
60+
}
61+
62+
CloudColoredLight& operator=(ColoredLight aLight) {
63+
_value.swi = aLight.swi;
64+
_value.hue = aLight.hue;
65+
_value.sat = aLight.sat;
66+
_value.bri = aLight.bri;
67+
updateLocalTimestamp();
68+
return *this;
69+
}
70+
71+
ColoredLight getCloudValue() {
72+
return _cloud_value;
73+
}
74+
75+
ColoredLight getValue() {
76+
return _value;
77+
}
78+
79+
virtual void fromCloudToLocal() {
80+
_value = _cloud_value;
81+
}
82+
virtual void fromLocalToCloud() {
83+
_cloud_value = _value;
84+
}
85+
virtual void appendAttributesToCloud() {
86+
appendAttribute(_value.swi);
87+
appendAttribute(_value.hue);
88+
appendAttribute(_value.sat);
89+
appendAttribute(_value.bri);
90+
}
91+
virtual void setAttributesFromCloud() {
92+
setAttribute(_cloud_value.swi);
93+
setAttribute(_cloud_value.hue);
94+
setAttribute(_cloud_value.sat);
95+
setAttribute(_cloud_value.bri);
96+
}
97+
};
98+
99+
#endif /* CLOUDCOLOREDLIGHT_H_ */
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// This file is part of ArduinoCloudThing
3+
//
4+
// Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of ArduinoCloudThing.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
18+
#ifndef CLOUDCONTACTSENSOR_H_
19+
#define CLOUDCONTACTSENSOR_H_
20+
21+
/******************************************************************************
22+
INCLUDE
23+
******************************************************************************/
24+
25+
#include <Arduino.h>
26+
#include "../CloudBool.h"
27+
28+
/******************************************************************************
29+
CLASS DECLARATION
30+
******************************************************************************/
31+
32+
33+
34+
class CloudContactSensor : public CloudBool {
35+
private:
36+
public:
37+
};
38+
39+
40+
#endif /* CLOUDCONTACTSENSOR_H_ */
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// This file is part of ArduinoCloudThing
3+
//
4+
// Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of ArduinoCloudThing.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
18+
#ifndef CLOUDDIMMEREDLIGHT_H_
19+
#define CLOUDDIMMEREDLIGHT_H_
20+
21+
/******************************************************************************
22+
INCLUDE
23+
******************************************************************************/
24+
25+
#include <math.h>
26+
#include <Arduino.h>
27+
#include "CloudColoredLight.h"
28+
29+
/******************************************************************************
30+
CLASS DECLARATION
31+
******************************************************************************/
32+
33+
class CloudDimmeredLight : public CloudColoredLight {
34+
private:
35+
public:
36+
float getBrightness() {
37+
return _value.bri;
38+
}
39+
bool getSwitch() {
40+
return _value.swi;
41+
}
42+
43+
virtual void appendAttributesToCloud() {
44+
appendAttribute(_value.swi);
45+
appendAttribute(_value.bri);
46+
}
47+
virtual void setAttributesFromCloud() {
48+
setAttribute(_cloud_value.swi);
49+
setAttribute(_cloud_value.bri);
50+
}
51+
};
52+
53+
#endif /* CLOUDDIMMEREDLIGHT_H_ */

types/HomeAutomation/CloudLight.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// This file is part of ArduinoCloudThing
3+
//
4+
// Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of ArduinoCloudThing.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
18+
#ifndef CLOUDLIGHT_H_
19+
#define CLOUDLIGHT_H_
20+
21+
/******************************************************************************
22+
INCLUDE
23+
******************************************************************************/
24+
25+
#include <Arduino.h>
26+
#include "../CloudBool.h"
27+
28+
/******************************************************************************
29+
CLASS DECLARATION
30+
******************************************************************************/
31+
32+
33+
34+
class CloudLight : public CloudBool {
35+
private:
36+
public:
37+
};
38+
39+
40+
#endif /* CLOUDLIGHT_H_ */
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// This file is part of ArduinoCloudThing
3+
//
4+
// Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of ArduinoCloudThing.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
18+
#ifndef CLOUDMOTIONSENSOR_H_
19+
#define CLOUDMOTIONSENSOR_H_
20+
21+
/******************************************************************************
22+
INCLUDE
23+
******************************************************************************/
24+
25+
#include <Arduino.h>
26+
#include "../CloudBool.h"
27+
28+
/******************************************************************************
29+
CLASS DECLARATION
30+
******************************************************************************/
31+
32+
33+
34+
class CloudMotionSensor : public CloudBool {
35+
private:
36+
public:
37+
};
38+
39+
40+
#endif /* CLOUDMOTIONSENSOR_H_ */

types/HomeAutomation/CloudSmartPlug.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// This file is part of ArduinoCloudThing
3+
//
4+
// Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of ArduinoCloudThing.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
18+
#ifndef CLOUDSMARTPLUG_H_
19+
#define CLOUDSMARTPLUG_H_
20+
21+
/******************************************************************************
22+
INCLUDE
23+
******************************************************************************/
24+
25+
#include <Arduino.h>
26+
#include "../CloudBool.h"
27+
28+
/******************************************************************************
29+
CLASS DECLARATION
30+
******************************************************************************/
31+
32+
33+
34+
class CloudSmartPlug : public CloudBool {
35+
private:
36+
public:
37+
};
38+
39+
40+
#endif /* CLOUDSMARTPLUG_H_ */

types/HomeAutomation/CloudSwitch.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// This file is part of ArduinoCloudThing
3+
//
4+
// Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
//
6+
// This software is released under the GNU General Public License version 3,
7+
// which covers the main part of ArduinoCloudThing.
8+
// The terms of this license can be found at:
9+
// https://www.gnu.org/licenses/gpl-3.0.en.html
10+
//
11+
// You can be released from the requirements of the above licenses by purchasing
12+
// a commercial license. Buying such a license is mandatory if you want to modify or
13+
// otherwise use the software for commercial activities involving the Arduino
14+
// software without disclosing the source code of your own applications. To purchase
15+
// a commercial license, send an email to [email protected].
16+
//
17+
18+
#ifndef CLOUDSWITCH_H_
19+
#define CLOUDSWITCH_H_
20+
21+
/******************************************************************************
22+
INCLUDE
23+
******************************************************************************/
24+
25+
#include <Arduino.h>
26+
#include "../CloudBool.h"
27+
28+
/******************************************************************************
29+
CLASS DECLARATION
30+
******************************************************************************/
31+
32+
33+
34+
class CloudSwitch : public CloudBool {
35+
private:
36+
public:
37+
};
38+
39+
40+
#endif /* CLOUDSWITCH_H_ */

0 commit comments

Comments
 (0)