Ajout Thermostat
This commit is contained in:
10
Thermostat/include/mqtt_handler.h
Normal file
10
Thermostat/include/mqtt_handler.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
void setup_mqtt(PubSubClient& client);
|
||||
void mqtt_loop(PubSubClient& client);
|
||||
void mqtt_publish_state(PubSubClient& client, ThermostatMode mode, float targetTemp, bool heating);
|
||||
void mqtt_callback(char* topic, byte* payload, unsigned int length);
|
||||
extern String mqtt_device_id;
|
||||
extern String mqtt_temp_topic;
|
||||
8
Thermostat/include/preset.h
Normal file
8
Thermostat/include/preset.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "thermostat.h"
|
||||
|
||||
void load_presets();
|
||||
void save_presets();
|
||||
float get_preset_temp(ThermostatMode mode);
|
||||
void set_preset_temp(ThermostatMode mode, float temp);
|
||||
21
Thermostat/include/thermostat.h
Normal file
21
Thermostat/include/thermostat.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
enum ThermostatMode { MODE_OFF, MODE_CONFORT, MODE_ECO, MODE_BOOST, MODE_HORS_GEL };
|
||||
|
||||
class Thermostat {
|
||||
public:
|
||||
Thermostat();
|
||||
void setMode(ThermostatMode mode);
|
||||
void setTemperature(float temp);
|
||||
void setPresetTemp(ThermostatMode mode, float temp);
|
||||
void update(float currentTemp);
|
||||
bool isHeating() const;
|
||||
ThermostatMode getMode() const;
|
||||
float getTargetTemp() const;
|
||||
private:
|
||||
ThermostatMode mode;
|
||||
float presetTemps[5];
|
||||
float targetTemp;
|
||||
bool heating;
|
||||
};
|
||||
19
Thermostat/include/web_config.h
Normal file
19
Thermostat/include/web_config.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
void setup_web_config();
|
||||
void handle_web_config();
|
||||
bool should_save_config();
|
||||
void save_config();
|
||||
void load_config();
|
||||
extern String wifi_ssid;
|
||||
extern String wifi_pass;
|
||||
extern String mqtt_server;
|
||||
extern int mqtt_port;
|
||||
extern String mqtt_user;
|
||||
extern String mqtt_pass;
|
||||
extern float preset_confort;
|
||||
extern float preset_eco;
|
||||
extern float preset_boost;
|
||||
extern float preset_hors_gel;
|
||||
extern String temp_sensor_id;
|
||||
Reference in New Issue
Block a user