change brightness and temperature immediately if light is off

This commit is contained in:
interfisch 2020-10-12 22:42:33 +02:00
parent c73f91c2e7
commit 9c845af231
1 changed files with 11 additions and 1 deletions

View File

@ -470,6 +470,13 @@ bool brightnessHandler(const HomieRange& range, const String& value) {
//lightNode.setProperty("brightness").send(value); //done in main loop
if (value.toFloat() >= BRIGHTNESS_MIN && value.toFloat() <= BRIGHTNESS_MAX) {
set_brightness=value.toFloat();
if (!enable) { //if light was off set final brightness immediately (fade on is done by enable fade)
brightness=set_brightness;
}
//enable light when brightness set
enable=true;
flag_updatePWM=true; //force update
}else {
Homie.getLogger() << "Value outside range" << endl;
return false;
@ -513,6 +520,9 @@ bool temperatureHandler(const HomieRange& range, const String& value) {
if (value.toFloat() >= TEMPERATURE_MIN && value.toFloat() <= TEMPERATURE_MAX) {
set_temperature=value.toFloat();
if (!enable) { //if light is off set final temperature immediately
temperature=set_temperature;
}
}else {
Homie.getLogger() << "Value outside range" << endl;
return false;
@ -545,7 +555,7 @@ bool enableHandler(const HomieRange& range, const String& value) { //change on o
Homie.getLogger() << "Value outside range" << endl;
return false;
}
flag_updatePWM=true; //force update
return true;