supla-device
Loading...
Searching...
No Matches
therm_hygro_meter.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_SENSOR_THERM_HYGRO_METER_H_
5#define SRC_SUPLA_SENSOR_THERM_HYGRO_METER_H_
6
7#include <supla/channel_element.h>
8#include <supla/sensor/thermometer_driver.h>
9
10#define HUMIDITY_NOT_AVAILABLE -1
11
12namespace Supla {
13namespace Sensor {
15 public:
17
18 void setRefreshIntervalMs(int intervalMs);
19
20 void onInit() override;
21 void onLoadConfig(SuplaDeviceClass *) override;
22 void iterateAlways() override;
23 void fillChannelConfig(void *channelConfig,
24 int *size,
25 uint8_t configType) override;
26 void purgeConfig() override;
27
28 virtual double getTemp();
29 virtual double getHumi();
30
31 int16_t getTempInt16();
32 int16_t getHumiInt16();
33
34 Supla::ApplyConfigResult applyChannelConfig(TSD_ChannelConfig *result,
35 bool local) override;
36
37 int16_t getConfiguredTemperatureCorrection();
38 int16_t getConfiguredHumidityCorrection();
39
48 void applyCorrectionsAndStoreIt(int32_t temperatureCorrection,
49 int32_t humidityCorrection,
50 bool local = false);
51
64
73 void setMinMaxAllowedTemperatureAdjustment(int32_t minMax);
74
83 void setMinMaxAllowedHumidityAdjustment(int32_t minMax);
84
85 protected:
86 int16_t readCorrectionFromIndex(int index);
87 void setCorrectionAtIndex(int32_t correction, int index);
88 virtual void setTemperatureCorrection(int32_t correction);
89 virtual void setHumidityCorrection(int32_t correction);
90
91 uint32_t lastReadTime = 0;
92 uint16_t refreshIntervalMs = 10000;
93
99
105
109 bool applyCorrections = true;
110};
111
112}; // namespace Sensor
113}; // namespace Supla
114
115#endif // SRC_SUPLA_SENSOR_THERM_HYGRO_METER_H_
Definition SuplaDevice.h:167
Definition channel_element.h:15
Definition therm_hygro_meter.h:14
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition therm_hygro_meter.cpp:76
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition therm_hygro_meter.cpp:69
bool applyCorrections
Whether correction should be applied by SD.
Definition therm_hygro_meter.h:109
void applyCorrectionsAndStoreIt(int32_t temperatureCorrection, int32_t humidityCorrection, bool local=false)
Apply temperature and humidity corrections and store them to Config.
Definition therm_hygro_meter.cpp:238
void setApplyCorrections(bool applyCorrections)
Set whether correction should be applied or not.
Definition therm_hygro_meter.cpp:291
int16_t minMaxAllowedTemperatureAdjustment
Minimum and maximum allowed temperature adjustment in 0.1 degree C.
Definition therm_hygro_meter.h:98
void setMinMaxAllowedHumidityAdjustment(int32_t minMax)
Set minimum and maximum allowed humidity adjustment.
Definition therm_hygro_meter.cpp:307
void setMinMaxAllowedTemperatureAdjustment(int32_t minMax)
Set minimum and maximum allowed temperature adjustment.
Definition therm_hygro_meter.cpp:296
int16_t minMaxAllowedHumidityAdjustment
Minimum and maximum allowed humidity adjustment in 0.1 RH.
Definition therm_hygro_meter.h:104
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition therm_hygro_meter.cpp:21
void purgeConfig() override
Removes all configration data related to the element from Storage::Config.
Definition therm_hygro_meter.cpp:108
Definition proto.h:3159