diff --git a/CS_499_backend.py b/CS_499_backend.py index e23b21ed8f9a987f255ba750b8bedbfbb67ded72..e12472d1013f67af8d9930a09b5f6ccaab2a149b 100644 --- a/CS_499_backend.py +++ b/CS_499_backend.py @@ -25,24 +25,24 @@ time_stamp=0 for i in range(0,NUM_WEEKS): for j in range(0,7): #door_opens = 0 - #window_opens = 0 + # window_opens=0 if j < 5: door_opens = random.randint(14,22) window_open= random.randint(1,5) else: door_opens = random.randint(26,36) window_open= random.randint(7,12) - door_minutes = door_opens *30/60 + door_minutes = door_opens*30/60 window_minutes = window_open *45/60 Door_Window_History[time_stamp] = Door_Window(WORKWEEK[j], door_opens, door_minutes, window_open, window_minutes) time_stamp += 1 for i in Door_Window_History: - print(i, Door_Window_History[i].day, Door_Window_History[i].Door_status, Door_Window_History[i].Door_time, Door_Window_History[i].Window_status, Door_Window_History[i].Window_time) + print(i,Door_Window_History[i].day,Door_Window_History[i].Door_status,Door_Window_History[i].Door_time,Door_Window_History[i].Window_status,Door_Window_History[i].Window_time) class Appliance_1: - def __init__(self,day,micro_pwr,stove_pwr,oven_pwr,Lrtv_pwr,Brtv_pwr,fridge_pwr,lights_pwr,micro_ct,stove_ct,oven_ct,Lrtv_ct,Brtv_ct,fridge_ct,lights_ct): + def __init__(self,day,micro_pwr,stove_pwr,oven_pwr,Lrtv_pwr,Brtv_pwr,fridge_pwr,lights_pwr,micro_ct,stove_ct,oven_ct,Lrtv_ct,Brtv_ct,fridge_ct,lights_ct,test_case_pwr,test_case_2pwr,test_case_1_ct,test_case_2_ct): self.day=day self.micro_pwr=micro_pwr self.stove_pwr=stove_pwr @@ -58,11 +58,15 @@ class Appliance_1: self.fridge_ct=fridge_ct self.lights_pwr=lights_pwr self.lights_ct=lights_ct + self.test_case_pwr=test_case_pwr + self.test_case_2pwr=test_case_2pwr + self.test_case_1_ct=test_case_1_ct + self.test_case_2_ct=test_case_2_ct App1_History=dict() time_stamp2=1 Fridge=0 -for i in range(0, NUM_WEEKS): +for i in range(0,NUM_WEEKS): for j in range(0,7): Fridge += 1440 if j<5: @@ -81,6 +85,9 @@ for i in range(0, NUM_WEEKS): lights=random.randint(55,95) #Watts Ussage + Watts_testcase_1=((BedroomTV+480)/60)*100 + Watts_testcase_2=((Living_roomTV+360)/60)*100 + Watts_micro=(Microwave/60)*1100 Watts_stove=(Stove/60)*3500 Watts_oven=(Oven/60)*4000/60 @@ -88,7 +95,11 @@ for i in range(0, NUM_WEEKS): Watts_Brtv=(BedroomTV/60)*100 Watts_Fridge=(Fridge/60)*150 Watts_Lights=(lights*random.randint(4,8)) + #Cost Calculations + Cost_testcase_1=(((Watts_testcase_1)/1000)*0.12)/100 + Cost_testcase_2=(((Watts_testcase_2)/1000)*0.12)/100 + Cost_micro=((Watts_micro/1000)*0.12)/100 Cost_stove=((Watts_stove/1000)*0.12)/100 Cost_oven=((Watts_oven/1000)*0.12)/100 @@ -96,7 +107,7 @@ for i in range(0, NUM_WEEKS): Cost_Brtv=((Watts_Brtv/1000)*0.12)/100 Cost_Fridge=((Watts_Fridge/1000)*0.12)/100 Cost_lights=((Watts_Lights/1000)*0.12 )/100 - App1_History[time_stamp2] = Appliance_1(WORKWEEK[j],Watts_micro,Watts_stove,Watts_oven,Watts_Lrtv,Watts_Brtv,Watts_Fridge,Watts_Lights,Cost_micro,Cost_stove,Cost_oven,Cost_Lrtv,Cost_Brtv,Cost_Fridge,Cost_lights) + App1_History[time_stamp2] = Appliance_1(WORKWEEK[j],Watts_micro,Watts_stove,Watts_oven,Watts_Lrtv,Watts_Brtv,Watts_Fridge,Watts_Lights,Cost_micro,Cost_stove,Cost_oven,Cost_Lrtv,Cost_Brtv,Cost_Fridge,Cost_lights,Watts_testcase_1,Watts_testcase_2,Cost_testcase_1,Cost_testcase_2) time_stamp2 += 1 monthly_cost1_JAN=0 @@ -105,6 +116,10 @@ monthly_cost1_FEB=0 monthly_power1_FEB=0 monthly_cost1_MAR=0 monthly_power1_MAR=0 +TC_pwr_MAR_lrtv=0 +TC_pwr_MAR_brtv=0 +TC_ct_MAR_lrtv=0 +TC_ct_MAR_brtv=0 print("###################################################### TOTAL APP1 HISTORY FOR 77 DAYS ###################################################### \n") for i in App1_History: @@ -117,23 +132,31 @@ for i in App1_History: if i>61: monthly_power1_MAR += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr monthly_cost1_MAR += App1_History[i].micro_ct + App1_History[i].stove_ct + App1_History[i].oven_ct + App1_History[i].Lrtv_ct + App1_History[i].Brtv_ct + App1_History[i].fridge_ct + App1_History[i].lights_ct + TC_pwr_MAR_lrtv += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr + App1_History[i].test_case_pwr + TC_pwr_MAR_brtv += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr + App1_History[i].test_case_2pwr + TC_ct_MAR_lrtv += App1_History[i].micro_ct + App1_History[i].stove_ct + App1_History[i].oven_ct + App1_History[i].Lrtv_ct + App1_History[i].Brtv_ct + App1_History[i].fridge_ct + App1_History[i].lights_ct + App1_History[i].test_case_1_ct + TC_ct_MAR_brtv += App1_History[i].micro_ct + App1_History[i].stove_ct + App1_History[i].oven_ct + App1_History[i].Lrtv_ct + App1_History[i].Brtv_ct + App1_History[i].fridge_ct + App1_History[i].lights_ct + App1_History[i].test_case_2_ct #print(i,App1_History[i].day,App1_History[i].micro_pwr,App1_History[i].stove_pwr,App1_History[i].oven_pwr,App1_History[i].Lrtv_pwr,App1_History[i].Brtv_pwr,App1_History[i].micro_ct,App1_History[i].stove_ct,App1_History[i].oven_ct,App1_History[i].Lrtv_ct,App1_History[i].Brtv_ct) print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") print( "Jan APP1 watts used : ",monthly_power1_JAN ) print( "FEB APP1 watts used : ",monthly_power1_FEB ) print( "MAR APP1 watts used : ",monthly_power1_MAR ) +print( "Test power cost March Living room TV : " ,TC_pwr_MAR_lrtv) +print( "Test power cost March Living room TV : " ,TC_pwr_MAR_brtv) print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") print( "Jan APP1 cost used : ",monthly_cost1_JAN ) print( "FEB APP1 cost used : ",monthly_cost1_FEB ) print( "MAR APP1 cost used : ",monthly_cost1_MAR ) -#print("################################################################################################################################################################# \n") +print( "Test case cost March Living room TV : " ,TC_ct_MAR_lrtv) +print( "Test case cost March Living room TV : " ,TC_ct_MAR_brtv) +#print( "################################################################################################################################################################# \n") class Appliance_with_Water: - def __init__(self,day,Water_Heat_pwr,DishWasher_pwr,Clothes_Wash_pwr,Clothes_dry_pwr,bath_fans_pwr,Water_Heat_ug,Bath_water_ug,Shower_water_ug,DishWasher_ug,Clothes_Wash_ug,Water_Heat_ct,DishWasher_ct,Clothes_Wash_ct,Clothes_dry_ct,bath_fans_ct,Water_ct,bath,shower): + def __init__(self,day,Water_Heat_pwr,DishWasher_pwr,Clothes_Wash_pwr,Clothes_dry_pwr,bath_fans_pwr,Water_Heat_ug,Bath_water_ug,Shower_water_ug,DishWasher_ug,Clothes_Wash_ug,Water_Heat_ct,DishWasher_ct,Clothes_Wash_ct,Clothes_dry_ct,bath_fans_ct,Water_ct,bath,shower,test_case_shower_ug,test_case_shower_pwr,test_case_shower_ct,test_case_heater_ct): self.day=day self.Water_Heat_pwr=Water_Heat_pwr self.DishWasher_pwr=DishWasher_pwr @@ -153,6 +176,10 @@ class Appliance_with_Water: self.Water_ct=Water_ct self.bath=bath self.shower=shower + self.test_case_shower_ug=test_case_shower_ug + self.test_case_shower_pwr=test_case_shower_pwr + self.test_case_shower_ct=test_case_shower_ct + self.test_case_heater_ct= test_case_heater_ct App2_History=dict() time_stamp3=0 @@ -173,35 +200,57 @@ for i in range(0,NUM_WEEKS): Clths_water=20*Clths_wash_dry_run Dish_washer_water=6*Dish_washer_run + test_water=10 + + + + # still have to apply floor to it ## hot water + test_hot_water=math.ceil(test_water*0.65) + Bath_hot=math.ceil(Bath_water*0.65) Shower_hot=math.ceil(Shower_water*0.65) Clths_wash_hot=math.ceil(Clths_water*0.85) # hot water heater ## use ceil round up Hot_water=(Bath_hot+Shower_hot+Clths_wash_hot) Hot_water_time=Hot_water*4 + test_time_1=(Bath_hot+Shower_hot+Clths_wash_hot+test_hot_water) + test_time=test_time_1*4 # Watts used + + Hot_water_pwr=(Hot_water_time/60)*4500 Dish_washer_pwr=((Dish_washer_run*45)/60)*1800 Clothes_wash_pwr=((Clths_wash_dry_run*30)/60)*500 Clothes_dry_pwr=((Clths_wash_dry_run*30)/60)*3000 Bath_Fans_pwr=((Bath*45)/60)*30 + test_hot_water_pwr=(test_time/60)*4500 + + # Cost + + Hot_water_ct=((Hot_water_pwr/1000)*0.12)/100 Dish_washer_ct=((Dish_washer_pwr/1000)*0.12)/100 Clothes_wash_ct=((Clothes_wash_pwr/1000)*0.12)/100 Clothes_dry_ct=((Clothes_dry_pwr/1000)*0.12)/100 Bath_Fans_ct=((Bath_Fans_pwr/1000)*0.12)/100 + test_hot_ct=(((test_hot_water_pwr)/1000)*0.12)/100 + # Water Used / Cost + test_case_total_ug=Bath_water+Shower_water+Clths_water+Dish_washer_water + test_case_feet=test_case_total_ug/7.48 + test_case_cost=test_case_feet*(2.52/100) + Water_Total=Bath_water+Shower_water+Clths_water+Dish_washer_water Water_Feet=Water_Total/7.48 Water_cost=Water_Feet*(2.52/100) - # Water_Heat_pwr, DishWasher_pwr, Clothes_Wash_pwr, Clothes_dry_pwr, bath_fan_pwr, Water_Heat_ug, DishWasher_ug, Clothes_Wash_ug, Water_Heat_ct, DishWasher_ct, Clothes_Wash_ct, Clothes_dry_ct, bath_fan_ct, bath, shower - App2_History[time_stamp3] = Appliance_with_Water(WORKWEEK[j],Hot_water_pwr,Dish_washer_pwr,Clothes_wash_pwr,Clothes_dry_pwr,Bath_Fans_pwr,Hot_water,Bath_water,Shower_water,Dish_washer_water,Clths_water,Hot_water_ct,Dish_washer_ct,Clothes_wash_ct,Clothes_dry_ct,Bath_Fans_ct,Water_cost,Bath,Shower) - time_stamp3 += 1 + #Water_Heat_pwr,DishWasher_pwr,Clothes_Wash_pwr,Clothes_dry_pwr,bath_fan_pwr,Water_Heat_ug,DishWasher_ug,Clothes_Wash_ug,Water_Heat_ct,DishWasher_ct,Clothes_Wash_ct,Clothes_dry_ct,bath_fan_ct,bath,shower + App2_History[time_stamp3] = Appliance_with_Water(WORKWEEK[j],Hot_water_pwr,Dish_washer_pwr,Clothes_wash_pwr,Clothes_dry_pwr,Bath_Fans_pwr,Hot_water,Bath_water,Shower_water,Dish_washer_water,Clths_water,Hot_water_ct,Dish_washer_ct,Clothes_wash_ct,Clothes_dry_ct,Bath_Fans_ct,Water_cost,Bath,Shower,test_water, test_hot_water_pwr ,test_case_cost,test_hot_ct) + time_stamp3+=1 monthly_cost2_JAN=0 monthly_power2_JAN=0 @@ -212,6 +261,9 @@ monthly_water_usg_FEB=0 monthly_cost2_MAR=0 monthly_power2_MAR=0 monthly_water_usg_MAR=0 +TC_shower_cost2_MAR=0 +TC_shower_power2_MAR=0 +TC_shower_water_usg_MAR=0 print("###################################################### TOTAL APP2 HISTORY FOR 77 DAYS ###################################################### \n") for i in App2_History: if i>=31: @@ -226,27 +278,33 @@ for i in App2_History: monthly_cost2_MAR+= App2_History[i].Water_Heat_ct + App2_History[i].DishWasher_ct + App2_History[i].Clothes_Wash_ct + App2_History[i].Clothes_dry_ct +App2_History[i].Water_ct + App2_History[i].bath_fans_ct monthly_power2_MAR+= App2_History[i].Water_Heat_pwr+ App2_History[i].DishWasher_pwr + App2_History[i].Clothes_Wash_pwr + App2_History[i].Clothes_dry_pwr + App2_History[i].bath_fans_pwr monthly_water_usg_MAR+= App2_History[i].Bath_water_ug + App2_History[i].Shower_water_ug + App2_History[i].DishWasher_ug+ App2_History[i].Clothes_Wash_ug + + TC_shower_cost2_MAR+= App2_History[i].Water_Heat_ct + App2_History[i].DishWasher_ct + App2_History[i].Clothes_Wash_ct + App2_History[i].Clothes_dry_ct + App2_History[i].test_case_shower_ct + App2_History[i].bath_fans_ct+ App2_History[i].test_case_heater_ct + TC_shower_power2_MAR+= App2_History[i].DishWasher_pwr + App2_History[i].Clothes_Wash_pwr + App2_History[i].Clothes_dry_pwr + App2_History[i].bath_fans_pwr+ App2_History[i].test_case_shower_pwr + TC_shower_water_usg_MAR+= App2_History[i].Bath_water_ug + App2_History[i].Shower_water_ug + App2_History[i].DishWasher_ug+ App2_History[i].Clothes_Wash_ug+App2_History[i].test_case_shower_ug #print(i,App2_History[i].day,App2_History[i].Water_Heat_pwr,App2_History[i].DishWasher_pwr,App2_History[i].Clothes_Wash_pwr,App2_History[i].Clothes_dry_pwr,App2_History[i].bath_fans_pwr,App2_History[i].Water_Heat_ug,App2_History[i].Bath_water_ug,App2_History[i].Shower_water_ug,App2_History[i].DishWasher_ug,App2_History[i].Clothes_Wash_ug,App2_History[i].Water_Heat_ct,App2_History[i].DishWasher_ct,App2_History[i].Clothes_Wash_ct,App2_History[i].Clothes_dry_ct,App2_History[i].bath_fans_ct,App2_History[i].Water_ct,App2_History[i].bath,App2_History[i].shower) print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") -print( "Jan APP2 watts used : ",monthly_power2_JAN ) -print( "FEB APP2 watts used : ",monthly_power2_FEB ) -print( "MAR APP2 watts used : ",monthly_power2_MAR ) +print( "Jan APP1 watts used : ",monthly_power2_JAN ) +print( "FEB APP1 watts used : ",monthly_power2_FEB ) +print( "MAR APP1 watts used : ",monthly_power2_MAR ) +print( " Test case MAR APP1 power used : ", TC_shower_power2_MAR) print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") -print( "Jan APP2 cost used : ",monthly_cost2_JAN ) -print( "FEB APP2 cost used : ",monthly_cost2_FEB ) -print( "MAR APP2 cost used : ",monthly_cost2_MAR ) +print( "Jan APP1 cost used : ",monthly_cost2_JAN ) +print( "FEB APP1 cost used : ",monthly_cost2_FEB ) +print( "MAR APP1 cost used : ",monthly_cost2_MAR ) +print( "Test case MAR APP1 cost used : ", TC_shower_cost2_MAR ) print( "_ - _ - _ - _ Gallons used for each Month _ - _ - _ - _ \n") -print( "Jan APP2 water used : ",monthly_water_usg_JAN ) -print( "FEB APP2 water used : ",monthly_water_usg_FEB ) -print( "MAR APP2 water used : ",monthly_water_usg_MAR ) +print( "Jan APP1 water used : ",monthly_water_usg_JAN ) +print( "FEB APP1 water used : ",monthly_water_usg_FEB ) +print( "MAR APP1 water used : ",monthly_water_usg_MAR ) +print( "Test case MAR APP1 water used : ", TC_shower_water_usg_MAR ) #print( "################################################################################################################################################################# \n") # weather api to get temp from history # Used this to help me understand and gather API.data: https://pypi.org/project/requests/ and https://realpython.com/api-integration-in-python/ - -class Temperature_data : - def __init__(self,temp_power,temp_cost): +class Temprature_data: + def __init__(self,temp_power,temp_cost ): self.temp_power=temp_power self.temp_cost=temp_cost @@ -254,16 +312,18 @@ class Temperature_data : response_API = requests.get("https://archive-api.open-meteo.com/v1/archive?latitude=33.52&longitude=-86.80&start_date=2023-01-01&end_date=2023-03-12&hourly=temperature_2m&timezone=America%2FChicago&temperature_unit=fahrenheit") data = response_API.text -parse_temp = json.loads(data) +parse_temp=json.loads(data) hourly_pull = parse_temp['hourly'] -dict_pull = hourly_pull["temperature_2m"] +dict_pull=hourly_pull["temperature_2m"] -App3_History = dict() -time_stamp4 = 0 + +App3_History=dict() +time_stamp4=0 daily_arr=np.array_split(dict_pull,77) + for i in range(0,len(daily_arr)): daily_arr[i] d_t=Door_Window_History[i].Door_time @@ -284,10 +344,10 @@ for i in range(0,len(daily_arr)): min_op=sum*60+(d_t+w_t) watts_per_day=(min_op)*3500 ct_per_day=((watts_per_day/1000)*0.12)/100 - App3_History[time_stamp4]=Temperature_data (watts_per_day,ct_per_day) + App3_History[time_stamp4]=Temprature_data(watts_per_day,ct_per_day) time_stamp4+=1 - # print(ct_per_day) - # print(watts_per_day) + #print(ct_per_day) + #print(watts_per_day) # print("what i is",i) # print("timestamp",i) @@ -311,13 +371,13 @@ for i in App3_History: monthly_temp_ct_MAR+=App3_History[i].temp_cost monthly_temp_watts_MAR+=App3_History[i].temp_power print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n") -print( "Jan APP3 watts used : ",monthly_temp_watts_JAN ) -print( "FEB APP3 watts used : ",monthly_temp_watts_FEB ) -print( "MAR APP3 watts used : ",monthly_temp_watts_MAR ) +print( "Jan APP1 watts used : ",monthly_temp_watts_JAN ) +print( "FEB APP1 watts used : ",monthly_temp_watts_FEB ) +print( "MAR APP1 watts used : ",monthly_temp_watts_MAR ) print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n") -print( "Jan APP3 cost used : ",monthly_temp_ct_JAN ) -print( "FEB APP3 cost used : ",monthly_temp_ct_FEB ) -print( "MAR APP3 cost used : ",monthly_temp_ct_MAR ) +print( "Jan APP1 cost used : ",monthly_temp_ct_JAN ) +print( "FEB APP1 cost used : ",monthly_temp_ct_FEB ) +print( "MAR APP1 cost used : ",monthly_temp_ct_MAR ) print( "################################################################################################################################################################# \n") print("January Total cost",monthly_temp_ct_JAN+monthly_cost2_JAN+monthly_cost1_JAN) print("Febuary Total cost",monthly_temp_ct_FEB+monthly_cost2_FEB+monthly_cost1_FEB)