def handle_control(self, terrarium): if self.action is None: self.action = "heating" KarniLogger().log_info("Getting terrarium data...") sht21 = TerrariumHelper().get_sht21_sensor(terrarium) print sht21 temperature = int(sht21.read_temperature()) print temperature # terra_data = TerrariumHelper().GetCurrentTerrariumData() KarniLogger().log_info("Accessing heater...") heater = TerrariumHelper().get_heater(terrarium) # if heater is available if heater is not None: KarniLogger().log_info("Terrarium: {0} C".format(int(temperature))) KarniLogger().log_info("Ziel-Temperatur: {0} C".format(int(terrarium.temperature_max))) KarniLogger().log_info("Action is '{0}'".format(self.action)) if int(temperature) < int(terrarium.temperature_min): self.action = "heating" heater.on() KarniLogger().log_info("Heating...") elif (int(temperature) <= int(terrarium.temperature_max)) & (self.action == "heating"): heater.on() elif (int(temperature) <= int(terrarium.temperature_max)) & (self.action == "cool down"): heater.off() elif int(temperature) > int(terrarium.temperature_max): self.action = "cool down" heater.off() KarniLogger().log_info("Cooling down...") else: KarniLogger().log_info("Don't know what to do...")
def handle_control(self, terrarium): if self.action is None: self.action = "heating" KarniLogger().log_info("Getting terrarium data...") sht21 = TerrariumHelper().get_sht21_sensor(terrarium) print sht21 temperature = int(sht21.read_temperature()) print temperature # terra_data = TerrariumHelper().GetCurrentTerrariumData() KarniLogger().log_info("Accessing heater...") heater = TerrariumHelper().get_heater(terrarium) # if heater is available if heater is not None: KarniLogger().log_info("Terrarium: {0} C".format(int(temperature))) KarniLogger().log_info("Ziel-Temperatur: {0} C".format( int(terrarium.temperature_max))) KarniLogger().log_info("Action is '{0}'".format(self.action)) if int(temperature) < int(terrarium.temperature_min): self.action = "heating" heater.on() KarniLogger().log_info("Heating...") elif (int(temperature) <= int( terrarium.temperature_max)) & (self.action == "heating"): heater.on() elif (int(temperature) <= int( terrarium.temperature_max)) & (self.action == "cool down"): heater.off() elif int(temperature) > int(terrarium.temperature_max): self.action = "cool down" heater.off() KarniLogger().log_info("Cooling down...") else: KarniLogger().log_info("Don't know what to do...")