This commit is contained in:
2026-04-17 01:18:02 +05:30
commit f83d4a4877
3 changed files with 33 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env

29
main.py Normal file
View File

@@ -0,0 +1,29 @@
import serial
import requests
import os
from dotenv import load_dotenv
load_dotenv()
ntfy_token = os.environ['NTFY_Token']
shutdown_timer = 10
with serial.Serial('COM10', 115200, timeout=1) as ser:
inverter_offline_counter = 0
while True:
if ser.readline().decode().strip() == "0":
print("Inverter Online")
inverter_offline_counter = 0
elif inverter_offline_counter >= shutdown_timer:
break
else:
inverter_offline_counter += 1
print(f"Running on UPS reserve, offline for {inverter_offline_counter}s")
print(f"Inverter offline for {shutdown_timer} seconds")
requests.post("https://ntfy.fieryeagle.org/Internet-Alerts",
data="Inverter offline, shutting down".encode(encoding='utf-8'),
headers={
"Title": "Hydrogen running on reserve power",
"Authorization": f"Bearer {ntfy_token}"
}
)

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
pyserial
requests
python-dotenv