Пример #1
0
    def set_weather_config(self, data):
        try:
            self.weather = terrariumWeather(data['location'],
                                            self.get_temperature_indicator,
                                            self.get_windspeed_indicator,
                                            self.get_weather)
        except terrariumWeatherSourceException as ex:
            return False

        return self.config.save_weather(data)
Пример #2
0
  def __init__(self):
    # List of queues for websocket communication
    self.subscribed_queues = []
    # Default power usage for a PI
    self.pi_power_wattage = 5

    self.switch_board = None #TODO: Fix proper
    self.environment = None

    # Load config
    self.config = terrariumConfig()
    self.set_authentication(self.config.get_admin(),self.config.get_password())

    # Load data collector for historical data
    self.collector = terrariumCollector()

    # Set the Pi power usage (including usb devices directly on the PI)
    self.pi_power_wattage = float(self.config.get_pi_power_wattage())

    # Load Weather part
    self.weather = terrariumWeather(self.config.get_weather_location(),
                                    self.config.get_weather_windspeed(),
                                    self.config.get_weather_temperature(),
                                    self.get_weather)

    # Load Powerswitches part
    self.power_switches = {}
    self.switch_board = terrariumSwitchboard(self.config,self.toggle_switch)
    self.power_switches = self.switch_board.switches

    # Load Door part
    self.door_sensor = terrariumDoor(self.config.get_door_pin(),self.door_status)

    # Load Sensors, with ID as index
    self.sensors = {}
    for sensor in terrariumSensor.scan(self.config.get_1wire_port(), self.config.get_sensors()):
      self.sensors[sensor.get_id()] = sensor

    # Load the environment system. This will controll the lights, sprayer and heaters
    self.environment = terrariumEnvironment(self.sensors, self.power_switches, self.door_sensor, self.weather, self.config)

    # Load webcams from config
    self.webcams = {}
    webcams = self.config.get_webcams()
    for webcamid in webcams:
      self.webcams[webcams[webcamid]['id']] = terrariumWebcam(webcams[webcamid]['id'],webcams[webcamid]['location'],webcams[webcamid]['name'],webcams[webcamid]['rotation'])

    # Start system update loop
    thread.start_new_thread(self.__engine_loop, ())
Пример #3
0
  def __init__(self):

    # Default system units
    self.__units = {'temperature' : 'C',
                    'distance'    : 'cm',
                    'humidity'    : '%',
                    'moisture'    : '%',
                    'conductivity': 'mS',
                    'ph'          : 'Ph',
                    'light'       :  ''}

    # List of queues for websocket communication
    self.subscribed_queues = []

    self.device = ''
    regex = r"product: (?P<device>.*)"
    hw=os.popen("lshw -c system 2>/dev/null")
    for line in hw.readlines():
      matches = re.search(regex, line)
      if matches:
        self.device = matches.group('device')
        break
    hw.close()

    # Default power usage for a PI
    self.pi_power_wattage = 5

    self.environment = None

    # Load config
    logger.info('Loading terrariumPI config')
    self.config = terrariumConfig()
    logger.info('Done Loading terrariumPI config')

    logger.info('Setting terrariumPI authentication')
    self.set_authentication(self.config.get_admin(),self.config.get_password())
    logger.info('Done setting terrariumPI authentication')

    # Load data collector for historical data
    logger.info('Loading terrariumPI collector')
    self.collector = terrariumCollector(self.config.get_system()['version'])
    logger.info('Done loading terrariumPI collector')

    # Set the Pi power usage (including usb devices directly on the PI)
    logger.info('Loading terrariumPI PI power setting')
    self.pi_power_wattage = float(self.config.get_pi_power_wattage())
    logger.info('Done loading terrariumPI PI power setting')

    # Set the system temperature indicator
    logger.info('Loading terrariumPI PI temperature indicator')
    self.set_temperature_indicator(self.config.get_temperature_indicator())
    logger.info('Done loading terrariumPI PI temperature indicator')

    # Set the system distance indicator
    logger.info('Loading terrariumPI PI distance indicator')
    self.set_distance_indicator(self.config.get_distance_indicator())
    logger.info('Done loading terrariumPI PI distance indicator')

    # Load Weather part
    logger.info('Loading terrariumPI weather data')
    self.weather = terrariumWeather(self.config.get_weather_location(),
                                    self.config.get_weather_windspeed(),
                                    self.__unit_type,
                                    self.get_weather)
    logger.info('Done loading terrariumPI weather data')

    # Load humidity and temperature sensors
    self.__load_sensors()

    # Load Powerswitches part
    self.__load_power_switches()

    # Load doors from config
    self.__load_doors()

    # Load the environment system. This will controll the lights, sprayer and heaters
    logger.debug('Loading terrariumPI environment system')
    self.environment = terrariumEnvironment(self.sensors, self.power_switches, self.weather, self.is_door_open, self.config.get_environment)
    logger.debug('Done loading terrariumPI environment system')

    # Load webcams from config
    self.__load_webcams()

    # Load audio system
    self.__audio_player = terrariumAudioPlayer(self.config.get_audio_playlists(),
                                               self.config.get_active_soundcard(),
                                               any(self.power_switches[switchid].is_pwm_dimmer() for switchid in self.power_switches),
                                               self.get_audio_playing)

    # Start system update loop
    self.__running = True
    thread.start_new_thread(self.__engine_loop, ())
    thread.start_new_thread(self.__log_tail, ())
    logger.info('TerrariumPI engine is running')
Пример #4
0
    def __init__(self):
        # List of queues for websocket communication
        self.subscribed_queues = []
        # Default power usage for a PI
        self.pi_power_wattage = 5

        self.environment = None

        # Load config
        logger.info('Loading terrariumPI config')
        self.config = terrariumConfig()
        logger.info('Done Loading terrariumPI config')

        logger.info('Setting terrariumPI authentication')
        self.set_authentication(self.config.get_admin(),
                                self.config.get_password())
        logger.info('Done setting terrariumPI authentication')

        # Load data collector for historical data
        logger.info('Loading terrariumPI collector')
        self.collector = terrariumCollector()
        logger.info('Done loading terrariumPI collector')

        # Set the Pi power usage (including usb devices directly on the PI)
        logger.info('Loading terrariumPI PI power setting')
        self.pi_power_wattage = float(self.config.get_pi_power_wattage())
        logger.info('Done loading terrariumPI PI power setting')

        # Set the system temperature indicator
        logger.info('Loading terrariumPI PI temperature indicator')
        self.temperature_indicator = self.config.get_temperature_indicator()

        logger.info('Done loading terrariumPI PI temperature indicator')

        # Load Weather part
        logger.info('Loading terrariumPI weather data')
        self.weather = terrariumWeather(self.config.get_weather_location(),
                                        self.config.get_weather_windspeed(),
                                        self.get_temperature_indicator,
                                        self.get_weather)
        logger.info('Done loading terrariumPI weather data')

        # Load humidity and temperature sensors
        self.__load_sensors()

        # Load Powerswitches part
        self.__load_power_switches()

        # Load doors from config
        self.__load_doors()

        # Load the environment system. This will controll the lights, sprayer and heaters
        logger.debug('Loading terrariumPI environment system')
        self.environment = terrariumEnvironment(self.sensors,
                                                self.power_switches,
                                                self.weather, self.door_status,
                                                self.config)
        logger.debug('Done loading terrariumPI environment system')

        # Load webcams from config
        self.__load_webcams()

        # Start system update loop
        logger.info('Start terrariumPI engine')
        thread.start_new_thread(self.__engine_loop, ())