1#include "thingProperties.h"
2#include <Button2.h>
3#include <DaikinHeatpumpIR.h>
4
5
6constexpr int IR_PIN = 12;
7constexpr int BTN_PIN = 39;
8
9IRSenderESP32 irSender(IR_PIN, 0);
10DaikinHeatpumpIR irHeatpump;
11Button2 button;
12
13void setup() {
14
15 initProperties();
16 ArduinoCloud.begin(ArduinoIoTPreferredConnection);
17
18
19 pinMode(39, INPUT_PULLUP);
20
21
22 button.begin(BTN_PIN);
23 button.setTapHandler([](Button2& btn) {
24 mode = (mode == "OFF") ? "COOL" : "OFF";
25 send();
26 });
27}
28
29void loop() {
30 ArduinoCloud.update();
31 button.loop();
32}
33
34
35void onOnOffChange() {
36 send();
37}
38
39void send() {
40 if (mode == "HEAT") {
41 irHeatpump.send(irSender, POWER_ON, MODE_HEAT, FAN_AUTO, temperature, VDIR_UP, HDIR_AUTO);
42 } else if (mode == "COOL") {
43 irHeatpump.send(irSender, POWER_ON, MODE_COOL, FAN_AUTO, temperature, VDIR_UP, HDIR_AUTO);
44 } else if (mode == "DRY") {
45 irHeatpump.send(irSender, POWER_ON, MODE_DRY, FAN_AUTO, temperature, VDIR_UP, HDIR_AUTO);
46 } else {
47 irHeatpump.send(irSender, POWER_OFF, MODE_HEAT, FAN_AUTO, 30, VDIR_UP, HDIR_AUTO);
48 }
49}
50
51
55void onModeChange() {
56
57 send();
58}
59
63void onTemperatureChange() {
64
65 send();
66}