Replies: 10 comments 24 replies
-
My take is that we should define semantics and then just change things as a bug fix, and not worry about compat with the previous world. Secondarily, I lean to looking at what Home Assistant norms are, and esphome, and aligning to that. I could also see battery_voltage for voltage in volts, separate from scaling to battery_level. But I could also see the argument that this is duplicative and thus bad. |
Beta Was this translation helpful? Give feedback.
-
There is always room for improvement. We don't like to break things for existing users, getting to Adding such a central field, say Whenever possible a field suffix should standardize the values, e.g. obvious suffixes like Some additional questions come to mind: what would be the defined top level? 100% i.e. 1.0? Should we cap there? What about values derived from battery mV with very fresh batteries above nominal voltage? What would be the nominal lowest values? 0% i.e. 0.0? Or should the nominal lowest value, e.g. derived from batteries or a battery_low flag be some random other value, 10%? Would there be a defined step for battery_warning, 30%? What about calculations that place minimum nominal battery voltage at, say, 10%, how much lower are they allowed to go? Should there be a cap or possibly negative values? In summary, if we do something like this then we need to think of and document all the weird edge cases, thoroughly. |
Beta Was this translation helpful? Give feedback.
-
So I guess the OP should say concretely what is wrong with Home Assistant, as far as I understand it, uses "Battery Level" with 100% as full/new. I think it should just be scaled to nominal, with 0% = 0V. So basically battery_V / battery_nominal_V. That leaves out a lot of complexity, which is good and bad. We could also add battery_remaining to be intended to be 0% to 100% of the runtime from new batteries. But that seems way harder than anybody is really going to do. Plus, to do it right, you need to know about the battery that was inserted (alkaline vs NiMH, as the biggest example). Personally, I want to know the voltage, but I like the 100%=fresh translation in HA. But, agreed this is harder than I made it out to be and that a deliberate approach is in order. |
Beta Was this translation helpful? Give feedback.
-
Sort of related: https://andrew-codechimp.github.io/HA-Battery-Notes/ |
Beta Was this translation helpful? Give feedback.
-
There is somewhat of a related issue of not really having boolean types in rtl_433 data schema. Using ints (or floats in battery_ok) allows for overloading which can be very tempting to overload in order to shoehorn something in. But in the long term this can be detrimental for having clear semantics for consumers. Other places this comes up is for most motion, security, leak, etc. sensors that using Home Assistant's terminology are naturally binary sensors. (Side note: I think Home Assistant's binary_sensor device class for battery status didn't exist when the MQTT auto discovery script was created.) Separate discussion, the current MQTT auto discovery script is somewhat of a dead end because it only works on the level of the individual data elements, so it can't make per model/device decisions. It also doesn't really keep state so hard to filter out false positive decodes and control when things get added. @DigiH - I'm not familiar with OpenMQTTGateway, but if it has support for the rtl_433 ESP port, could it be used to read from rtl_433 directly and replace the auto discovery script and/or mqtt gateway script for Home Assistant users? |
Beta Was this translation helpful? Give feedback.
-
Doctrine questions:
|
Beta Was this translation helpful? Give feedback.
-
discovery probably needs to be upleveled, perhaps to some descriptor emitted by the driver, or in rtl_433 more properly. That's a much bigger rototill. Otherwise we're doing it twice. |
Beta Was this translation helpful? Give feedback.
-
There are two ways to represent information that is derived from voltage. Well, 3. One is to just output the voltage, and I would say any decoder that reads voltage should output battery_V (not mV, but V, this is using SI units vs some synthetic -- we already convert to metric units otherwise). Then, there is "battery_level", which is battery voltage divided by nominal battery voltage * 100%, That's a way to have something that behaves exactly like voltage but is on a common scale if graphing different kinds of devices. For example I am monitoring (not with rtl_433) 3 UPS units. 2 have 2x 12V lead acid, and 1 has 1. It would be nice to look at that as /24V and /12V since then it lines up nicely. Note that this has no belief about remaining life and curve shapes - it is not obscuring the underlying data, just fixed scaling. Finally there is battery_pct (or _percent), which is an estimate of remaining life, from 100% at new battery to 0% at failure and in theory linear in time. This is very tricky. Some devices report things that are like this and mapping is straightforward. Making up percent life from voltage is I think aspiratiional rather than reliable, absent device-specific calibration. If you think there is some min, and want to synthesize percent from new-battery-min (say 1.6V to 1.3V for AA, but that fails for NiMH), then I don't have a problem with that, but I would like to see battery_level which is 100% for 1.5V, sort of "percent of battery nominal voltage". As in also see, not instead. |
Beta Was this translation helpful? Give feedback.
-
Another ambiguity and inconsistency is with the uv and uvi keys. The Vevor 7-in-1 has the UV key actually being the UV Index, while my own Fineoffset-WH65B has both UV and UVI, which we discover as UV Level/Raw (UV) and UV Index (UVI), already causing a UV Index inconsistency and discovery mayhem with these two decoders without having even looked at any other UV and UVI implementations. |
Beta Was this translation helpful? Give feedback.
-
@DigiH yes, all UV Index fields should be named "uvi", please review #3131 |
Beta Was this translation helpful? Give feedback.
-
With the current state of RTL_433 keys indiscriminately covering different types with the same named keys, it is hard, if not impossible, to correctly auto-discover such key correctly.
The major example is the current battery_ok key, covering binary integer states for some devices, while others broadcast a float which can be nicely multiplied for a 0-100% battery level state.
Coming from the OpenMQTTGateway side, which uses the RTL_433_ESP port, this previously took over the RTL_433's own rtl_433_mqtt_hass.py script binary state conversion. This always was a thorn in my side side and a very ugly crutch tin my view, jumping from 100% to a nonsensical 0% only for any binary battery devices, making even reviewers think it 's a bug or what not.
I have mentioned this before in
#2948
and eventually implemented a manual filtering in OpenMQTTGateway to correct this. With the recent update of RTL_433_ESP, with new decoders included, this would mean going through all the added decoders again manually to see which new devices might need to be added to the manual filter at
/~https://github.com/1technophile/OpenMQTTGateway/blob/development/main/ZgatewayRTL_433.ino#L160
For which I do not have the time, nor the inclination at the moment.
It all boils down to the question if RTL_433 is willing and interested in making discoverable type distinctions for battery_ok, and possibly other similar keys, and owning up to the fact that it's 2024, well 2025 soon , and most users are non-technical relying on a preferable nicely well implemented auto-discovery, while renaming the float key to battery_ok_f and keeping battery_ok (for int/binary) would also not majorly break it for existing non-discovery users, even though battery_level and battery_ok would be more fitting keys.
Both the rtl_433_mqtt_hass.py script, as well as new devices in RTL_433_ESP would greatly benefit from this, presenting correctly battery device classes for auto-discovery, instead of the current state.
Thanks for reading my rant.
Beta Was this translation helpful? Give feedback.
All reactions