commit 7dcbb55855415c0994721ce5b516286497911622 Author: Mihit Date: Sun Sep 14 16:59:45 2025 +0530 init diff --git a/.env b/.env new file mode 100644 index 0000000..c81e722 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +HASSIO_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI4NmNhOTc4YmRmZTY0OWRkOGMyMjBjNGQ5Mjg0ZWY1MCIsImlhdCI6MTc1Nzg0NjgyNSwiZXhwIjoyMDczMjA2ODI1fQ.VDtSlZoOxbxiWv-Rlc8DF5DCrfdcwOmu15y9WXEuv40" \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..d1bdf02 --- /dev/null +++ b/main.py @@ -0,0 +1,39 @@ +import requests +from dotenv import load_dotenv +import os +import argparse + +load_dotenv() + +token = os.getenv("HASSIO_TOKEN") + +headers = { + "Authorization": f"Bearer {token}", + "content-type": "application/json" +} + +def toggle(): + requests.post("https://home.fieryeagle.org/api/services/climate/toggle", headers=headers, json={"entity_id": "climate.airconditioner"}) + +def reduce(): + requests.post("https://home.fieryeagle.org/api/services/script/ac_temp_down", headers=headers) + +def increase(): + requests.post("https://home.fieryeagle.org/api/services/script/ac_temp_up", headers=headers) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Control AC via Home Assistant") + parser.add_argument("--up", action="store_true", help="Increase temperature") + parser.add_argument("--down", action="store_true", help="Reduce temperature") + parser.add_argument("--toggle", action="store_true", help="Toggle AC on/off") + + args = parser.parse_args() + + if args.up: + increase() + elif args.down: + reduce() + elif args.toggle: + toggle() + else: + parser.print_help() \ No newline at end of file