Skip to content

Commit

Permalink
Merge pull request Aircoookie#2851 from albarlow/BH1750-Enabled-Bugfix
Browse files Browse the repository at this point in the history
Fix Enabled Toggle on BH1750
  • Loading branch information
blazoncek authored Oct 24, 2022
2 parents 3d502a4 + 7288e5a commit 69a111e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions usermods/BH1750_v2/usermod_bh1750.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Usermod_BH1750 : public Usermod
bool getLuminanceComplete = false;

// flag set at startup
bool disabled = false;
bool enabled = true;

// strings to reduce flash memory usage (used more than twice)
static const char _name[];
Expand Down Expand Up @@ -133,7 +133,7 @@ class Usermod_BH1750 : public Usermod

void loop()
{
if (disabled || strip.isUpdating())
if ((!enabled) || strip.isUpdating())
return;

unsigned long now = millis();
Expand Down Expand Up @@ -205,7 +205,7 @@ class Usermod_BH1750 : public Usermod
{
// we add JSON object.
JsonObject top = root.createNestedObject(FPSTR(_name)); // usermodname
top[FPSTR(_enabled)] = !disabled;
top[FPSTR(_enabled)] = enabled;
top[FPSTR(_maxReadInterval)] = maxReadingInterval;
top[FPSTR(_minReadInterval)] = minReadingInterval;
top[FPSTR(_HomeAssistantDiscovery)] = HomeAssistantDiscovery;
Expand Down Expand Up @@ -233,7 +233,7 @@ class Usermod_BH1750 : public Usermod
}
bool configComplete = !top.isNull();

configComplete &= getJsonValue(top[FPSTR(_enabled)], disabled, false);
configComplete &= getJsonValue(top[FPSTR(_enabled)], enabled, false);
configComplete &= getJsonValue(top[FPSTR(_maxReadInterval)], maxReadingInterval, 10000); //ms
configComplete &= getJsonValue(top[FPSTR(_minReadInterval)], minReadingInterval, 500); //ms
configComplete &= getJsonValue(top[FPSTR(_HomeAssistantDiscovery)], HomeAssistantDiscovery, false);
Expand Down

0 comments on commit 69a111e

Please sign in to comment.