Skip to content

Commit

Permalink
Introduces standardized key for govee binary moisture sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
kcpants committed Sep 18, 2023
1 parent 582af76 commit a9bc818
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/devices/govee.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,21 @@ static int govee_h5054_decode(r_device *decoder, bitbuffer_t *bitbuffer)
decoder_logf(decoder, 1, __func__, "crc_sum=%04x", crc_sum);

char const *event_str;
int wet = -1;
int leak_num = -1;
int battery = -1;
switch (event) {
case 0x0:
event_str = "Button Press";
wet = 0;
break;
case 0x1:
event_str = "Battery Report";
battery = event_data;
break;
case 0x2:
event_str = "Water Leak";
wet = 1;
leak_num = event_data;
break;
default:
Expand All @@ -378,6 +381,7 @@ static int govee_h5054_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"battery_ok", "Battery level", DATA_COND, battery >= 0, DATA_DOUBLE, battery_level,
"battery_mV", "Battery", DATA_COND, battery >= 0, DATA_FORMAT, "%d mV", DATA_INT, battery_mv,
"event", "", DATA_STRING, event_str,
"wet", "", DATA_COND, wet >= 0, DATA_INT, wet,
"leak_num", "Leak Num", DATA_COND, leak_num >= 0, DATA_INT, leak_num,
"code", "Raw Code", DATA_STRING, code_str,
"mic", "Integrity", DATA_STRING, "CRC",
Expand All @@ -389,6 +393,18 @@ static int govee_h5054_decode(r_device *decoder, bitbuffer_t *bitbuffer)
return 1;
}

static char const *const output_fields_5054[] = {
"model",
"id",
"battery_ok",
"battery_mV",
"event",
"wet",
"code",
"mic",
NULL,
};

r_device const govee_h5054 = {
.name = "Govee Water Leak Detector H5054",
.modulation = OOK_PULSE_PWM,
Expand All @@ -397,5 +413,5 @@ r_device const govee_h5054 = {
.gap_limit = 900, // Maximum gap size before new row of bits [us]
.reset_limit = 9000, // Maximum gap size before End Of Message [us]
.decode_fn = &govee_h5054_decode,
.fields = output_fields,
.fields = output_fields_5054,
};

0 comments on commit a9bc818

Please sign in to comment.