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,
int *size)
override;
87 void handleAction(
int event,
int action)
override;
89 void printConfig()
const;
93 virtual int readNewValue();
96 void setValue(
int value);
98 bool isAlarmActive()
const;
99 bool isWarningActive()
const;
100 bool isInvalidSensorStateActive()
const;
101 bool isSoundAlarmOn()
const;
111 virtual void setReadIntervalMs(uint32_t timeMs);
115 void setWarningAboveLevel(int8_t warningAboveLevel);
117 int8_t getWarningAboveLevel()
const;
118 bool isWarningAboveLevelSet()
const;
122 void setAlarmAboveLevel(int8_t alarmAboveLevel);
124 int8_t getAlarmAboveLevel()
const;
125 bool isAlarmAboveLevelSet()
const;
129 void setWarningBelowLevel(int8_t warningBelowLevel);
131 int8_t getWarningBelowLevel()
const;
132 bool isWarningBelowLevelSet()
const;
136 void setAlarmBelowLevel(int8_t alarmBelowLevel);
138 int8_t getAlarmBelowLevel()
const;
139 bool isAlarmBelowLevelSet()
const;
141 void setMuteAlarmSoundWithoutAdditionalAuth(
142 bool muteAlarmSoundWithoutAdditionalAuth);
143 bool isMuteAlarmSoundWithoutAdditionalAuth()
const;
154 bool setSensorData(uint8_t channelNumber, uint8_t fillLevel);
186 void setSoundAlarmSupported(
bool soundAlarmSupported);
187 bool isSoundAlarmSupported()
const;
196 void setExternalSoundAlarmOn();
197 void setExternalSoundAlarmOff();
200 void updateConfigField(uint8_t *configField, int8_t value);
201 int8_t getHighestSensorValueAndUpdateState();
202 void setAlarmActive(
bool alarmActive);
203 void setWarningActive(
bool warningActive);
204 void setInvalidSensorStateActive(
bool invalidSensorStateActive);
205 void setSoundAlarmOn(uint8_t level);
219 const int8_t tolerance = 0)
const;
224 enum SensorState getSensorState(
const uint8_t channelNumber)
const;
225 uint32_t lastReadTime = 0;
226 uint32_t readIntervalMs = 1000;
227 int8_t fillLevel = -1;
228 bool soundAlarmSupported =
false;
229 uint8_t soundAlarmActivatedLevel = 0;
230 bool externalSoundAlarm =
false;
231 bool sensorOfflineReported =
false;
233 ContainerConfig config = {};
236static_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:242
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition container.cpp:410
bool isSensorDataUsed() const
Checks if any sensor data is set.
Definition container.cpp:296
int getFillLevelForSensor(uint8_t channelNumber) const
Returns fill level for sensor with given channel number.
Definition container.cpp:287
void setInternalLevelReporting(bool internalLevelReporting)
Sets the internal level reporting flag.
Definition container.cpp:38
bool isExternalSoundAlarmOn() const
Checks if the sound alarm was enabled for external source (other than container itself)
Definition container.cpp:642
bool isInternalLevelReporting() const
Checks if the internal level reporting flag is enabled.
Definition container.cpp:48
bool isAlarmingUsed() const
Checks if any alarm or warning level is set (both above and below)
Definition container.cpp:389
int handleCalcfgFromServer(TSD_DeviceCalCfgRequest *request) override
Handles CALCFG requests from server.
Definition container.cpp:611
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition container.cpp:53
void removeSensorData(uint8_t channelNumber)
Removes sensor data for given channel number.
Definition container.cpp:277
bool checkSensorInvalidState(const int8_t currentFillLevel, const int8_t tolerance=0) const
Checks if sensor is in invalid state.
Definition container.cpp:341
void muteSoundAlarm()
Mutes the sound alarmm by clearing channel value flag, but does not clear soundAlarmActivated flag,...
Definition container.cpp:192
Definition container.h:38
Definition container.h:33