diff --git a/docs/use/actuators.md b/docs/use/actuators.md index 4c081cc..8ec91c5 100644 --- a/docs/use/actuators.md +++ b/docs/use/actuators.md @@ -19,6 +19,20 @@ OFF command: ON command: `mosquitto_pub -t home/OpenMQTTGateway_MEGA/commands/MQTTtoONOFF -m '{"gpio":15,"cmd":1}'` +Since v0.9.9, you could ask for a short activation, the PIN will change state for only half a second. + +For example you could use it with a relay board to activate an existing step relay. So your home automation act as a supplementary switch and do not interfere with the existing switch in your house. + +It's available only with [json receiving](../upload/pio.md#api): + +Goes ON for half a second, then back to OFF: +`mosquitto_pub -t home/OpenMQTTGateway_MEGA/commands/MQTTtoONOFF -m '{"gpio":15,"cmd":"high_pulse"}'` + +Goes OFF for half a second, then back to ON: +`mosquitto_pub -t home/OpenMQTTGateway_MEGA/commands/MQTTtoONOFF -m '{"gpio":15,"cmd":"low_pulse}"'` + +Be aware that outputs are OFF by default when the board first start. + ## FASTLED ### The FASTLED module support 2 different operation modes 1. control one specific RGB LED diff --git a/main/ZactuatorONOFF.ino b/main/ZactuatorONOFF.ino index b4c32ea..4f87efe 100644 --- a/main/ZactuatorONOFF.ino +++ b/main/ZactuatorONOFF.ino @@ -44,7 +44,23 @@ void MQTTtoONOFF(char* topicOri, JsonObject& ONOFFdata) { // we acknowledge the sending by publishing the value to an acknowledgement topic pub(subjectGTWONOFFtoMQTT, ONOFFdata); } else { - Log.error(F("MQTTtoONOFF failed json read" CR)); + if (ONOFFdata["cmd"] == "high_pulse") { + Log.notice(F("MQTTtoONOFF high_pulse ok" CR)); + Log.notice(F("GPIO number: %d" CR), gpio); + pinMode(gpio, OUTPUT); + digitalWrite(gpio, HIGH); + delay(500); + digitalWrite(gpio, LOW); + } else if (ONOFFdata["cmd"] == "low_pulse") { + Log.notice(F("MQTTtoONOFF low_pulse ok" CR)); + Log.notice(F("GPIO number: %d" CR), gpio); + pinMode(gpio, OUTPUT); + digitalWrite(gpio, LOW); + delay(500); + digitalWrite(gpio, HIGH); + } else { + Log.error(F("MQTTtoONOFF failed json read" CR)); + } } } } diff --git a/main/config_ONOFF.h b/main/config_ONOFF.h index 8fa22ef..0fcb3c2 100644 --- a/main/config_ONOFF.h +++ b/main/config_ONOFF.h @@ -37,7 +37,7 @@ extern void MQTTtoONOFF(char* topicOri, JsonObject& RFdata); #define ONKey "setON" #define OFFKey "setOFF" #ifndef ACTUATOR_ON -# define ACTUATOR_ON LOW // 0 or 1, set to the output level of the gpio pin to turn the actuator on. +# define ACTUATOR_ON LOW // LOW or HIGH, set to the output level of the gpio pin to turn the actuator on. #endif #ifndef ACTUATOR_ONOFF_DEFAULT # define ACTUATOR_ONOFF_DEFAULT !ACTUATOR_ON // ACTUATOR_ON or !ACTUATOR_ON, set to the state desired on reset.