-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathThermostatAccessory.h
50 lines (42 loc) · 1.14 KB
/
ThermostatAccessory.h
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
#ifndef THERMOSTAT_ACCESSORY_H
#define THERMOSTAT_ACCESSORY_H
#include "HomeSpan.h"
#include "Config.h"
#include "IRController.h"
#if USE_BME680
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>
#else
#include <DHT.h>
#endif
class ThermostatAccessory : public Service::Thermostat {
private:
#if USE_BME680 == 1
Adafruit_BME680 *bme;
uint8_t sdaPin;
uint8_t sclPin;
#else
DHT *dht;
#endif
IRController *irController;
unsigned long lastReadTime = 0;
const unsigned long readInterval = 60000;
float lastSentTemp = 0.0;
float lastSentHumidity = 0.0;
SpanCharacteristic *currentState;
SpanCharacteristic *targetState;
SpanCharacteristic *currentTemp;
SpanCharacteristic *unit;
SpanCharacteristic *targetTemp;
SpanCharacteristic *currentHumidity;
public:
#if USE_BME680
ThermostatAccessory(Adafruit_BME680 *bmeSensor, IRController *irCtrl, uint8_t sdaPin, uint8_t sclPin);
#else
ThermostatAccessory(DHT *dhtSensor, IRController *irCtrl);
#endif
boolean update();
void loop();
void readTemperatureAndHumidity();
};
#endif