init
This commit is contained in:
		
							
								
								
									
										1
									
								
								.env
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.env
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
HASSIO_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI4NmNhOTc4YmRmZTY0OWRkOGMyMjBjNGQ5Mjg0ZWY1MCIsImlhdCI6MTc1Nzg0NjgyNSwiZXhwIjoyMDczMjA2ODI1fQ.VDtSlZoOxbxiWv-Rlc8DF5DCrfdcwOmu15y9WXEuv40"
 | 
			
		||||
							
								
								
									
										39
									
								
								main.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								main.py
									
									
									
									
									
										Normal file
									
								
							@@ -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()
 | 
			
		||||
		Reference in New Issue
	
	Block a user