Skip to content

Commit 23fb57b

Browse files
committed
Merge pull request #482 from gaudryc/send_device_options_on_MQTT_device_info_request
Fix missing Selector switch levels in MQTT device info response by returning all device options (#459)
2 parents c5498f0 + aa2c28c commit 23fb57b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

History.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Version 2.4xxx
7777
- Fixed: Refactor the http::server::reply structure and add some helper methods.
7878
- Fixed: Fix filename attachment when saving ZWave configuration file (use filename instead of path).
7979
- Fixed: Fix Security devices edit form by hiding Selector switch options (#473).
80+
- Fixed: Fix missing Selector switch levels in MQTT device info response by returning all device options (#459)
8081
- Updated: OpenZWave, configuration files
8182

8283
Version 2.3530 (November 1th 2015)

hardware/MQTT.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ void MQTT::SendDeviceInfo(const int m_HwdID, const unsigned long long DeviceRowI
493493
if (!m_IsConnected)
494494
return;
495495
std::vector<std::vector<std::string> > result;
496-
result = m_sql.safe_query("SELECT DeviceID, Unit, Name, [Type], SubType, nValue, sValue, SwitchType, SignalLevel, BatteryLevel FROM DeviceStatus WHERE (HardwareID==%d) AND (ID==%llu)", m_HwdID, DeviceRowIdx);
496+
result = m_sql.safe_query("SELECT DeviceID, Unit, Name, [Type], SubType, nValue, sValue, SwitchType, SignalLevel, BatteryLevel, Options FROM DeviceStatus WHERE (HardwareID==%d) AND (ID==%llu)", m_HwdID, DeviceRowIdx);
497497
if (result.size() > 0)
498498
{
499499
std::vector<std::string> sd = result[0];
@@ -507,6 +507,7 @@ void MQTT::SendDeviceInfo(const int m_HwdID, const unsigned long long DeviceRowI
507507
_eSwitchType switchType = (_eSwitchType)atoi(sd[7].c_str());
508508
int RSSI = atoi(sd[8].c_str());
509509
int BatteryLevel = atoi(sd[9].c_str());
510+
std::map<std::string, std::string> options = m_sql.BuildDeviceOptions(sd[10]);
510511

511512
Json::Value root;
512513

@@ -520,6 +521,14 @@ void MQTT::SendDeviceInfo(const int m_HwdID, const unsigned long long DeviceRowI
520521
if (IsLightOrSwitch(dType, dSubType) == true) {
521522
root["switchType"] = Switch_Type_Desc(switchType);
522523
}
524+
// Add device options
525+
std::map<std::string, std::string>::const_iterator itt;
526+
for (itt = options.begin(); itt != options.end(); ++itt)
527+
{
528+
std::string optionName = itt->first.c_str();
529+
std::string optionValue = itt->second.c_str();
530+
root[optionName] = optionValue;
531+
}
523532

524533
root["RSSI"] = RSSI;
525534
root["Battery"] = BatteryLevel;

0 commit comments

Comments
 (0)