Exemple #1
0
	def __init__(self, args):

		try:

		    # Imports the IotFetcher
		    from iot_fetcher import IotFetcher

		except ImportError:
		    exit("This script requires to import the IoT shared functions\nThe file iot_fetcher.py was not found")

		self.verbose = args.get('verbose')
		self.configFileAddress = args.get('configFileAddress')

		# Sets the fetcher
		fetcher = IotFetcher('OLED Display',self.configFileAddress, self.verbose)

		# Load OLED Display configuration from file
		self.configJson = fetcher.loadConfig().get('oled_display')

		# Sets the values from parsed
		parsed = {
			'rst_pin': args.get('rst_pin'),
			'size': args.get('size'),
		}

		# Sets the parameters from parsed or fetched from file
		fetched = fetcher.setsFetcher(parsed, self.configJson)

		# Updates the Dictionary
		self.configJson['rst_pin'] = fetched.get('rst_pin')
		self.configJson['size'] = fetched.get('size')

		# Updates the functionsDict with the Twitter module
		dictValues = {
            'display_name': 'OLED Display',
			'display_description': 'Uses the OLED Display module',
			'function': 'oled'
		}
		fetcher.updatesFunctionsDict(args.get('functionsDict'), dictValues)

		# Sets super
		super(IotOledDisplay, self).__init__(self.configJson, self.verbose)
Exemple #2
0
    def __init__(self, args):

        self.verbose = args.get('verbose')
        self.configFileAddress = args.get('configFileAddress')

        # Sets the fetcher
        fetcher = IotFetcher('Temperature Sensor', self.configFileAddress,
                             self.verbose)

        # Load Philips-Hue configuration from file
        self.configJson = fetcher.loadConfig().get('temperature_sensor')

        # Sets the values from parsed
        parsed = {
            'model': args.get('model'),
            'gpio_pin': args.get('gpio_pin'),
        }

        # Sets the parameters from parsed or fetched from file
        fetched = fetcher.setsFetcher(parsed, self.configJson)

        # Updates the Dictionary
        self.configJson['model'] = fetched.get('model')
        self.configJson['gpio_pin'] = fetched.get('gpio_pin')

        # Sets the variables
        self.model = fetched.get('model')
        self.gpio_pin = fetched.get('gpio_pin')

        # Updates the functionsDict with the Twitter module
        dictValues = {
            'display_name': 'Temperature Sensor',
            'display_description': 'Uses the Temperature Sensor',
            'function': 'temperature'
        }

        fetcher.updatesFunctionsDict(args.get('functionsDict'), dictValues)

        # Sets super
        super(IotTemperatureSensor, self).__init__(self.verbose)
Exemple #3
0
    def __init__(self, args):

        self.verbose = args.get('verbose')
        self.configFileAddress = args.get('configFileAddress')

        # Sets the fetcher
        fetcher = IotFetcher('Twitter', self.configFileAddress, self.verbose)

        # Load Twitter configuration from file
        self.configJson = fetcher.loadConfig()

        # Sets the values from parsed
        parsed = {
            'twitter_user': args.get('twitter_user'),
            'tweets_count': args.get('tweets_count'),
        }

        # Sets the parameters from parsed or fetched from file
        fetched = fetcher.setsFetcher(parsed, self.configJson.get('fetcher'))

        # Updates the Dictionary
        self.configJson['twitter_user'] = fetched.get('twitter_user')
        self.configJson['tweets_count'] = fetched.get('tweets_count')

        # Updates the functionsDict with the Twitter module
        dictValues = {
            'display_name': 'Twitter',
            'display_description': 'Uses the Twitter module',
            'function': 'twitter'
        }
        fetcher.updatesFunctionsDict(args.get('functionsDict'), dictValues)

        # Sets the variables
        self.twitter_user = fetched.get('twitter_user')
        self.tweets_count = fetched.get('tweets_count')

        # Sets super
        super(IotTwitter, self).__init__(self.configJson.get('config'),
                                         self.verbose)
Exemple #4
0
    def __init__(self, args):

        self.verbose = args.get('verbose')
        self.configFileAddress = args.get('configFileAddress')

        # Sets the fetcher
        fetcher = IotFetcher('Philips-Hue', self.configFileAddress,
                             self.verbose)

        # Load Philips-Hue configuration from file
        self.configJson = fetcher.loadConfig().get('philips_hue')

        # Sets the values from parsed
        parsed = {
            'bridgeIP': args.get('bridgeIP'),
            'username': args.get('username'),
        }

        # Sets the parameters from parsed or fetched from file
        fetched = fetcher.setsFetcher(parsed, self.configJson)

        # Updates the Dictionary
        self.configJson['bridgeIP'] = fetched.get('bridgeIP')
        self.configJson['username'] = fetched.get('username')

        # Updates the functionsDict with the Twitter module
        dictValues = {
            'display_name': 'Hue',
            'display_description': 'Uses the Philips-Hue',
            'function': 'hue'
        }

        fetcher.updatesFunctionsDict(args.get('functionsDict'), dictValues)

        # Sets super
        super(IotPhilipsHue, self).__init__(self.configJson, self.verbose)