-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHumidityPlantAlerter.cpp
More file actions
40 lines (36 loc) · 1.11 KB
/
HumidityPlantAlerter.cpp
File metadata and controls
40 lines (36 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "HumidityPlantAlerter.h"
#include "SmartThingsManager.h"
#include "Config.h"
#include "LaMetricManager.h"
namespace SA
{
HumidityPlantAlerter::HumidityPlantAlerter() = default;
HumidityPlantAlerter::~HumidityPlantAlerter() = default;
void HumidityPlantAlerter::Update()
{
if (const auto result = SmartThingsManager::Get().GetDeviceValue<float>(Config::c_humidityPlantDevice, "relativeHumidityMeasurement/humidity/value", false))
{
constexpr float humidityThreshold = 5.0f;
if (*result < humidityThreshold)
{
LaMetricManager::Frame frame;
frame.m_text = "PODLEJ";
frame.m_icon = 72618;
frame.m_duration = 3100;
if (m_frameHandle)
{
LaMetricManager::Get().UpdateFrame(*m_frameHandle, std::move(frame));
}
else
{
m_frameHandle = std::make_unique<LaMetricFrameRequestHandle>(LaMetricManager::Get().AddFrame(std::move(frame)));
}
}
else if (m_frameHandle)
{
LaMetricManager::Get().RemoveFrame(*m_frameHandle);
m_frameHandle = nullptr;
}
}
}
}