mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-09 14:11:39 +02:00
Add MQTT parts (publish groups)
This commit is contained in:
parent
b8a1bb126f
commit
73b3542c16
1 changed files with 15 additions and 3 deletions
|
@ -504,11 +504,15 @@ class ZeroExport {
|
|||
if (topic.indexOf("groups") != -1) {
|
||||
String i = topic.substring(topic.length() - 10, topic.length() - 8);
|
||||
uint id = i.toInt();
|
||||
}
|
||||
|
||||
mCfg->groups[id].enabled = (bool)obj["val"];
|
||||
}
|
||||
else
|
||||
{
|
||||
mCfg->enabled = (bool)obj["val"];
|
||||
mLog["zero_enable"] = mCfg->enabled;
|
||||
}
|
||||
}
|
||||
|
||||
mLog["Msg"] = obj;
|
||||
sendLog();
|
||||
|
@ -1499,15 +1503,23 @@ class ZeroExport {
|
|||
JsonObject obj = doc.to<JsonObject>();
|
||||
|
||||
*doLog = true;
|
||||
String gr;
|
||||
|
||||
// Init
|
||||
if (!mIsSubscribed) {
|
||||
mIsSubscribed = true;
|
||||
mMqtt->publish("zero/set/enabled", ((mCfg->enabled) ? dict[STR_TRUE] : dict[STR_FALSE]), false);
|
||||
mMqtt->subscribe("zero/set/enabled", QOS_2);
|
||||
|
||||
gr = "zero/set/groups/" + String(group) + "/enabled";
|
||||
mMqtt->publish(gr.c_str(), ((mCfg->groups[group].enabled) ? dict[STR_TRUE] : dict[STR_FALSE]) , false);
|
||||
mMqtt->subscribe(gr.c_str(), QOS_2);
|
||||
}
|
||||
|
||||
mMqtt->publish("zero/state/enabled", ((mCfg->enabled) ? dict[STR_TRUE] : dict[STR_FALSE]), false);
|
||||
gr = "zero/state/groups/" + String(group) + "/enabled";
|
||||
mMqtt->publish(gr.c_str(), ((mCfg->groups[group].enabled) ? dict[STR_TRUE] : dict[STR_FALSE]) , false);
|
||||
|
||||
|
||||
// if (mCfg->groups[group].publishPower) {
|
||||
// mCfg->groups[group].publishPower = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue