![]() |
BeeeOn Gateway
v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
|
The class communicates with FHEM server. It allows to search HomeMatic devices, gather data from HomeMatic devices and send commands to change state of a device. More...
#include <FHEMClient.h>
Public Types | |
|
typedef Poco::SharedPtr < FHEMClient > | Ptr |
Public Types inherited from BeeeOn::StoppableRunnable | |
|
typedef Poco::SharedPtr < StoppableRunnable > | Ptr |
Public Member Functions | |
| void | setRefreshTime (const Poco::Timespan &time) |
| void | setReceiveTimeout (const Poco::Timespan &timeout) |
| void | setReconnectTime (const Poco::Timespan &time) |
| void | setFHEMAddress (const std::string &address) |
| void | run () override |
| It starts with creation of telnet connection with FHEM server and then it periodicly ask FHEM server about new events. | |
| void | stop () override |
| void | sendRequest (const std::string &request) |
| Sends a request over a telnet connection to FHEM server. | |
| Poco::JSON::Object::Ptr | receive (const Poco::Timespan &timeout) |
| Waiting for a new event according to given timeout. Returns event, if some event is in queue, otherwise waiting for a new event or timeout exception. More... | |
Protected Member Functions | |
| void | initConnection () |
| Creates DialogSocket and connect it to a defined socket address m_fhemAddress. | |
| void | cycle () |
| Retrieves all HomeMatic devices known to FHEM server and processes each device. Processing of device The processing of a device consists of a detection and creation of an event. | |
| Poco::JSON::Object::Ptr | nextEvent () |
| Returns message from queue. If the queue is empty it returns null. | |
| void | retrieveHomeMaticDevices (std::vector< std::string > &devices) |
| Retrieves all HomeMatic devices known to FHEM server. | |
| void | processDevice (const std::string &device) |
| Retrieves information about given device and detects changes connected to this device. If some change is detected then an event is created and is appended to the queue. More... | |
| FHEMDeviceInfo | assembleDeviceInfo (const std::string &device, const Poco::JSON::Object::Ptr internals) const |
| Creates DeviceInfo for a given device and part of message. | |
| void | retrieveChannelsState (Poco::JSON::Object::Ptr internals, std::map< std::string, std::string > &channels) |
| For a given device it retrieves all channels and their states. | |
| std::string | retrieveChannelState (const std::string &channel) |
| Retrieves a state of a given channel. | |
| void | createNewDeviceEvent (const std::string &device, const std::string &model, const std::string &type, const std::string &serialNumber) |
| void | createStatEvent (const std::string &event, const std::string &device) |
| void | createMessageEvent (const std::string &device, const std::string &model, const std::string &type, const std::string &serialNumber, const std::string &rawMsg, const double rssi, const std::map< std::string, std::string > &channels) |
| void | appendEventToQueue (const Poco::JSON::Object::Ptr event) |
| Poco::JSON::Object::Ptr | sendCommand (const std::string &command) |
| Sends a command over telnet connection and returns a response. More... | |
The class communicates with FHEM server. It allows to search HomeMatic devices, gather data from HomeMatic devices and send commands to change state of a device.
|
protected |
Retrieves information about given device and detects changes connected to this device. If some change is detected then an event is created and is appended to the queue.
Events: new_device, message, rcv_cnt, snd_cnt
| Object::Ptr FHEMClient::receive | ( | const Poco::Timespan & | timeout | ) |
Waiting for a new event according to given timeout. Returns event, if some event is in queue, otherwise waiting for a new event or timeout exception.
This method should not be called by multiple threads, received message could be given to only one thread.
Timeout:
|
protected |
Sends a command over telnet connection and returns a response.
| TimeoutException | in case of expiration of receive timeout. |
| SyntaxException | in case of wrong response. |
|
overridevirtual |
Stop the runnable. The call should not block.
Implements BeeeOn::StoppableRunnable.
1.8.5