Enable to keep actuator on off state in case of restart (#1334)
and publish status as a json when triggering actuator on off through a button
This commit is contained in:
1 parent
66588149a8
commit
c58e765253
3 files changed
+15
-6
No files matched your search
+12
-1
@@ -30,6 +30,13 @@
|
||||
|
||||
#ifdef ZactuatorONOFF
|
||||
|
||||
void setupONOFF() {
|
||||
pinMode(ACTUATOR_ONOFF_GPIO, OUTPUT);
|
||||
# ifdef ACTUATOR_ONOFF_DEFAULT
|
||||
digitalWrite(ACTUATOR_ONOFF_GPIO, ACTUATOR_ONOFF_DEFAULT);
|
||||
# endif
|
||||
}
|
||||
|
||||
# if jsonReceiving
|
||||
void MQTTtoONOFF(char* topicOri, JsonObject& ONOFFdata) {
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoONOFF)) {
|
||||
@@ -104,7 +111,11 @@ void ActuatorButtonTrigger() {
|
||||
}
|
||||
Log.trace(F("Actuator triggered %s by button" CR), level_string);
|
||||
digitalWrite(ACTUATOR_ONOFF_GPIO, level);
|
||||
pub(subjectGTWONOFFtoMQTT, level_string);
|
||||
// Send the state of the switch to the broker so as to update the status
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject ONOFFdata = jsonBuffer.to<JsonObject>();
|
||||
ONOFFdata["cmd"] = (int)level;
|
||||
pub(subjectGTWONOFFtoMQTT, ONOFFdata);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user