Community
OpenEnergyMonitor

Community

LCD setup question

Tags: #<Tag:0x00007f6e13a66a48>

I’m a python noob, but i want something changed to the output on the LCD of my emonpi.
The below text from the python-script should generate an output of a rounded value, instead of a decimal value, and negative values should be shown as an Absolute value with IN (for positive values, or OUT (in case the value was negative)

if page == 3:
if r.get(“feed1”) is not None:
lcd[0] = feed1_name + ‘:’ + r.get(“feed1”) + feed1_unit
else:
lcd[0] = feed1_name + ‘:’ + “—”

    if r.get("feed2") is not None:
        lcd[1] = feed2_name + ':'  + r.get("feed2") + feed2_unit 
    else:
        lcd[1] = feed2_name + ':'  + "---"

How to accomplish this?

Hello @peter_duyck, perhaps try:

https://www.w3schools.com/python/ref_func_round.asp

and

https://www.tutorialspoint.com/python/number_abs.htm

before calling abs you will want to check if its positive or negative and display the right text.

When your combining numbers and strings you need to add a str(1.234) around the number