Skip to content

Commit

Permalink
Fix pH environmentpart #145
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Apr 27, 2018
1 parent 3b81965 commit 82ea871
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions terrariumEnvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def __update_environment_state(self):
self.heater['temperature'] = self.get_average_temperature(self.heater['sensors'])
self.cooler['temperature'] = self.get_average_temperature(self.cooler['sensors'])
self.watertank['distance'] = self.get_average_distance(self.watertank['sensors'])
self.moisture['moisture'] = self.get_average_moisture(self.moisture['sensors'])
self.ph['distance'] = self.get_average_ph(self.ph['sensors'])
self.moisture['moisture'] = self.get_average_moisture(self.moisture['sensors'])
self.ph['ph'] = self.get_average_ph(self.ph['sensors'])

def __engine_loop(self):
logger.info('Starting engine')
Expand Down Expand Up @@ -678,14 +678,14 @@ def __engine_loop(self):
# Only on when the lights are off. Or when explicit enabled during the day.
if self.ph['day_enabled'] or self.is_light_off():
# On based on the average temperature values of the used sensors
if self.ph['temperature']['current'] < self.ph['temperature']['alarm_min']:
if self.ph['ph']['current'] < self.ph['ph']['alarm_min']:
toggle_on = True
extra_logging_message = 'Ph value %f%% is lower then alarm %f%%.' % (self.ph['temperature']['current'],
self.ph['temperature']['alarm_min'])
elif self.ph['temperature']['current'] > self.ph['temperature']['alarm_max']:
extra_logging_message = 'Ph value %f%% is lower then alarm %f%%.' % (self.ph['ph']['current'],
self.ph['ph']['alarm_min'])
elif self.ph['ph']['current'] > self.ph['ph']['alarm_max']:
toggle_on = False
extra_logging_message = 'Ph value %f%% is higher then alarm %f%%.' % (self.ph['temperature']['current'],
self.ph['temperature']['alarm_max'])
extra_logging_message = 'Ph value %f%% is higher then alarm %f%%.' % (self.ph['ph']['current'],
self.ph['ph']['alarm_max'])
else:
# Force off when lights are on!
if self.is_ph_on():
Expand All @@ -703,14 +703,14 @@ def __engine_loop(self):
# Reset toggle based on the extra available sensors
toggle_on = None
# Use the extra added sensors for finetuning the trigger action
if self.ph['temperature']['current'] < self.ph['temperature']['alarm_min']:
if self.ph['ph']['current'] < self.ph['ph']['alarm_min']:
toggle_on = True
extra_logging_message = 'Ph value %f%% is lower then alarm %f%%.' % (self.ph['temperature']['current'],
self.ph['temperature']['alarm_min'])
elif self.ph['temperature']['current'] > self.ph['temperature']['alarm_max']:
extra_logging_message = 'Ph value %f%% is lower then alarm %f%%.' % (self.ph['ph']['current'],
self.ph['ph']['alarm_min'])
elif self.ph['ph']['current'] > self.ph['ph']['alarm_max']:
toggle_on = False
extra_logging_message = 'Ph value %f%% is higher then alarm %f%%.' % (self.ph['temperature']['current'],
self.ph['temperature']['alarm_max'])
extra_logging_message = 'Ph value %f%% is higher then alarm %f%%.' % (self.ph['ph']['current'],
self.ph['ph']['alarm_max'])

if toggle_on is True:
if not self.is_ph_on():
Expand Down

0 comments on commit 82ea871

Please sign in to comment.