Update
This commit is contained in:
@@ -47,6 +47,8 @@ DETIK_ANTAR_KARUNG = 30
|
|||||||
RELAY_KIRI_ON = "http://192.168.192.26:5001/relay_on"
|
RELAY_KIRI_ON = "http://192.168.192.26:5001/relay_on"
|
||||||
RELAY_KIRI_OFF = "http://192.168.192.26:5001/relay_off"
|
RELAY_KIRI_OFF = "http://192.168.192.26:5001/relay_off"
|
||||||
|
|
||||||
|
RELAY_KANAN_ON = "http://192.168.192.26:5002/relay_on"
|
||||||
|
RELAY_KANAN_OFF = "http://192.168.192.26:5002/relay_off"
|
||||||
|
|
||||||
def init_database():
|
def init_database():
|
||||||
"""Initialize the SQLite database with the required table"""
|
"""Initialize the SQLite database with the required table"""
|
||||||
@@ -166,6 +168,25 @@ def relay_kiri_on():
|
|||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
def relay_kanan_off():
|
||||||
|
global RELAY_KANAN_ON, RELAY_KANAN_OFF
|
||||||
|
try:
|
||||||
|
requests.get(RELAY_KANAN_OFF, timeout=1)
|
||||||
|
print(f"Relay Kanan OFF")
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
|
def relay_kanan_on():
|
||||||
|
global DETIK_ANTAR_KARUNG
|
||||||
|
|
||||||
|
try:
|
||||||
|
requests.get(RELAY_KANAN_ON, timeout=1)
|
||||||
|
threading.Timer(DETIK_ANTAR_KARUNG, relay_kanan_off).start()
|
||||||
|
print(f"Relay Kanan ON -> Start Counter Kanan: {DETIK_ANTAR_KARUNG} seconds")
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
# =====================
|
# =====================
|
||||||
# RESET HARIAN
|
# RESET HARIAN
|
||||||
# =====================
|
# =====================
|
||||||
@@ -335,6 +356,9 @@ def on_message(client, userdata, msg):
|
|||||||
if camera == "kandang_atas_feeder_kiri":
|
if camera == "kandang_atas_feeder_kiri":
|
||||||
relay_kiri_on()
|
relay_kiri_on()
|
||||||
|
|
||||||
|
if camera == "kandang_bawah_feeder_kanan":
|
||||||
|
relay_kanan_on()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error parsing message:", e)
|
print("Error parsing message:", e)
|
||||||
|
|
||||||
@@ -373,6 +397,7 @@ schedule_reset()
|
|||||||
#schedule_reset_masuk()
|
#schedule_reset_masuk()
|
||||||
# Pastikan Relay OFF
|
# Pastikan Relay OFF
|
||||||
relay_kiri_off()
|
relay_kiri_off()
|
||||||
|
relay_kanan_off()
|
||||||
|
|
||||||
client_publish.loop_start()
|
client_publish.loop_start()
|
||||||
print(f"MQTT Publish Counter berjalan di {PUBLISH_BROKER}")
|
print(f"MQTT Publish Counter berjalan di {PUBLISH_BROKER}")
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ DETIK_ANTAR_KARUNG = 30
|
|||||||
RELAY_KIRI_ON = "http://192.168.192.26:5001/relay_on"
|
RELAY_KIRI_ON = "http://192.168.192.26:5001/relay_on"
|
||||||
RELAY_KIRI_OFF = "http://192.168.192.26:5001/relay_off"
|
RELAY_KIRI_OFF = "http://192.168.192.26:5001/relay_off"
|
||||||
|
|
||||||
|
RELAY_KANAN_ON = "http://192.168.192.26:5002/relay_on"
|
||||||
|
RELAY_KANAN_OFF = "http://192.168.192.26:5002/relay_off"
|
||||||
|
|
||||||
def init_database():
|
def init_database():
|
||||||
"""Initialize the SQLite database with the required table"""
|
"""Initialize the SQLite database with the required table"""
|
||||||
@@ -166,6 +168,25 @@ def relay_kiri_on():
|
|||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
def relay_kanan_off():
|
||||||
|
global RELAY_KANAN_ON, RELAY_KANAN_OFF
|
||||||
|
try:
|
||||||
|
requests.get(RELAY_KANAN_OFF, timeout=1)
|
||||||
|
print(f"Relay Kanan OFF")
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
|
def relay_kanan_on():
|
||||||
|
global DETIK_ANTAR_KARUNG
|
||||||
|
|
||||||
|
try:
|
||||||
|
requests.get(RELAY_KANAN_ON, timeout=1)
|
||||||
|
threading.Timer(DETIK_ANTAR_KARUNG, relay_kanan_off).start()
|
||||||
|
print(f"Relay Kanan ON -> Start Counter Kanan: {DETIK_ANTAR_KARUNG} seconds")
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
# =====================
|
# =====================
|
||||||
# RESET HARIAN
|
# RESET HARIAN
|
||||||
# =====================
|
# =====================
|
||||||
@@ -335,6 +356,9 @@ def on_message(client, userdata, msg):
|
|||||||
if camera == "kandang_atas_feeder_kiri":
|
if camera == "kandang_atas_feeder_kiri":
|
||||||
relay_kiri_on()
|
relay_kiri_on()
|
||||||
|
|
||||||
|
if camera == "kandang_bawah_feeder_kanan":
|
||||||
|
relay_kanan_on()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error parsing message:", e)
|
print("Error parsing message:", e)
|
||||||
|
|
||||||
@@ -373,6 +397,7 @@ schedule_reset()
|
|||||||
#schedule_reset_masuk()
|
#schedule_reset_masuk()
|
||||||
# Pastikan Relay OFF
|
# Pastikan Relay OFF
|
||||||
relay_kiri_off()
|
relay_kiri_off()
|
||||||
|
relay_kanan_off()
|
||||||
|
|
||||||
client_publish.loop_start()
|
client_publish.loop_start()
|
||||||
print(f"MQTT Publish Counter berjalan di {PUBLISH_BROKER}")
|
print(f"MQTT Publish Counter berjalan di {PUBLISH_BROKER}")
|
||||||
|
|||||||
Binary file not shown.
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"kandang_atas_feeder_kiri": {
|
"kandang_atas_feeder_kiri": {
|
||||||
"karung": 0
|
"karung": 25
|
||||||
},
|
},
|
||||||
"kandang_bawah_feeder_kanan": {
|
"kandang_bawah_feeder_kanan": {
|
||||||
"karung": 0
|
"karung": 40
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user