Pump OFF as only one string

This commit is contained in:
Ollo 2020-10-20 21:31:39 +02:00
commit c6acc467e2
2 changed files with 9 additions and 34 deletions

View File

@ -13,22 +13,8 @@ platform = espressif32
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
framework = arduino framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
board_build.partitions = huge_app.csv
; the latest development brankitchen-lightch (convention V3.0.x) ; the latest development brankitchen-lightch (convention V3.0.x)
lib_deps = ArduinoJson@6.16.1 lib_deps = ArduinoJson@6.16.1
https://github.com/homieiot/homie-esp8266.git#v3.0 https://github.com/homieiot/homie-esp8266.git#v3.0
OneWire OneWire
[env:esp32doitThinkpadDock]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
board_build.partitions = huge_app.csv
; the latest development brankitchen-lightch (convention V3.0.x)
lib_deps = ArduinoJson@6.16.1
https://github.com/homieiot/homie-esp8266.git#v3.0
OneWire
upload_port = /dev/ttyUSB1

View File

@ -311,15 +311,16 @@ void readSensors() {
//Homie.getMqttClient().disconnect(); //Homie.getMqttClient().disconnect();
void onHomieEvent(const HomieEvent& event) { void onHomieEvent(const HomieEvent& event) {
const String OFF = String("OFF");
switch(event.type) { switch(event.type) {
case HomieEventType::MQTT_READY: case HomieEventType::MQTT_READY:
plant0.setProperty("switch").send(String("OFF")); plant0.setProperty("switch").send(OFF);
plant1.setProperty("switch").send(String("OFF")); plant1.setProperty("switch").send(OFF);
plant2.setProperty("switch").send(String("OFF")); plant2.setProperty("switch").send(OFF);
plant3.setProperty("switch").send(String("OFF")); plant3.setProperty("switch").send(OFF);
plant4.setProperty("switch").send(String("OFF")); plant4.setProperty("switch").send(OFF);
plant5.setProperty("switch").send(String("OFF")); plant5.setProperty("switch").send(OFF);
plant6.setProperty("switch").send(String("OFF")); plant6.setProperty("switch").send(OFF);
//wait for rtc sync? //wait for rtc sync?
rtcDeepSleepTime = deepSleepTime.get(); rtcDeepSleepTime = deepSleepTime.get();
@ -468,7 +469,6 @@ void homieLoop(){
void systemInit(){ void systemInit(){
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
Serial.println("1");
Homie_setFirmware("PlantControl", FIRMWARE_VERSION); Homie_setFirmware("PlantControl", FIRMWARE_VERSION);
@ -476,24 +476,15 @@ void systemInit(){
deepSleepTime.setDefaultValue(300000); /* 5 minutes in milliseconds */ deepSleepTime.setDefaultValue(300000); /* 5 minutes in milliseconds */
deepSleepNightTime.setDefaultValue(0); deepSleepNightTime.setDefaultValue(0);
wateringDeepSleep.setDefaultValue(60000); /* 1 minute in milliseconds */ wateringDeepSleep.setDefaultValue(60000); /* 1 minute in milliseconds */
Serial.println("2");
waterLevelMax.setDefaultValue(1000); /* 100cm in mm */ waterLevelMax.setDefaultValue(1000); /* 100cm in mm */
waterLevelMin.setDefaultValue(50); /* 5cm in mm */ waterLevelMin.setDefaultValue(50); /* 5cm in mm */
waterLevelWarn.setDefaultValue(500); /* 50cm in mm */ waterLevelWarn.setDefaultValue(500); /* 50cm in mm */
waterLevelVol.setDefaultValue(5000); /* 5l in ml */ waterLevelVol.setDefaultValue(5000); /* 5l in ml */
Serial.println("4");
Homie.setLoopFunction(homieLoop); Homie.setLoopFunction(homieLoop);
Serial.println("5");
Homie.setup(); Homie.setup();
Serial.println("6");
Serial.println("3");
mConfigured = Homie.isConfigured(); mConfigured = Homie.isConfigured();
Serial.println("3b");
if (mConfigured) { if (mConfigured) {
// Advertise topics // Advertise topics
plant1.advertise("switch").setName("Pump 1") plant1.advertise("switch").setName("Pump 1")
@ -554,10 +545,8 @@ Serial.println("2");
.setDatatype("number") .setDatatype("number")
.setUnit("V"); .setUnit("V");
sensorWater.advertise("remaining").setDatatype("number").setUnit("%"); sensorWater.advertise("remaining").setDatatype("number").setUnit("%");
// Mode 3
stayAlive.advertise("alive").setName("Alive").setDatatype("number").settable(aliveHandler);
} }
stayAlive.advertise("alive").setName("Alive").setDatatype("number").settable(aliveHandler);
} }