Просмотр исходного кода

write display values every 5s to influx and ignore ddc errors.

Thomas B 3 месяцев назад
Родитель
Сommit
6bd3442aa1
1 измененных файлов: 10 добавлений и 10 удалений
  1. 10
    10
      client/brightness.py

+ 10
- 10
client/brightness.py Просмотреть файл

@@ -5,7 +5,7 @@ import ddc
5 5
 import time
6 6
 import influx
7 7
 
8
-filter_fact = 0.9
8
+filter_fact = 0.99
9 9
 
10 10
 c_in = 0.6, -30.0, # in_a, in_b
11 11
 calibration = {
@@ -78,6 +78,10 @@ if __name__ == "__main__":
78 78
 
79 79
             try:
80 80
                 influx.write("brightness,location=pc-back", "lux", brightness)
81
+
82
+                for d in disps:
83
+                    name = '_'.join(d["name"].split())
84
+                    influx.write("brightness,location=" + name, "backlight", d["prev"])
81 85
             except:
82 86
                 pass
83 87
 
@@ -88,13 +92,9 @@ if __name__ == "__main__":
88 92
             for d in disps:
89 93
                 val = lux_to_disp(d["name"], brightness)
90 94
                 if val != d["prev"]:
91
-                    d["prev"] = val
92
-                    print("{}: Setting \"{}\" to {}".format(time.ctime(), d["name"], val))
93
-                    ddc.ddc_set(d["_id"], val)
94
-
95 95
                     try:
96
-                        name = '_'.join(d["name"].split())
97
-                        influx.write("brightness,location=" + name, "backlight", val)
98
-                    except:
99
-                        pass
100
-
96
+                        print("{}: Setting \"{}\" to {}".format(time.ctime(), d["name"], val))
97
+                        ddc.ddc_set(d["_id"], val)
98
+                        d["prev"] = val
99
+                    except Exception as e:
100
+                        print(e)

Загрузка…
Отмена
Сохранить