diff --git a/sensors/SensorDigitalOutput.h b/sensors/SensorDigitalOutput.h index 7f54f75..fbf3ede 100644 --- a/sensors/SensorDigitalOutput.h +++ b/sensors/SensorDigitalOutput.h @@ -111,7 +111,9 @@ class SensorDigitalOutput: public Sensor { void onSetup() { // do not average the value children.get()->setValueProcessing(NONE); - // setup the pin + // First, set pin status. This will effect only the pullup at first + setStatus(OFF); + // Now, setup the pin mode pinMode(_pin, OUTPUT); // setup the off pin if needed if (_pin_off > 0) pinMode(_pin_off, OUTPUT); @@ -121,8 +123,7 @@ class SensorDigitalOutput: public Sensor { // keep track of the value in EEPROM so to restore it upon a reboot children.get()->setPersistValue(true); #else - // turn the output off by default - setStatus(OFF); + #endif }; diff --git a/sensors/SensorRelay.h b/sensors/SensorRelay.h index 0e0db27..1b447f5 100644 --- a/sensors/SensorRelay.h +++ b/sensors/SensorRelay.h @@ -27,8 +27,9 @@ SensorRelay class SensorRelay: public SensorDigitalOutput { public: - SensorRelay(int8_t pin, uint8_t child_id = 0): SensorDigitalOutput(pin, child_id) { + SensorRelay(int8_t pin, bool inverted = false, uint8_t child_id = 0): SensorDigitalOutput(pin, child_id) { _name = "RELAY"; + setInvertValueToWrite(inverted); children.get()->setPresentation(S_BINARY); children.get()->setType(V_STATUS); children.get()->setDescription(_name);