Code Monkey home page Code Monkey logo

Comments (5)

realthk avatar realthk commented on July 29, 2024 1

Oh, I see, and already found the bug there, this conversion is wrong:
"value_template": "{{ float(value|float) * 3.6 | round(2) }}"

Because in Jinja templating of HA, the order of execution is not guaranteed to be left-to-right, only if you use parentheses around everything before the last filter like this:
"value_template": "{{ (float(value|float) * 3.6) | round(2) }}"

For example, copy this into the template editor of developer tools in HA, and get the same 1.4400000000000002:
{{ float(0.4|float) * 3.6 | round(2) }}
while this results the correct 1.44:
{{ (float(0.4|float) * 3.6) | round(2) }}

Now of course this only affects the lines having round() filter in the linked rtl_433_mqtt_hass.py, like speed conversions from m/s to km/h, calculation rain rate/hour, not the temperature, which is simple {{ value|float }} - but I have no problem with my RTL 433 temperature values in HA, that might be something else with the problem of booroondookZ.

So thanks, I'll report the issue in that main 433 repo, this might as well be closed.

from rtl_433-hass-addons.

realthk avatar realthk commented on July 29, 2024 1

I did, and as the fix is very simple, it was merged at once

from rtl_433-hass-addons.

realthk avatar realthk commented on July 29, 2024

Yes, even more so with wind-speed:
image

It's easy to create a rounded template sensor in HA, but it would be much better to handle in RTL 433.
It even could be a global option, as I guess a 2 decimal rounding won't hurt any sensor.
(especially because it is not real sensor-precision, but only the result of BCD conversion)

from rtl_433-hass-addons.

deviantintegral avatar deviantintegral commented on July 29, 2024

merbanan/rtl_433#1509 discusses this upstream. It's pointed out that different systems consuming the MQTT data may need different precision to parse the float correctly. However, in our case, we know that we're consuming the data in Home Assistant and could make some assumptions.

If we implement rounding, would we do it for all floats, or just specific floats? What if different devices needed different options for rounding?

Perhaps more interesting, what if Home Assistant or some upstream library is parsing the float incorrectly? I'm assuming you've confirmed that the numbers in Home Assistant match the MQTT data?

I'm happy to continue the discussion here for now, but I think this is likely best as an update to the upstream script at https://github.com/merbanan/rtl_433/blob/master/examples/rtl_433_mqtt_hass.py.

from rtl_433-hass-addons.

deviantintegral avatar deviantintegral commented on July 29, 2024

Please link the issue here when you do.

from rtl_433-hass-addons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.