Minor changes in PIR usermod.

This commit is contained in:
Blaz Kristan 2021-04-21 20:57:58 +02:00
parent 04aa22b510
commit 90516217e0

View File

@ -257,6 +257,8 @@ public:
uiDomString += "</button>";
infoArr.add(uiDomString); //value
if (m_PIRenabled)
{
//this code adds "u":{"&#x23F2; switch off timer":uiDomString} to the info object
uiDomString = "<i class=\"icons\">&#xe325;</i> switch off timer<span style=\"display:block;padding-left:25px;\">\
after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
@ -296,6 +298,7 @@ after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
infoArr.add("inactive");
}
}
}
/**
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
@ -323,9 +326,9 @@ after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
m_updateConfig = true;
}
if (root[F("pin")] != nullptr)
if (root["pin"] != nullptr)
{
int8_t pin = (int)root[F("pin")];
int8_t pin = (int)root["pin"];
// check if pin is OK
if (pin != PIRsensorPin && pin>=0 && pinManager.allocatePin(pin,false)) {
// deallocate old pin
@ -379,8 +382,8 @@ after <input type=\"number\" min=\"1\" max=\"720\" value=\"";
void readFromConfig(JsonObject &root)
{
JsonObject top = root[F("PIRsensorSwitch")];
if (!top.isNull() && top[F("pin")] != nullptr) {
PIRsensorPin = (int)top[F("pin")];
if (!top.isNull() && top["pin"] != nullptr) {
PIRsensorPin = (int)top["pin"];
}
m_PIRenabled = (top[F("PIRenabled")] != nullptr ? top[F("PIRenabled")] : true);
m_switchOffDelay = top[F("PIRoffSec")] | m_switchOffDelay;