From 79b98d00107caa436181cb6638085743271beea4 Mon Sep 17 00:00:00 2001 From: clavay Date: Fri, 24 Nov 2023 14:05:34 +0100 Subject: [PATCH] fix difference percent period calculation --- pyscada/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyscada/models.py b/pyscada/models.py index 615ccda5..3e3c404e 100755 --- a/pyscada/models.py +++ b/pyscada/models.py @@ -2215,7 +2215,10 @@ def get_value(self, d1, d2): elif type_str == "difference": res = values[-1] - values[0] elif type_str == "difference percent": - res = (values[-1] - values[0]) / min(values) + if values[0] == 0: + res = None + else: + res = (values[-1] - values[0]) / (values[0] * 100) elif type_str == "delta": res = 0 v = None