You might want do a test for null before doing a greater/less than comparison to avoid the "TypeError: '>=' not supported between instances of 'NoneType' and 'float'" errors. I suspect you'll get those errors if there is no value for $x in your example.
This is off the top of my head and likely the wrong syntax: #if $x is not None and $x>= 2.41 On Fri, Dec 3, 2021, 10:09 AM vince <[email protected]> wrote: > Well you WANTED accuracy, you're getting accuracy :-) > > I know you figured it out, but be forewarned that the Cheetah engine under > the hood here is very finicky and debugging things when you have even the > slightest typo can get very frustrating. Definitely make small changes > one at a time and keep your modifications in a version control system such > as git. You'll thank yourself later. > > Incidentally - Cheetah is a third-party thing weewx relies on, so it's not > anything anybody here can fix. It is what it is. Sometimes you have to go > with it. It's powerful but yes it can make you a little crazy when it > throws a fit. > > Hint for the future - go through the formatting examples > <https://weewx.com/docs/customizing.htm#Formatting_examples> in the > Customization guide. It'll make how to tweak things more obvious. In > fact, you should at least scan the whole Customization guide > <https://weewx.com/docs/customizing.htm> and the other large sets of info > in the wiki <https://github.com/weewx/weewx/wiki> and the FAQ > <https://github.com/weewx/weewx/wiki/WeeWX-Frequently-Asked-Questions>. > > On Friday, December 3, 2021 at 12:43:40 AM UTC-8 [email protected] wrote: > >> eeeek. >> >> >> Battery OK - 2.6226000000000003 >> >> k, how do I format a float in this cheetah template language? I mean, I >> assume thats what sensor.inc is ? >> >> #if $x >= 2.455 >> <span class="status_ok">OK - *$x*</span> >> #else >> #if $x >= 2.41 >> <span class="status_low">LOW - mode 1 - *$x*</span> >> #else >> #if $x >= 2.39 >> <span class="status_low">LOW - mode 2 - *$x*</span> >> #else >> <span class="status_low">LOW - mode 3 - *$x*</span> >> #end if >> #end if >> #end if >> >> >> -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/fa850573-3052-4f98-bfa9-f3847dfd7c0cn%40googlegroups.com > <https://groups.google.com/d/msgid/weewx-user/fa850573-3052-4f98-bfa9-f3847dfd7c0cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAA1SM21d_Ghqj2HGOPBjoJYghukGY%2BEQF%2BL8GfbkWp7FNBcbuQ%40mail.gmail.com.
