change brightness and temperature immediately if light is off
This commit is contained in:
parent
c73f91c2e7
commit
9c845af231
10
src/main.cpp
10
src/main.cpp
|
@ -470,6 +470,13 @@ bool brightnessHandler(const HomieRange& range, const String& value) {
|
||||||
//lightNode.setProperty("brightness").send(value); //done in main loop
|
//lightNode.setProperty("brightness").send(value); //done in main loop
|
||||||
if (value.toFloat() >= BRIGHTNESS_MIN && value.toFloat() <= BRIGHTNESS_MAX) {
|
if (value.toFloat() >= BRIGHTNESS_MIN && value.toFloat() <= BRIGHTNESS_MAX) {
|
||||||
set_brightness=value.toFloat();
|
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 {
|
}else {
|
||||||
Homie.getLogger() << "Value outside range" << endl;
|
Homie.getLogger() << "Value outside range" << endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -513,6 +520,9 @@ bool temperatureHandler(const HomieRange& range, const String& value) {
|
||||||
|
|
||||||
if (value.toFloat() >= TEMPERATURE_MIN && value.toFloat() <= TEMPERATURE_MAX) {
|
if (value.toFloat() >= TEMPERATURE_MIN && value.toFloat() <= TEMPERATURE_MAX) {
|
||||||
set_temperature=value.toFloat();
|
set_temperature=value.toFloat();
|
||||||
|
if (!enable) { //if light is off set final temperature immediately
|
||||||
|
temperature=set_temperature;
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
Homie.getLogger() << "Value outside range" << endl;
|
Homie.getLogger() << "Value outside range" << endl;
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue