4#ifndef SRC_SUPLA_SENSOR_CONTAINER_H_
5#define SRC_SUPLA_SENSOR_CONTAINER_H_
7#include <supla/channel_element.h>
8#include <supla/action_handler.h>
12class ContainerParameters;
19 uint8_t fillLevel = 0;
20 uint8_t channelNumber = 255;
24 uint8_t warningAboveLevel = 0;
25 uint8_t alarmAboveLevel = 0;
26 uint8_t warningBelowLevel = 0;
27 uint8_t alarmBelowLevel = 0;
29 uint8_t muteAlarmSoundWithoutAdditionalAuth = 0;
36enum class SensorState {
68 bool local =
false)
override;
69 void fillChannelConfig(
void *channelConfig,
71 uint8_t configType)
override;
74 void handleAction(
int event,
int action)
override;
76 void printConfig()
const;
80 virtual int readNewValue();
83 void setValue(
int value);
85 bool isAlarmActive()
const;
86 bool isWarningActive()
const;
87 bool isInvalidSensorStateActive()
const;
88 bool isSoundAlarmOn()
const;
98 virtual void setReadIntervalMs(uint32_t timeMs);
102 void setWarningAboveLevel(int8_t warningAboveLevel);
104 int8_t getWarningAboveLevel()
const;
105 bool isWarningAboveLevelSet()
const;
109 void setAlarmAboveLevel(int8_t alarmAboveLevel);
111 int8_t getAlarmAboveLevel()
const;
112 bool isAlarmAboveLevelSet()
const;
116 void setWarningBelowLevel(int8_t warningBelowLevel);
118 int8_t getWarningBelowLevel()
const;
119 bool isWarningBelowLevelSet()
const;
123 void setAlarmBelowLevel(int8_t alarmBelowLevel);
125 int8_t getAlarmBelowLevel()
const;
126 bool isAlarmBelowLevelSet()
const;
128 void setMuteAlarmSoundWithoutAdditionalAuth(
129 bool muteAlarmSoundWithoutAdditionalAuth);
130 bool isMuteAlarmSoundWithoutAdditionalAuth()
const;
141 bool setSensorData(uint8_t channelNumber, uint8_t fillLevel);
173 void setSoundAlarmSupported(
bool soundAlarmSupported);
174 bool isSoundAlarmSupported()
const;
183 void setExternalSoundAlarmOn();
184 void setExternalSoundAlarmOff();
187 void updateConfigField(uint8_t *configField, int8_t value);
188 int8_t getHighestSensorValueAndUpdateState();
189 void setAlarmActive(
bool alarmActive);
190 void setWarningActive(
bool warningActive);
191 void setInvalidSensorStateActive(
bool invalidSensorStateActive);
192 void setSoundAlarmOn(uint8_t level);
206 const int8_t tolerance = 0)
const;
211 enum SensorState getSensorState(
const uint8_t channelNumber)
const;
212 uint32_t lastReadTime = 0;
213 uint32_t readIntervalMs = 1000;
214 int8_t fillLevel = -1;
215 bool soundAlarmSupported =
false;
216 uint8_t soundAlarmActivatedLevel = 0;
217 bool externalSoundAlarm =
false;
218 bool sensorOfflineReported =
false;
Definition SuplaDevice.h:167
Definition action_handler.h:8
Definition channel_element.h:15
Definition container_parameters.h:14
Definition container.h:43
bool setSensorData(uint8_t channelNumber, uint8_t fillLevel)
Sets sensor data for given channel number.
Definition container.cpp:233
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition container.cpp:401
bool isSensorDataUsed() const
Checks if any sensor data is set.
Definition container.cpp:287
int getFillLevelForSensor(uint8_t channelNumber) const
Returns fill level for sensor with given channel number.
Definition container.cpp:278
void setInternalLevelReporting(bool internalLevelReporting)
Sets the internal level reporting flag.
Definition container.cpp:26
bool isExternalSoundAlarmOn() const
Checks if the sound alarm was enabled for external source (other than container itself)
Definition container.cpp:638
bool isInternalLevelReporting() const
Checks if the internal level reporting flag is enabled.
Definition container.cpp:36
bool isAlarmingUsed() const
Checks if any alarm or warning level is set (both above and below)
Definition container.cpp:380
int handleCalcfgFromServer(TSD_DeviceCalCfgRequest *request) override
Handles CALCFG requests from server.
Definition container.cpp:607
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition container.cpp:41
void removeSensorData(uint8_t channelNumber)
Removes sensor data for given channel number.
Definition container.cpp:268
bool checkSensorInvalidState(const int8_t currentFillLevel, const int8_t tolerance=0) const
Checks if sensor is in invalid state.
Definition container.cpp:332
void muteSoundAlarm()
Mutes the sound alarmm by clearing channel value flag, but does not clear soundAlarmActivated flag,...
Definition container.cpp:183
Definition container.h:23
Definition container.h:18