Smart Home Automation Project
=============================

# smart_home.py
from dataclasses import dataclass, field

MAX_TEMP = 30
MIN_TEMP = 10
SECURITY_ARMED_LABEL = "ARMED"
SECURITY_DISARMED_LABEL = "DISARMED"

@dataclass
class Device:
    name: str
    on: bool = False

    def toggle(self):
        self.on = not self.on

@dataclass
class Thermostat(Device):
    temp: int = 22

    def set_temp(self, new_temp: int):
        if new_temp < MIN_TEMP or new_temp > MAX_TEMP:
            raise ValueError(f"Temperature must be between {MIN_TEMP} and {MAX_TEMP}.")
        self.temp = new_temp

@dataclass
class SecuritySystem:
    armed: bool = False

    def toggle(self):
        self.armed = not self.armed

    def status_label(self):
        return SECURITY_ARMED_LABEL if self.armed else SECURITY_DISARMED_LABEL

def print_menu():
    print("\n--- Smart Home Menu ---")
    print("1) Show system status")
    print("2) Toggle living room light")
    print("3) Toggle kitchen light")
    print("4) Set thermostat temperature")
    print("5) Toggle security system")
    print("0) Exit")

def main():
    living_light = Device("Living Room Light", on=False)
    kitchen_light = Device("Kitchen Light", on=False)
    thermostat = Thermostat("Main Thermostat", temp=22)
    security = SecuritySystem(armed=False)

    while True:
        print_menu()
        choice = input("Choose an option: ").strip()
        if choice == "1":
            print("\n--- System Status ---")
            print(f"{living_light.name}: {'ON' if living_light.on else 'OFF'}")
            print(f"{kitchen_light.name}: {'ON' if kitchen_light.on else 'OFF'}")
            print(f"{thermostat.name}: {thermostat.temp}°C")
            print(f"Security System: {security.status_label()}")
        elif choice == "2":
            living_light.toggle()
            print(f"{living_light.name} is now {'ON' if living_light.on else 'OFF'}.")
        elif choice == "3":
            kitchen_light.toggle()
            print(f"{kitchen_light.name} is now {'ON' if kitchen_light.on else 'OFF'}.")
        elif choice == "4":
            try:
                val = input(f"Enter temperature ({MIN_TEMP}-{MAX_TEMP}): ").strip()
                new_temp = int(val)
                thermostat.set_temp(new_temp)
                print(f"Thermostat set to {thermostat.temp}°C.")
            except ValueError as e:
                print("Invalid temperature:", e)
        elif choice == "5":
            security.toggle()
            print(f"Security System is now {security.status_label()}.")
        elif choice == "0":
            print("Exiting Smart Home. Bye!")
            break
        else:
            print("Invalid option — please choose a valid menu number.")

if __name__ == "__main__":
    main()
