Skip to content

Commit a09fda5

Browse files
committed
configurable homekey color
1 parent a089462 commit a09fda5

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

data/misc.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,27 @@ <h2 style="text-align: center;">Device Configuration</h2>
2323
<label for="hk-always-lock">Always Lock on HK Auth</label>
2424
<input type='hidden' name='hk-always-lock' value='0'>
2525
<input type="checkbox" name="hk-always-lock" id="hk-always-lock" value="1">
26-
26+
27+
<fieldset>
28+
<legend>HomeKey Card Finish:</legend>
29+
<div>
30+
<label for="hk-tan">Tan</label>
31+
<input type="radio" id="hk-finish-0" name="hk-hwfinish" value="0" />
32+
</div>
33+
<div>
34+
<label for="hk-gold">Gold</label>
35+
<input type="radio" id="hk-finish-1" name="hk-hwfinish" value="1" />
36+
</div>
37+
<div>
38+
<label for="hk-silver">Silver</label>
39+
<input type="radio" id="hk-finish-2" name="hk-hwfinish" value="2" />
40+
</div>
41+
<div>
42+
<label for="hk-black">Black</label>
43+
<input type="radio" id="hk-finish-3" name="hk-hwfinish" value="3" />
44+
</div>
45+
</fieldset>
46+
2747
<p><b>- HomeKey Events</b></p>
2848

2949
<label for="nfc-s-pin">Auth Success/Failure GPIO Pin (NeoPixel)</label>
@@ -79,6 +99,8 @@ <h2 style="text-align: center;">Device Configuration</h2>
7999
let gpioActionEn = "%GPIOAEN%" == true;
80100
let gpioActionLock = "%GPIOALOCK%" == true;
81101
let gpioActionUnlock = "%GPIOAUNLOCK%" == true;
102+
let hwfinish = "%HWFINISH%";
103+
document.getElementById(`hk-finish-${hwfinish}`).setAttribute("checked", "");
82104
if (nfcSuccessHL) {
83105
document.getElementById("nfc-s-hl").setAttribute("checked", "");
84106
}

src/main.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace espConfig
6767
{
6868
std::string deviceName = DEVICE_NAME;
6969
std::string otaPasswd = OTA_PWD;
70-
std::string hk_key_color = hk_color_vals[HOMEKEY_COLOR];
70+
uint8_t hk_key_color = HOMEKEY_COLOR;
7171
std::string setupCode = SETUP_CODE;
7272
bool lockAlwaysUnlock = HOMEKEY_ALWAYS_UNLOCK;
7373
bool lockAlwaysLock = HOMEKEY_ALWAYS_LOCK;
@@ -672,6 +672,9 @@ String miscHtmlProcess(const String& var) {
672672
else if (var == "GPIOAUNLOCK") {
673673
return String(espConfig::miscConfig.gpioActionUnlockState);
674674
}
675+
else if (var == "HWFINISH") {
676+
return String(espConfig::miscConfig.hk_key_color);
677+
}
675678
return String();
676679
}
677680

@@ -946,6 +949,9 @@ void setupWeb() {
946949
else if (!strcmp(p->name().c_str(), "gpio-a-unlock")) {
947950
espConfig::miscConfig.gpioActionUnlockState = p->value().toInt();
948951
}
952+
else if (!strcmp(p->name().c_str(), "hk-hwfinish")) {
953+
espConfig::miscConfig.hk_key_color = p->value().toInt();
954+
}
949955
}
950956
try {
951957
std::string strNvs;
@@ -1292,7 +1298,7 @@ void setup() {
12921298
serialNumber.append(macStr);
12931299
new Characteristic::SerialNumber(serialNumber.c_str());
12941300
new Characteristic::FirmwareRevision(app_version.c_str());
1295-
std::vector<uint8_t> decB64 = utils::decodeB64(espConfig::miscConfig.hk_key_color.c_str());
1301+
std::vector<uint8_t> decB64 = utils::decodeB64(hk_color_vals[HK_COLOR(espConfig::miscConfig.hk_key_color)]);
12961302
TLV8 hwfinish(NULL, 0);
12971303
hwfinish.unpack(decB64.data(), decB64.size());
12981304
new Characteristic::HardwareFinish(hwfinish);
@@ -1304,7 +1310,7 @@ void setup() {
13041310
new Characteristic::Version();
13051311
homeSpan.setControllerCallback(pairCallback);
13061312
homeSpan.setWifiCallback(wifiCallback);
1307-
1313+
13081314
if (espConfig::miscConfig.nfcNeopixelPin && espConfig::miscConfig.nfcNeopixelPin != 255) {
13091315
pixels.setPin(espConfig::miscConfig.nfcNeopixelPin);
13101316
pixels.begin();

0 commit comments

Comments
 (0)