BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
SonoffDevice.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 
6 #include <Poco/SharedPtr.h>
7 #include <Poco/Timestamp.h>
8 
9 #include "model/DeviceID.h"
10 #include "model/ModuleType.h"
11 #include "model/RefreshTime.h"
12 #include "model/SensorData.h"
13 #include "net/MqttMessage.h"
14 #include "util/Loggable.h"
15 
16 namespace BeeeOn {
17 
21 class SonoffDevice : protected Loggable {
22 public:
23  typedef Poco::SharedPtr<SonoffDevice> Ptr;
24 
25  static const std::string VENDOR_NAME;
26 
28  const DeviceID& id,
29  const RefreshTime &refresh,
30  const std::string& productName,
31  const std::list<ModuleType>& moduleTypes);
32  virtual ~SonoffDevice();
33 
34  DeviceID id() const;
35  RefreshTime refreshTime() const;
36  std::list<ModuleType> moduleTypes() const;
37  std::string vendor() const;
38  std::string productName() const;
39  Poco::Timestamp lastSeen() const;
40 
44  virtual SensorData parseMessage(const MqttMessage& message) = 0;
45 
46 protected:
47  const DeviceID m_deviceId;
48  RefreshTime m_refresh;
49  std::string m_productName;
50  std::list<ModuleType> m_moduleTypes;
51  Poco::Timestamp m_lastSeen;
52 };
53 
54 }
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
Definition: SensorData.h:20
Abstract class representing generic Sonoff device.
Definition: SonoffDevice.h:21
Definition: MqttMessage.h:7
Definition: Loggable.h:19
virtual SensorData parseMessage(const MqttMessage &message)=0
Transforms received MQTT message to SensorData.
Definition: DeviceID.h:17