diff --git a/daemon/clearpowerd/charge_control.py b/daemon/clearpowerd/charge_control.py index 06a9dbb..acda9c0 100644 --- a/daemon/clearpowerd/charge_control.py +++ b/daemon/clearpowerd/charge_control.py @@ -68,11 +68,13 @@ def _write_thresholds(self, start, end): order = order[::-1] try: for path, value in order: - write_str(path, value) + if os.path.exists(path): + write_str(path, value) except OSError: # firmware quirk: try the other order once before giving up for path, value in order[::-1]: - write_str(path, value) + if os.path.exists(path): + write_str(path, value) def _write_behaviour(self, b): if not self.behaviour_supported: diff --git a/daemon/clearpowerd/sampler.py b/daemon/clearpowerd/sampler.py index 5cf9d7b..c6f65b3 100644 --- a/daemon/clearpowerd/sampler.py +++ b/daemon/clearpowerd/sampler.py @@ -107,7 +107,7 @@ def sample(self, hot=True): # ---- whole-machine draw ---- if not on_ac and bat_w < -0.05: sys_w, sys_source = -bat_w, "battery" # physical truth incl. all losses - elif psys > 0: + elif psys > 0 and (package <= 0 or psys >= package * 0.7): sys_w, sys_source = psys, "psys" elif package > 0: sys_w, sys_source = package + 3.0, "estimate" diff --git a/daemon/clearpowerd/sources/rapl.py b/daemon/clearpowerd/sources/rapl.py index e89a842..3c85b32 100644 --- a/daemon/clearpowerd/sources/rapl.py +++ b/daemon/clearpowerd/sources/rapl.py @@ -17,6 +17,8 @@ def __init__(self): if not name: continue key = name.split("-")[0] # package-0 -> package + if key == "psys" and read_int(os.path.join(d, "enabled")) == 0: + continue self.domains[key] = d self._wrap = {k: read_int(os.path.join(p, "max_energy_range_uj")) or (1 << 32) for k, p in self.domains.items()}