aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--on_battery.py32
-rw-r--r--requirements.txt3
-rwxr-xr-xupsmart.jpgbin0 -> 65505 bytes
3 files changed, 34 insertions, 1 deletions
diff --git a/on_battery.py b/on_battery.py
new file mode 100644
index 0000000..6ea5e09
--- /dev/null
+++ b/on_battery.py
@@ -0,0 +1,32 @@
+from influxdb_client import InfluxDBClient, Point, WritePrecision
+from influxdb_client.client.write_api import SYNCHRONOUS
+import dotenv
+import os
+
+def main():
+ influxc = InfluxDBClient(
+ url = "http://%s:8086" % INFLUXDB_HOST,
+ token = os.environ["DOCKER_INFLUXDB_INIT_ADMIN_TOKEN"],
+ org = os.environ["DOCKER_INFLUXDB_INIT_ORG"]
+ )
+ influxc.ping()
+
+ write_api = influxc.write_api(write_options = SYNCHRONOUS)
+ write_api.write(
+ os.environ["DOCKER_INFLUXDB_INIT_BUCKET"],
+ os.environ["DOCKER_INFLUXDB_INIT_ORG"],
+ [{
+ "measurement": "ups_status",
+ "fields": {"on_battery": 1}
+ }],
+ write_precision = WritePrecision.S
+ )
+
+if __name__ == "__main__":
+ env_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.env")
+ if os.path.exists(env_path):
+ import dotenv
+ dotenv.load_dotenv(dotenv_path = env_path)
+ INFLUXDB_HOST = "192.168.69.5"
+
+ main()
diff --git a/requirements.txt b/requirements.txt
index 7efe2a9..a614f08 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
pyautogui
-pygetwindow \ No newline at end of file
+opencv-python
+
diff --git a/upsmart.jpg b/upsmart.jpg
new file mode 100755
index 0000000..c3d2f71
--- /dev/null
+++ b/upsmart.jpg
Binary files differ