19#ifndef SRC_SUPLA_SENSOR_CONTAINER_H_
20#define SRC_SUPLA_SENSOR_CONTAINER_H_
22#include <supla/channel_element.h>
23#include <supla/action_handler.h>
34 uint8_t fillLevel = 0;
35 uint8_t channelNumber = 255;
39 uint8_t warningAboveLevel = 0;
40 uint8_t alarmAboveLevel = 0;
41 uint8_t warningBelowLevel = 0;
42 uint8_t alarmBelowLevel = 0;
44 uint8_t muteAlarmSoundWithoutAdditionalAuth = 0;
51enum class SensorState {
58class Container :
public ChannelElement,
public ActionHandler {
83 bool local =
false)
override;
84 void fillChannelConfig(
void *channelConfig,
86 uint8_t configType)
override;
89 void handleAction(
int event,
int action)
override;
91 void printConfig()
const;
95 virtual int readNewValue();
98 void setValue(
int value);
100 bool isAlarmActive()
const;
101 bool isWarningActive()
const;
102 bool isInvalidSensorStateActive()
const;
103 bool isSoundAlarmOn()
const;
113 virtual void setReadIntervalMs(uint32_t timeMs);
117 void setWarningAboveLevel(int8_t warningAboveLevel);
119 int8_t getWarningAboveLevel()
const;
120 bool isWarningAboveLevelSet()
const;
124 void setAlarmAboveLevel(int8_t alarmAboveLevel);
126 int8_t getAlarmAboveLevel()
const;
127 bool isAlarmAboveLevelSet()
const;
131 void setWarningBelowLevel(int8_t warningBelowLevel);
133 int8_t getWarningBelowLevel()
const;
134 bool isWarningBelowLevelSet()
const;
138 void setAlarmBelowLevel(int8_t alarmBelowLevel);
140 int8_t getAlarmBelowLevel()
const;
141 bool isAlarmBelowLevelSet()
const;
143 void setMuteAlarmSoundWithoutAdditionalAuth(
144 bool muteAlarmSoundWithoutAdditionalAuth);
145 bool isMuteAlarmSoundWithoutAdditionalAuth()
const;
156 bool setSensorData(uint8_t channelNumber, uint8_t fillLevel);
188 void setSoundAlarmSupported(
bool soundAlarmSupported);
189 bool isSoundAlarmSupported()
const;
198 void setExternalSoundAlarmOn();
199 void setExternalSoundAlarmOff();
202 void updateConfigField(uint8_t *configField, int8_t value);
203 int8_t getHighestSensorValueAndUpdateState();
204 void setAlarmActive(
bool alarmActive);
205 void setWarningActive(
bool warningActive);
206 void setInvalidSensorStateActive(
bool invalidSensorStateActive);
207 void setSoundAlarmOn(uint8_t level);
221 const int8_t tolerance = 0)
const;
226 enum SensorState getSensorState(
const uint8_t channelNumber)
const;
227 uint32_t lastReadTime = 0;
228 uint32_t readIntervalMs = 1000;
229 int8_t fillLevel = -1;
230 bool soundAlarmSupported =
false;
231 uint8_t soundAlarmActivatedLevel = 0;
232 bool externalSoundAlarm =
false;
233 bool sensorOfflineReported =
false;
235 ContainerConfig config = {};
238static_assert(
sizeof(ContainerConfig().sensorData) /
sizeof(SensorData) ==
Definition SuplaDevice.h:93
Definition container_parameters.h:29
bool setSensorData(uint8_t channelNumber, uint8_t fillLevel)
Sets sensor data for given channel number.
Definition container.cpp:244
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition container.cpp:412
bool isSensorDataUsed() const
Checks if any sensor data is set.
Definition container.cpp:298
int getFillLevelForSensor(uint8_t channelNumber) const
Returns fill level for sensor with given channel number.
Definition container.cpp:289
void setInternalLevelReporting(bool internalLevelReporting)
Sets the internal level reporting flag.
Definition container.cpp:40
bool isExternalSoundAlarmOn() const
Checks if the sound alarm was enabled for external source (other than container itself)
Definition container.cpp:649
bool isInternalLevelReporting() const
Checks if the internal level reporting flag is enabled.
Definition container.cpp:50
bool isAlarmingUsed() const
Checks if any alarm or warning level is set (both above and below)
Definition container.cpp:391
int handleCalcfgFromServer(TSD_DeviceCalCfgRequest *request) override
Handles CALCFG requests from server.
Definition container.cpp:618
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition container.cpp:55
void removeSensorData(uint8_t channelNumber)
Removes sensor data for given channel number.
Definition container.cpp:279
bool checkSensorInvalidState(const int8_t currentFillLevel, const int8_t tolerance=0) const
Checks if sensor is in invalid state.
Definition container.cpp:343
void muteSoundAlarm()
Mutes the sound alarmm by clearing channel value flag, but does not clear soundAlarmActivated flag,...
Definition container.cpp:194
Definition container.h:38
Definition container.h:33