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 all uv fields to uvi, BREAKING change to UV sensors #3131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions examples/rtl_433_mqtt_hass.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@
"device_type": "sensor",
"object_suffix": "uv",
"config": {
"name": "UV Index",
"unit_of_measurement": "UV Index",
"name": "UV Value",
"unit_of_measurement": "UV",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is changing a field called 'uv' to be called value vs index, to unconfuse it with the index.

But what is this field? Is it "some random thing in a decoder we think is related to uv"? Or does it have more semantics? I can see some sort of radiometric measurement that means something, before converting to index, but I really doubt that's what is going on.

I wonder then if we should rename it something that indicates that it is unclear, or how many drivers generate it. But I get it that unconfusing is a positive step, even if confusion remains, so this is not an objection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I have this on my station I have to say I really don't know what kind of UV related value this might be, but with consumer stations generally having UVA only photodiodes I assume it is the raw diode value from which the eventual UV Index value is being calculated!?!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be. What I don't like is reporting a bunch of such values from different kinds of manufacturers/hardware using the same name, implying they are the same thing. Perhaps if we rename it UV Raw, and adopt a convention that "Foo Raw" means e.g. some unprocessed ADC value that we believe is related to Foo, and that while people might want to e.g. transmit it to Home Assistant and log/graph it, there's no reason to expect a Foo Raw from device A to mean the same thing as Foo Raw from device B. This is different from things like temperature, illuminance, station pressure, UV index.

I worked on the Ford TPMS decoder a while ago, and it had values that were in odd units (0.25 psi), and we didn't and don't put those values in the output. Generally, once mapped to real units, the upstream data isn't useful or interesting.

In this case, though, it sounds like in the over-the-air format there is both a "UV Raw" and a "UV Index"? If so, I guess that's ok. But if rtl_433 is calculating UV Index, then I would lean to suppressing the Raw in the output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you suspect it's a mapping from a roughly linear raw(?) value.

// UV value UVI
// 0-432 0
// 433-851 1
// 852-1210 2
// 1211-1570 3
// 1571-2017 4
// 2018-2450 5
// 2451-2761 6
// 2762-3100 7
// 3101-3512 8
// 3513-3918 9
// 3919-4277 10
// 4278-4650 11
// 4651-5029 12
// >=5230 13
int uvi_upper[] = {432, 851, 1210, 1570, 2017, 2450, 2761, 3100, 3512, 3918, 4277, 4650, 5029};
int uv_index = 0;
while (uv_index < 13 && uvi_upper[uv_index] < uv_raw) ++uv_index;
added with #809

This raw value has a resolution of about 400 units per Index step. Perhaps a case for a 0.01 UV Index here :)

We could drop this, possibly raw, value if we represent all useful information from it in a standard way.

We could then also debate to use uv as the UV Index key and thus hit less devices with a breaking change. I have a feeling that "UVI" is more of a known term then "UV" alone.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that UVI is better than UV, but if we (rtl_433) decide that a field named UV means "UV index", that's fine. There would then be a different change, to rename all fields that are UV that are not UV index, to something else.

Given that fineoffset code, I'd say just output the index, and not the raw. And make uv index have 2 places, if not 3. The point is that with 3, you can back out the raw if you want, or you can see the structure in how it changes, and that removes the last "but I want the info in the raw, even if just to see if it makes sense".

"value_template": "{{ value|float|round(1) }}",
"state_class": "measurement"
}
Expand Down
4 changes: 2 additions & 2 deletions src/devices/acurite.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
}

/* clang-format off */
data = data_int(data, "uv", NULL, NULL, uv);
data = data_int(data, "uvi", "UV Index", NULL, uv);
data = data_int(data, "lux", NULL, NULL, lux * 10);
/* clang-format on */
}
Expand Down Expand Up @@ -1899,7 +1899,7 @@ static char const *const acurite_txr_output_fields[] = {
"storm_dist",
"strike_count",
"strike_distance",
"uv",
"uvi",
"lux",
"active",
"exception",
Expand Down
2 changes: 1 addition & 1 deletion src/devices/ambientweather_wh31e.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static int ambientweather_whx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"light_lux", "Lux", DATA_FORMAT, "%u lux", DATA_INT, light_lux,
"wind_avg_m_s", "Wind Speed", DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, wspeed * 0.1f,
"wind_max_m_s", "Wind Gust", DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, wgust * 0.1f,
"uvi", "UVI", DATA_INT, uvindex,
"uvi", "UV Index", DATA_INT, uvindex,
"wind_dir_deg", "Wind dir", DATA_INT, wdir,
"data", "Extra Data", DATA_STRING, extra,
"mic", "Integrity", DATA_STRING, "CRC",
Expand Down
6 changes: 3 additions & 3 deletions src/devices/bresser_6in1.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static int bresser_6in1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
// apparently ff01 or 0000 if not available, ???0 if valid inverted BCD
int uv_ok = (msg[16] & 0x0f) == 0 && (~msg[15] & 0xff) <= 0x99 && (~msg[16] & 0xf0) <= 0x90;
int const uv_raw = ((~msg[15] & 0xf0) >> 4) * 100 + (~msg[15] & 0x0f) * 10 + ((~msg[16] & 0xf0) >> 4);
float const uv = uv_raw * 0.1f;
float const uvi = uv_raw * 0.1f;
int const flags = (msg[16] & 0x0f); // looks like some flags, not sure

//int const unk_ok = (msg[16] & 0xf0) == 0xf0;
Expand Down Expand Up @@ -219,7 +219,7 @@ static int bresser_6in1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"wind_dir_deg", "Direction", DATA_COND, wind_ok, DATA_INT, wind_dir,
"rain_mm", "Rain", DATA_COND, rain_ok, DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rain_mm,
//"unknown", "Unknown", DATA_COND, unk_ok, DATA_INT, unk_raw,
"uv", "UV", DATA_COND, uv_ok, DATA_FORMAT, "%.1f", DATA_DOUBLE, uv,
"uvi", "UV Index", DATA_COND, uv_ok, DATA_FORMAT, "%.1f", DATA_DOUBLE, uvi,
"startup", "Startup", DATA_COND, startup, DATA_INT, startup,
"flags", "Flags", DATA_INT, flags,
"mic", "Integrity", DATA_STRING, "CRC",
Expand All @@ -243,7 +243,7 @@ static char const *const output_fields[] = {
"wind_avg_m_s",
"wind_dir_deg",
"rain_mm",
"uv",
"uvi",
"startup",
"flags",
"mic",
Expand Down
4 changes: 2 additions & 2 deletions src/devices/bresser_7in1.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static int bresser_7in1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"rain_mm", "Rain", DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rain_mm,
"light_klx", "Light", DATA_FORMAT, "%.3f klx", DATA_DOUBLE, light_klx, // TODO: remove this
"light_lux", "Light", DATA_FORMAT, "%.3f lux", DATA_DOUBLE, light_lux,
"uv", "UV Index", DATA_FORMAT, "%.1f", DATA_DOUBLE, uv_index,
"uvi", "UV Index", DATA_FORMAT, "%.1f", DATA_DOUBLE, uv_index,
"battery_ok", "Battery", DATA_INT, !battery_low,
"mic", "Integrity", DATA_STRING, "CRC",
NULL);
Expand Down Expand Up @@ -311,7 +311,7 @@ static char const *const output_fields[] = {
"rain_mm",
"light_klx", // TODO: remove this
"light_lux",
"uv",
"uvi",
"pm2_5_ug_m3",
"pm10_0_ug_m3",
"battery_ok",
Expand Down
8 changes: 4 additions & 4 deletions src/devices/cotech_36_7959.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ static int cotech_36_7959_decode(r_device *decoder, bitbuffer_t *bitbuffer)
int temp_raw = ((b[7] & 0x0f) << 8) | (b[8]); // [60:12]
int humidity = (b[9]); // [72:8]
int light_lux = (b[10] << 8) | b[11] | ((b[7] & 0x80) << 9); // [56:1][80:16]
int uv = (b[12]); // [96:8]
int uvi = (b[12]); // [96:8]
//int crc = (b[13]); // [104:8]

float temp_c = (temp_raw - 400) * 0.1f;

// On models without a light sensor, the value read for UV index is out of bounds with its top bits set
int light_is_valid = (uv <= 150); // error value seems to be 0xfb, lux would be 0xfffb
int light_is_valid = (uvi <= 150); // error value seems to be 0xfb, lux would be 0xfffb

/* clang-format off */
data = data_make(
Expand All @@ -128,7 +128,7 @@ static int cotech_36_7959_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"wind_avg_m_s", "Wind", DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, wind * 0.1f,
"wind_max_m_s", "Gust", DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, gust * 0.1f,
"light_lux", "Light Intensity", DATA_COND, light_is_valid, DATA_FORMAT, "%u lux", DATA_INT, light_lux,
"uv", "UV Index", DATA_COND, light_is_valid, DATA_FORMAT, "%.1f", DATA_DOUBLE, uv * 0.1f,
"uvi", "UV Index", DATA_COND, light_is_valid, DATA_FORMAT, "%.1f", DATA_DOUBLE, uvi * 0.1f,
"mic", "Integrity", DATA_STRING, "CRC",
NULL);
/* clang-format on */
Expand All @@ -149,7 +149,7 @@ static char const *const cotech_36_7959_output_fields[] = {
"wind_avg_m_s",
"wind_max_m_s",
"light_lux",
"uv",
"uvi",
"mic",
NULL,
};
Expand Down
4 changes: 2 additions & 2 deletions src/devices/emax.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int emax_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"wind_avg_km_h", "Wind avg speed", DATA_FORMAT, "%.1f km/h", DATA_DOUBLE, speed_kmh,
"wind_dir_deg", "Wind Direction", DATA_INT, direction_deg,
"rain_mm", "Total rainfall", DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rain_mm,
"uv", "UV Index", DATA_COND, tag !=3, DATA_FORMAT, "%u", DATA_INT, uv_index,
"uvi", "UV Index", DATA_COND, tag !=3, DATA_FORMAT, "%u", DATA_INT, uv_index,
"light_lux", "Lux", DATA_COND, tag !=3, DATA_FORMAT, "%u", DATA_INT, light_lux,
"pairing", "Pairing?", DATA_COND, pairing, DATA_INT, !!pairing,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
Expand Down Expand Up @@ -264,7 +264,7 @@ static char const *const output_fields[] = {
"wind_max_km_h",
"rain_mm",
"wind_dir_deg",
"uv",
"uvi",
"light_lux",
"pairing",
"mic",
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fineoffset.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static int fineoffset_WH24_callback(r_device *decoder, bitbuffer_t *bitbuffer)
"wind_max_m_s", "Gust speed", DATA_COND, gust_speed_raw != 0xff, DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, gust_speed_ms,
"rain_mm", "Rainfall", DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rainfall_mm,
"uv", "UV", DATA_COND, uv_raw != 0xffff, DATA_INT, uv_raw,
"uvi", "UVI", DATA_COND, uv_raw != 0xffff, DATA_INT, uv_index,
"uvi", "UV Index", DATA_COND, uv_raw != 0xffff, DATA_INT, uv_index,
"light_lux", "Light", DATA_COND, light_raw != 0xffffff, DATA_FORMAT, "%.1f lux", DATA_DOUBLE, light_lux,
"mic", "Integrity", DATA_STRING, "CRC",
NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fineoffset_ws80.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static int fineoffset_ws80_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"wind_dir_deg", "Wind direction", DATA_COND, wind_dir != 0x1ff, DATA_INT, wind_dir,
"wind_avg_m_s", "Wind speed", DATA_COND, wind_avg != 0x1ff, DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, wind_avg * 0.1f,
"wind_max_m_s", "Gust speed", DATA_COND, wind_max != 0x1ff, DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, wind_max * 0.1f,
"uvi", "UVI", DATA_COND, uv_index != 0xff, DATA_FORMAT, "%.1f", DATA_DOUBLE, uv_index * 0.1f,
"uvi", "UV Index", DATA_COND, uv_index != 0xff, DATA_FORMAT, "%.1f", DATA_DOUBLE, uv_index * 0.1f,
"light_lux", "Light", DATA_COND, light_raw != 0xffff, DATA_FORMAT, "%.1f lux", DATA_DOUBLE, (double)light_lux,
"flags", "Flags", DATA_FORMAT, "%02x", DATA_INT, flags,
"unknown", "Unknown", DATA_COND, unknown != 0x3fff, DATA_INT, unknown,
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fineoffset_ws90.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int fineoffset_ws90_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"wind_dir_deg", "Wind direction", DATA_COND, wind_dir != 0x1ff, DATA_INT, wind_dir,
"wind_avg_m_s", "Wind speed", DATA_COND, wind_avg != 0x1ff, DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, wind_avg * 0.1f,
"wind_max_m_s", "Gust speed", DATA_COND, wind_max != 0x1ff, DATA_FORMAT, "%.1f m/s", DATA_DOUBLE, wind_max * 0.1f,
"uvi", "UVI", DATA_COND, uv_index != 0xff, DATA_FORMAT, "%.1f", DATA_DOUBLE, uv_index * 0.1f,
"uvi", "UV Index", DATA_COND, uv_index != 0xff, DATA_FORMAT, "%.1f", DATA_DOUBLE, uv_index * 0.1f,
"light_lux", "Light", DATA_COND, light_raw != 0xffff, DATA_FORMAT, "%.1f lux", DATA_DOUBLE, (double)light_lux,
"flags", "Flags", DATA_FORMAT, "%02x", DATA_INT, flags,
"rain_mm", "Total Rain", DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rain_raw * 0.1f,
Expand Down
4 changes: 2 additions & 2 deletions src/devices/holman_ws5029.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static int holman_ws5029pcm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"rain_mm", "Total rainfall", DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rain_mm,
"wind_avg_km_h", "Wind avg speed", DATA_FORMAT, "%.1f km/h", DATA_DOUBLE, speed_kmh,
"wind_dir_deg", "Wind Direction", DATA_INT, direction_deg,
"uv", "UV Index", DATA_FORMAT, "%u", DATA_INT, uv_index,
"uvi", "UV Index", DATA_FORMAT, "%u", DATA_INT, uv_index,
"light_lux", "Lux", DATA_FORMAT, "%u", DATA_INT, light_lux,
"counter", "Counter", DATA_FORMAT, "%u", DATA_INT, counter,
"battery_ok", "battery", DATA_FORMAT, "%u", DATA_INT, !battery_low,
Expand All @@ -192,7 +192,7 @@ static char const *const output_fields[] = {
"rain_mm",
"wind_avg_km_h",
"wind_dir_deg",
"uv",
"uvi",
"light_lux",
"counter",
"mic",
Expand Down
6 changes: 3 additions & 3 deletions src/devices/oregon_scientific.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ static int oregon_scientific_v2_1_decode(r_device *decoder, bitbuffer_t *bitbuff
data = data_make(
"model", "", DATA_STRING, "Oregon-UVR128",
"id", "House Code", DATA_INT, device_id,
"uv", "UV Index", DATA_FORMAT, "%u", DATA_INT, uvidx,
"uvi", "UV Index", DATA_FORMAT, "%u", DATA_INT, uvidx,
"battery_ok", "Battery", DATA_INT, !battery_low,
//"channel", "Channel", DATA_INT, channel,
NULL);
Expand Down Expand Up @@ -710,7 +710,7 @@ static int oregon_scientific_v3_decode(r_device *decoder, bitbuffer_t *bitbuffer
"id", "House Code", DATA_INT, device_id,
"channel", "Channel", DATA_INT, channel,
"battery_ok", "Battery", DATA_INT, !battery_low,
"uv", "UV Index", DATA_FORMAT, "%u", DATA_INT, uvidx,
"uvi", "UV Index", DATA_FORMAT, "%u", DATA_INT, uvidx,
NULL);
/* clang-format on */
decoder_output_data(decoder, data);
Expand Down Expand Up @@ -951,7 +951,7 @@ static char const *const output_fields[] = {
"wind_avg_m_s",
"wind_dir_deg",
"pressure_hPa",
"uv",
"uvi",
"power_W",
"energy_kWh",
"radio_clock",
Expand Down
4 changes: 2 additions & 2 deletions src/devices/vevor_7in1.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static int vevor_7in1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"wind_max_km_h", "Wind max speed", DATA_FORMAT, "%.1f km/h", DATA_DOUBLE, gust_kmh,
"wind_dir_deg", "Wind Direction", DATA_INT, direction_deg,
"rain_mm", "Total rainfall", DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rain_mm,
"uv", "UV Index", DATA_FORMAT, "%u", DATA_INT, uv_index,
"uvi", "UV Index", DATA_FORMAT, "%u", DATA_INT, uv_index,
"light_lux", "Lux", DATA_FORMAT, "%u", DATA_INT, light_lux,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
NULL);
Expand All @@ -155,7 +155,7 @@ static char const *const output_fields[] = {
"wind_max_km_h",
"rain_mm",
"wind_dir_deg",
"uv",
"uvi",
"light_lux",
"mic",
NULL,
Expand Down
Loading