Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,13 +6,12 @@ device_state = {
|
|
| 6 |
"heater": False,
|
| 7 |
"dehumidifier": False,
|
| 8 |
"humidifier": False,
|
| 9 |
-
"window": "closed"
|
| 10 |
}
|
| 11 |
|
| 12 |
def climate_control(temperature, humidity):
|
| 13 |
messages = []
|
| 14 |
|
| 15 |
-
# AC na Heater control
|
| 16 |
if temperature > 25:
|
| 17 |
messages.append("⚠️ Ubushyuhe buri hejuru, turakoresha AC.")
|
| 18 |
device_state["ac"] = True
|
|
@@ -26,7 +25,6 @@ def climate_control(temperature, humidity):
|
|
| 26 |
device_state["ac"] = False
|
| 27 |
device_state["heater"] = False
|
| 28 |
|
| 29 |
-
# Fan na Humidity control
|
| 30 |
if humidity < 30:
|
| 31 |
messages.append("⚠️ Umuyaga uri hasi, tuzongera fan na Humidifier.")
|
| 32 |
device_state["fan"] = True
|
|
@@ -43,7 +41,6 @@ def climate_control(temperature, humidity):
|
|
| 43 |
device_state["humidifier"] = False
|
| 44 |
device_state["dehumidifier"] = False
|
| 45 |
|
| 46 |
-
# Window control (funga amadirishya niba ubushyuhe cyangwa umuyaga uri hanze bidahuye)
|
| 47 |
if temperature > 28 or humidity > 65:
|
| 48 |
device_state["window"] = "closed"
|
| 49 |
messages.append("❌ Amadirishya yafunzwe kubera ubushyuhe cyangwa umuyaga uri hejuru.")
|
|
@@ -51,7 +48,6 @@ def climate_control(temperature, humidity):
|
|
| 51 |
device_state["window"] = "open"
|
| 52 |
messages.append("✅ Amadirishya yafunguwe.")
|
| 53 |
|
| 54 |
-
# Status y'ibikoresho byose
|
| 55 |
for device in ["ac", "heater", "fan", "humidifier", "dehumidifier"]:
|
| 56 |
status = "ON" if device_state[device] else "OFF"
|
| 57 |
messages.append(f"ℹ️ {device.capitalize()} status: {status}")
|
|
@@ -63,20 +59,4 @@ with gr.Blocks() as demo:
|
|
| 63 |
gr.Markdown("## Climate Control System - Igenzura ry'Ubushyuhe, Umuyaga, na Windows")
|
| 64 |
|
| 65 |
temperature = gr.Slider(0, 50, step=1, label="Ubushyuhe (°C)", value=22)
|
| 66 |
-
humidity = gr.Slider(0, 100, step=1, label="Humidity (%)",
|
| 67 |
-
|
| 68 |
-
submit_btn = gr.Button("Ohereza / Submit")
|
| 69 |
-
|
| 70 |
-
output = gr.Textbox(label="Ibisubizo bya System", lines=12)
|
| 71 |
-
|
| 72 |
-
# Iyo uhinduye slider, ibisubizo bihita byerekanwa
|
| 73 |
-
temperature.change(fn=climate_control, inputs=[temperature, humidity], outputs=output)
|
| 74 |
-
humidity.change(fn=climate_control, inputs=[temperature, humidity], outputs=output)
|
| 75 |
-
|
| 76 |
-
# N'igihe ukanda submit button, na byo byerekana ibisubizo
|
| 77 |
-
submit_btn.click(fn=climate_control, inputs=[temperature, humidity], outputs=output)
|
| 78 |
-
|
| 79 |
-
# Igaragaza status ya mbere ku ifunguro
|
| 80 |
-
output.value = climate_control(temperature.value, humidity.value)
|
| 81 |
-
|
| 82 |
-
demo.launch()
|
|
|
|
| 6 |
"heater": False,
|
| 7 |
"dehumidifier": False,
|
| 8 |
"humidifier": False,
|
| 9 |
+
"window": "closed"
|
| 10 |
}
|
| 11 |
|
| 12 |
def climate_control(temperature, humidity):
|
| 13 |
messages = []
|
| 14 |
|
|
|
|
| 15 |
if temperature > 25:
|
| 16 |
messages.append("⚠️ Ubushyuhe buri hejuru, turakoresha AC.")
|
| 17 |
device_state["ac"] = True
|
|
|
|
| 25 |
device_state["ac"] = False
|
| 26 |
device_state["heater"] = False
|
| 27 |
|
|
|
|
| 28 |
if humidity < 30:
|
| 29 |
messages.append("⚠️ Umuyaga uri hasi, tuzongera fan na Humidifier.")
|
| 30 |
device_state["fan"] = True
|
|
|
|
| 41 |
device_state["humidifier"] = False
|
| 42 |
device_state["dehumidifier"] = False
|
| 43 |
|
|
|
|
| 44 |
if temperature > 28 or humidity > 65:
|
| 45 |
device_state["window"] = "closed"
|
| 46 |
messages.append("❌ Amadirishya yafunzwe kubera ubushyuhe cyangwa umuyaga uri hejuru.")
|
|
|
|
| 48 |
device_state["window"] = "open"
|
| 49 |
messages.append("✅ Amadirishya yafunguwe.")
|
| 50 |
|
|
|
|
| 51 |
for device in ["ac", "heater", "fan", "humidifier", "dehumidifier"]:
|
| 52 |
status = "ON" if device_state[device] else "OFF"
|
| 53 |
messages.append(f"ℹ️ {device.capitalize()} status: {status}")
|
|
|
|
| 59 |
gr.Markdown("## Climate Control System - Igenzura ry'Ubushyuhe, Umuyaga, na Windows")
|
| 60 |
|
| 61 |
temperature = gr.Slider(0, 50, step=1, label="Ubushyuhe (°C)", value=22)
|
| 62 |
+
humidity = gr.Slider(0, 100, step=1, label="Humidity (%)", valu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|