Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change old battery keys to battery_ok #1737

Merged
merged 1 commit into from
Jun 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions examples/rtl_433_collectd_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ def rtl_433_probe():
attributes = {}
temperatures = {}

if data["battery"] == "OK":
attributes["battery"] = 1.0
else:
attributes["battery"] = 0.0
attributes["battery"] = data["battery_ok"]

attributes["humidity"] = data["humidity"]

Expand Down
7 changes: 2 additions & 5 deletions examples/rtl_433_graphite_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,8 @@ def rtl_433_probe():
label += ".ID" + str(data["id"])
path = GRAPHITE_PREFIX + label

if "battery" in data:
if data["battery"] == "OK":
graphite.push(path + '.battery', 1, now)
else:
graphite.push(path + '.battery', 0, now)
if "battery_ok" in data:
graphite.push(path + '.battery', data["battery_ok"], now)

if "humidity" in data:
graphite.push(path + '.humidity', data["humidity"], now)
Expand Down
7 changes: 2 additions & 5 deletions examples/rtl_433_mqtt_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ def publish_sensor_to_mqtt(mqttc, data, line):
elif "id" in data:
path += "/" + str(data["id"])

if "battery" in data:
if data["battery"] == "OK":
pass
else:
mqttc.publish(path + "/battery", str(data["battery"]))
if "battery_ok" in data:
mqttc.publish(path + "/battery", data["battery_ok"])

if "humidity" in data:
mqttc.publish(path + "/humidity", data["humidity"])
Expand Down
7 changes: 2 additions & 5 deletions examples/rtl_433_statsd_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ def rtl_433_probe():
if "channel" in data:
label += ".CH" + str(data["channel"])

if "battery" in data:
if data["battery"] == "OK":
statsd.gauge(label + '.battery', 1)
else:
statsd.gauge(label + '.battery', 0)
if "battery_ok" in data:
statsd.gauge(label + '.battery', data["battery_ok"])

if "humidity" in data:
statsd.gauge(label + '.humidity', data["humidity"])
Expand Down
7 changes: 2 additions & 5 deletions examples/rtl_433_statsd_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ def rtl_433_probe():
if "channel" in data:
label += ".CH" + str(data["channel"])

if "battery" in data:
if data["battery"] == "OK":
statsd.gauge(label + '.battery', 1)
else:
statsd.gauge(label + '.battery', 0)
if "battery_ok" in data:
statsd.gauge(label + '.battery', data["battery_ok"])

if "humidity" in data:
statsd.gauge(label + '.humidity', data["humidity"])
Expand Down
46 changes: 23 additions & 23 deletions src/devices/acurite.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static int acurite_th_decode(r_device *decoder, bitbuffer_t *bitbuffer)
data = data_make(
"model", "", DATA_STRING, "Acurite-609TXC",
"id", "", DATA_INT, id,
"battery", "", DATA_STRING, battery_low ? "LOW" : "OK",
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, tempc,
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"status", "", DATA_INT, status,
Expand Down Expand Up @@ -405,7 +405,7 @@ static int acurite_6045_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
"model", "", DATA_STRING, "Acurite-6045M",
"id", NULL, DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, channel_str,
"battery", "battery", DATA_STRING, battery_low ? "LOW" : "OK",
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_F", "temperature", DATA_FORMAT, "%.1f F", DATA_DOUBLE, tempf,
"humidity", "humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"strike_count", "strike_count", DATA_INT, strike_count,
Expand Down Expand Up @@ -547,8 +547,8 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
"id", NULL, DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, &channel_str,
"sequence_num", NULL, DATA_INT, sequence_num,
"battery_ok", NULL, DATA_INT, !battery_low,
"message_type", NULL, DATA_INT, message_type,
"battery_ok", "Battery", DATA_INT, !battery_low,
"message_type", NULL, DATA_INT, message_type,
"wind_avg_mi_h", "Wind Speed", DATA_FORMAT, "%.1f mi/h", DATA_DOUBLE, wind_speed_mph,
NULL);
/* clang-format on */
Expand Down Expand Up @@ -739,7 +739,7 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"model", "", DATA_STRING, "Acurite-Tower",
"id", "", DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, &channel_str,
"battery_ok", "", DATA_INT, !battery_low,
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, tempc,
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
Expand Down Expand Up @@ -788,7 +788,7 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"model", "", DATA_STRING, "Acurite-515",
"id", "", DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, &channel_str,
"battery_ok", "", DATA_INT, !battery_low,
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_F", "Temperature", DATA_FORMAT, "%.1f F", DATA_DOUBLE, tempf,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
NULL);
Expand Down Expand Up @@ -848,7 +848,7 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"id", NULL, DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, &channel_str,
"sequence_num", NULL, DATA_INT, sequence_num,
"battery", NULL, DATA_STRING, battery_low ? "OK" : "LOW",
"battery_ok", "Battery", DATA_INT, !battery_low,
"wind_avg_km_h", "wind_speed", DATA_FORMAT, "%.1f km/h", DATA_DOUBLE, wind_speed_kph,
"wind_dir_deg", NULL, DATA_FORMAT, "%.1f", DATA_DOUBLE, wind_dir,
"rain_in", "Rainfall Accumulation", DATA_FORMAT, "%.2f in", DATA_DOUBLE, raincounter * 0.01f,
Expand All @@ -875,7 +875,7 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"id", NULL, DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, &channel_str,
"sequence_num", NULL, DATA_INT, sequence_num,
"battery", NULL, DATA_STRING, battery_low ? "OK" : "LOW",
"battery_ok", "Battery", DATA_INT, !battery_low,
"wind_avg_km_h", "wind_speed", DATA_FORMAT, "%.1f km/h", DATA_DOUBLE, wind_speed_kph,
"temperature_F", "temperature", DATA_FORMAT, "%.1f F", DATA_DOUBLE, tempf,
"humidity", NULL, DATA_FORMAT, "%u %%", DATA_INT, humidity,
Expand Down Expand Up @@ -904,7 +904,7 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"id", NULL, DATA_FORMAT, "0x%02X", DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, &channel_str,
"sequence_num", NULL, DATA_INT, sequence_num,
"battery", NULL, DATA_STRING, battery_low ? "OK" : "LOW",
"battery_ok", "Battery", DATA_INT, !!battery_low, // NOTE: is this really flipped?
"wind_avg_mi_h", "wind_speed", DATA_FORMAT, "%.1f mi/h", DATA_DOUBLE, wind_speed_mph,
"temperature_F", "temperature", DATA_FORMAT, "%.1f F", DATA_DOUBLE, tempf,
"humidity", NULL, DATA_FORMAT, "%u %%", DATA_INT, humidity,
Expand Down Expand Up @@ -1078,7 +1078,7 @@ static int acurite_986_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"model", "", DATA_STRING, "Acurite-986",
"id", NULL, DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, channel_str,
"battery", "battery", DATA_STRING, battery_low ? "LOW" : "OK",
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_F", "temperature", DATA_FORMAT, "%f F", DATA_DOUBLE, (float)tempf,
"status", "status", DATA_INT, status,
"mic", "Integrity", DATA_STRING, "CRC",
Expand All @@ -1103,7 +1103,7 @@ static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)
int row;
int16_t temp_raw; // temperature as read from the data packet
float temp_c; // temperature in C
int battery; // the battery status: 1 is good, 0 is low
int battery_ok; // the battery status: 1 is good, 0 is low
int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed

row = bitbuffer_find_repeated_row(bitbuffer, 3, 32); // expected are 6 rows
Expand Down Expand Up @@ -1134,7 +1134,7 @@ static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)
// Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2
// upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status)
sensor_id = b[0];
battery = (b[1] & 0x80) >> 7;
battery_ok = (b[1] & 0x80) >> 7;
temp_raw = (int16_t)((b[1] << 12) | (b[2] << 4));
temp_raw = temp_raw >> 4;
temp_c = temp_raw * 0.1f;
Expand All @@ -1143,7 +1143,7 @@ static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)
data = data_make(
"model", "", DATA_STRING, "Acurite-606TX",
"id", "", DATA_INT, sensor_id,
"battery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
"battery_ok", "Battery", DATA_INT, battery_ok,
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
NULL);
Expand All @@ -1159,7 +1159,7 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
uint8_t *b;
int row;
int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed
int battery; // the battery status: 1 is good, 0 is low
int battery_ok; // the battery status: 1 is good, 0 is low
int channel;
int humidity;
int temp_raw; // temperature as read from the data packet
Expand Down Expand Up @@ -1203,7 +1203,7 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
// Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2
// upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status)
sensor_id = b[0] & 0xFE; //first 6 bits and it changes each time it resets or change the battery
battery = (b[0] & 0x01); //1=ok, 0=low battery
battery_ok = (b[0] & 0x01); //1=ok, 0=low battery
//next 2 bits are checksum
//next two bits are identify ID (maybe channel ?)
channel = (b[1] >> 4) & 0x03;
Expand All @@ -1221,7 +1221,7 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
data = data_make(
"model", "", DATA_STRING, "Acurite-590TX",
"id", "", DATA_INT, sensor_id,
"battery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
"battery_ok", "Battery", DATA_INT, battery_ok,
"channel", "Channel", DATA_INT, channel,
"humidity", "Humidity", DATA_COND, humidity != -1, DATA_INT, humidity,
"temperature_C", "Temperature", DATA_COND, humidity == -1, DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c,
Expand Down Expand Up @@ -1298,7 +1298,7 @@ static int acurite_00275rm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"model", "", DATA_STRING, model_flag ? "Acurite-00275rm" : "Acurite-00276rm",
"subtype", "Probe", DATA_INT, probe,
"id", "", DATA_INT, id,
"battery", "", DATA_STRING, battery_low ? "LOW" : "OK",
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_C", "Celsius", DATA_FORMAT, "%.1f C", DATA_DOUBLE, tempc,
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"water", "", DATA_COND, probe == 1, DATA_INT, water,
Expand Down Expand Up @@ -1338,7 +1338,7 @@ r_device acurite_rain_896 = {
static char *acurite_th_output_fields[] = {
"model",
"id",
"battery",
"battery_ok",
"temperature_C",
"humidity",
"status",
Expand Down Expand Up @@ -1368,7 +1368,7 @@ static char *acurite_txr_output_fields[] = {
"channel",
"sequence_num",
"battery_ok",
"battery",
"battery_ok",
"temperature_C",
"temperature_F",
"humidity",
Expand Down Expand Up @@ -1416,7 +1416,7 @@ static char *acurite_986_output_fields[] = {
"model",
"id",
"channel",
"battery",
"battery_ok",
"temperature_F",
"status",
NULL,
Expand All @@ -1443,7 +1443,7 @@ r_device acurite_986 = {
static char *acurite_606_output_fields[] = {
"model",
"id",
"battery",
"battery_ok",
"temperature_C",
"mic",
NULL,
Expand All @@ -1452,7 +1452,7 @@ static char *acurite_606_output_fields[] = {
static char *acurite_590_output_fields[] = {
"model",
"id",
"battery",
"battery_ok",
"channel",
"temperature_C",
"humidity",
Expand Down Expand Up @@ -1481,7 +1481,7 @@ static char *acurite_00275rm_output_fields[] = {
"model",
"subtype",
"id",
"battery",
"battery_ok",
"temperature_C",
"humidity",
"water",
Expand Down
8 changes: 4 additions & 4 deletions src/devices/alecto.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static int alectov1_callback(r_device *decoder, bitbuffer_t *bitbuffer)
"model", "", DATA_STRING, "AlectoV1-Wind",
"id", "House Code", DATA_INT, sensor_id,
"channel", "Channel", DATA_INT, channel,
"battery", "Battery", DATA_STRING, battery_low ? "LOW" : "OK",
"battery_ok", "Battery", DATA_INT, !battery_low,
"wind_avg_m_s", "Wind speed", DATA_FORMAT, "%.2f m/s", DATA_DOUBLE, speed * 0.2F,
"wind_max_m_s", "Wind gust", DATA_FORMAT, "%.2f m/s", DATA_DOUBLE, gust * 0.2F,
"wind_dir_deg", "Wind Direction", DATA_INT, direction,
Expand All @@ -183,7 +183,7 @@ static int alectov1_callback(r_device *decoder, bitbuffer_t *bitbuffer)
"model", "", DATA_STRING, "AlectoV1-Rain",
"id", "House Code", DATA_INT, sensor_id,
"channel", "Channel", DATA_INT, channel,
"battery", "Battery", DATA_STRING, battery_low ? "LOW" : "OK",
"battery_ok", "Battery", DATA_INT, !battery_low,
"rain_mm", "Total Rain", DATA_FORMAT, "%.02f mm", DATA_DOUBLE, rain_mm,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
NULL);
Expand All @@ -208,7 +208,7 @@ static int alectov1_callback(r_device *decoder, bitbuffer_t *bitbuffer)
"model", "", DATA_STRING, "AlectoV1-Temperature",
"id", "House Code", DATA_INT, sensor_id,
"channel", "Channel", DATA_INT, channel,
"battery", "Battery", DATA_STRING, battery_low ? "LOW" : "OK",
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_C", "Temperature", DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp_c,
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
Expand All @@ -225,7 +225,7 @@ static char *output_fields[] = {
"model",
"id",
"channel",
"battery",
"battery_ok",
"temperature_C",
"humidity",
"rain_mm",
Expand Down
8 changes: 5 additions & 3 deletions src/devices/ambient_weather.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@ static int ambient_weather_decode(r_device *decoder, bitbuffer_t *bitbuffer, uns
temperature = (temp_f - 400) * 0.1f;
humidity = b[4];

/* clang-format off */
data = data_make(
"model", "", DATA_STRING, "Ambientweather-F007TH",
"id", "House Code", DATA_INT, deviceID,
"channel", "Channel", DATA_INT, channel,
"battery", "Battery", DATA_STRING, isBatteryLow ? "Low" : "OK",
"battery_ok", "Battery", DATA_INT, !isBatteryLow,
"temperature_F", "Temperature", DATA_FORMAT, "%.1f F", DATA_DOUBLE, temperature,
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"mic", "Integrity", DATA_STRING, "CRC",
NULL);
decoder_output_data(decoder, data);
/* clang-format on */

decoder_output_data(decoder, data);
return 1;
}

Expand Down Expand Up @@ -106,7 +108,7 @@ static char *output_fields[] = {
"model",
"id",
"channel",
"battery",
"battery_ok",
"temperature_F",
"humidity",
"mic",
Expand Down
8 changes: 4 additions & 4 deletions src/devices/ambientweather_tx8300.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ static int ambientweather_tx8300_callback(r_device *decoder, bitbuffer_t *bitbuf
/* clang-format off */
data = data_make(
"model", "", DATA_STRING, "AmbientWeather-TX8300",
"id", "", DATA_INT, sensor_id,
"channel", "", DATA_INT, channel,
"battery", "Battery", DATA_INT, battery_low, // mapping unknown
"id", "", DATA_INT, sensor_id,
"channel", "", DATA_INT, channel,
"battery", "Battery", DATA_INT, battery_low, // mapping unknown
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c,
"humidity", "Humidity", DATA_COND, humidity >= 0, DATA_FORMAT, "%u %%", DATA_INT, humidity,
"humidity", "Humidity", DATA_COND, humidity >= 0, DATA_FORMAT, "%u %%", DATA_INT, humidity,
"mic", "MIC", DATA_STRING, "CHECKSUM",
NULL);
/* clang-format on */
Expand Down
Loading