From 37c4198cdf300b4dab002e5cbc9ea2590f17f168 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andrej=20Kou=C5=99il?= Date: Sun, 27 Mar 2016 13:10:14 +0200 Subject: [PATCH] Added rate check --- widgets/bat.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/widgets/bat.lua b/widgets/bat.lua index b118035..8cc1ea9 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -69,6 +69,13 @@ local function worker(args) local rate_voltage = tonumber(first_line(bstr .. "/voltage_now")) local rate_power = tonumber(first_line(bstr .. "/power_now")) + -- if rate = 0 or rate not defined skip the round + if not (rate_power and rate_power > 0) and + not (rate_current and rate_current > 0) + then + return + end + -- energy_now(P)[uWh], charge_now(I)[uAh] local energy_now = tonumber(first_line(bstr .. "/energy_now") or first_line(bstr .. "/charge_now")) -- 2.39.5