当前位置: 首页>>代码示例>>Python>>正文


Python Adafruit_IO.Client类代码示例

本文整理汇总了Python中Adafruit_IO.Client的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

 def run(self):
     print "ChartThread connecting"
     aio = Client(self._client_key)
 
     print "ChartThread fetching data"
     data = aio.data(self._feed_name)
 
     today = datetime.datetime.now()
     one_day = datetime.timedelta(days=1)
     yesterday = today - one_day
 
     dates = []
     temps = []
 
     print "ChartThread treating data"
     for d in data:
         ts = datetime.datetime.fromtimestamp(d.created_epoch)
         if ts > yesterday:
             dates.append(ts)
             temps.append(d.value)
 
     print "ChartThread plotting"
     dates = date2num(dates)
 
     fig = plt.figure()
     fig.set_size_inches(4, 3)
     plt.subplots_adjust(left=0.0, right=0.925, bottom=0.0, top=0.948)
     ax = fig.add_subplot(111)
     ax.plot_date(dates, temps, '-')
     ax.axes.get_xaxis().set_visible(False)
     plt.savefig(self._out_dir+'temps.png', dpi = 80, bbox_inches='tight', pad_inches = 0)
     plt.close(fig)
     print "ChartThread done"
开发者ID:jerbly,项目名称:adaiot,代码行数:33,代码来源:feed.py

示例2: AdafruitHandler

class AdafruitHandler(MessageHandler):

    def __init__(self, api_key, feed, message_field = "value"):
        self.message_field = message_field
        self.client = Client(api_key)
        self.feed = feed

    def send_value(self, value):

        logging.debug("Send value %s to feed %s", value, self.feed)
        self.client.send(self.feed, value)

    def handle(self, message):

        value = message.data[self.message_field]
        self.send_value(value)
开发者ID:rbender,项目名称:messagebus,代码行数:16,代码来源:adafruit.py

示例3: AioWriter

class AioWriter(threading.Thread):

    def __init__(self, queue):
        super().__init__()
        self.queue = queue
        self.aio = Client(AIO_KEY)
        self.daemon = False

    def run(self):
        while True:
            # Get the reading from the queue
            reading = self.queue.get()

            temperature = reading['temp']
            id = reading['id']
            try:
                self.aio.send(id, temperature)
            except AdafruitIOError as e:
                print(e)
开发者ID:Buntworthy,项目名称:motey-monitor,代码行数:19,代码来源:monitor.py

示例4: __init__

 def __init__(self):
     threading.Thread.__init__(self)
     self.setDaemon(True)
     self._homeDir        = os.path.expanduser("~/.sensomatic")
     self._configFileName = self._homeDir + '/config.ini'
     self._config         = ConfigParser.ConfigParser()
     self._readConfig()
     self._redis          = redis.StrictRedis(host= self._config.get("REDIS", "ServerAddress"),
                                              port= self._config.get("REDIS", "ServerPort"),
                                              db  = 0)
     self._adafruit       = Client(self._config.get("ADAFRUIT", "Id"))
开发者ID:AnsgarSchmidt,项目名称:sensomatic,代码行数:11,代码来源:Adafruit.py

示例5: IOAdafruitConnector

class IOAdafruitConnector(object):

    def __init__(self, api_key=None):

        if not api_key:
            api_key =  SERVICES['ADAFRUITIO_KEY']

        self.aio = Client(api_key)

    def send(self, data):
        # send data to dweet

        try:
            for key, value in data.iteritems():
                self.aio.send(key, value)

            response = {'status': 'ok'}
        except Exception as exception:
            response = {'error': exception.message}

        return response
开发者ID:bassdread,项目名称:zeep,代码行数:21,代码来源:io_adafruit.py

示例6: Client

# get the host and build a path for the logfile and make the file name individual
host = socket.gethostname()
path = '/home/pi/RPI-Weather-Log/logs/rpi_weather_data_{}.log'.format(host)
LOG_FILENAME = path

# Set up a specific logger with our desired output level
weather_logger = logging.getLogger('WeatherLogger')
weather_logger.setLevel(logging.INFO)

# Add the log message handler to the logger and make a log-rotation of 100 files with max. 10MB per file
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=LOG_SIZE, backupCount=BACKUP_COUNT,)
weather_logger.addHandler(handler)

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_KEY)

# Every refresh_interval seconds we'll refresh the weather data
pause = 0.1
ticks_per_second = 1 / pause
refresh_interval = 60 * REFRESH_RATE

# reed brightness slider from adafruit io feed
brightness = aio.receive('brightness')
brightness = int(brightness.value)


# get location for weather requests
def get_location():
    location_request_url = 'http://ip-api.com/json'
    location_data = requests.get(location_request_url).json()
开发者ID:LoveBootCaptain,项目名称:RPI-Weather-Log,代码行数:30,代码来源:rpi_weather_log.py

示例7: Author

Dark Sky Hyperlocal for IO Plus
with Adafruit IO API

Author(s): Brent Rubell for Adafruit Industries
"""
# Import JSON for forecast parsing
import json
# Import Adafruit IO REST client.
from Adafruit_IO import Client, Feed, RequestError

# Set to your Adafruit IO key.
ADAFRUIT_IO_USERNAME = 'YOUR_IO_USERNAME'
ADAFRUIT_IO_KEY = 'YOUR_IO_PASSWORD'

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

# Grab the weather JSON
weather = aio.receive_weather(1234)
weather = json.dumps(weather)
forecast = json.loads(weather)

# Parse the current forecast
current = forecast['current']
print('Current Forecast')
print('It is {0} and {1}.'.format(current['summary'], current['temperature']))

# Parse the two day forecast
forecast_days_2 = forecast['forecast_days_2']
print('\nWeather in Two Days')
print('It will be {0} with a high of {1}F and a low of {2}F.'.format(
开发者ID:adafruit,项目名称:io-client-python,代码行数:31,代码来源:weather.py

示例8: Client

#====================================================================
# Import subfiles
#====================================================================
import datetime
import glob
import os
import re
#import serial
import subprocess
import sys
import time
import warnings

# Import library and create instance of REST client.
from Adafruit_IO import Client
aio = Client('7e01e8b5e56360efc48a27682324fc353e18d14f')

# Set Variables
DEBUG = 1

# Add a delay for boot
time.sleep(1)

# Continuously append data
while(True):

  os.system('modprobe w1-gpio')
  os.system('modprobe w1-therm')
 
  base_dir = '/sys/bus/w1/devices/'
#  device_folder1 = glob.glob(base_dir + '*27c2')[0]
开发者ID:robingreig,项目名称:raspi-git,代码行数:31,代码来源:BasementTempAio.py

示例9: TSL2561

# TODO: Incorporate Python logging Module into controls
# TODO: Find a logging website other than io.adafruit for greater logging capabilities
# TODO: Find a decent light sensor and incorporate it into program
# TODO: Devise a means of checking the battery state before operating the fans
# TODO: Incorporate PowerSwitch Tail to turn a heater on and off
# TODO: Modify fan code so both fans only come on during daylight
# TODO: Create a warning message system for events such as high/low temp, low bat. etc...

# Global config stuff
#tsl = TSL2561()
config = SafeConfigParser()
config.read('/home/pi/Projects/Greenhouse/config.cfg')
interval = config.getint('defaults', 'interval')  # Get sensor updating interval
debug = config.getboolean('defaults', 'debug')  # debug print to console
ADAFRUIT_IO_KEY = config.get('defaults', 'aio_key')  # Import Adafruit aio Key
aio = Client(ADAFRUIT_IO_KEY)
DHT_TYPE = Adafruit_DHT.DHT22
DHT_PIN = config.getint('defaults', 'dht_pin')
mysqlUpdate = config.getboolean('database', 'mysqlUpdate')  # Are we using database?
max_cpu_temp = config.getint('defaults', 'max_cpu_temp')
exhaustOn = config.getint('environment', 'exhaust_fan_on')
exhaustOff = config.getint('environment', 'exhaust_fan_off')
circulate_temp = config.getint('environment', 'circulate_temp')
message_service = config.getboolean('email', 'send_email')
dayTempHigh = config.getint('environment', 'day_temp_high')
dayTempLow = config.getint('environment', 'day_temp_low')
nightTempHigh = config.getint('environment', 'night_temp_high')
nightTempLow = config.getint('environment', 'night_temp_low')
heaterPin = config.getint('defaults', 'heaterPin')

# Setup and initiate fans on GPIO pins.  Fans should be connected to a relay board.
开发者ID:mikepaxton,项目名称:Greenhouse,代码行数:31,代码来源:main.py

示例10: Client

from Adafruit_IO import Client
import tempSensor

ADAFRUIT_IO_KEY = 'f48251f19a88f21b5e7f9e97e2c81428d2120958'

aio = Client(ADAFRUIT_IO_KEY)
temperature = tempSensor.readTemperature()
res = aio.send('bedroom', temperature)
print res.created_at, res.value
开发者ID:vorasilp,项目名称:adafruitio-temperature,代码行数:9,代码来源:adafruitio_rest.py

示例11: Client

#Import library and create new REST client
from Adafruit_IO import Client
aio = Client('7e01e8b5e56360efc48a27682324fc353e18d14f')

# Get a list of feeds
data = aio.receive('Lamp')

# Print out feed metadata
print('Data Value: {0}'.format(data.value))
开发者ID:robingreig,项目名称:raspi-git,代码行数:9,代码来源:FeedControl01.py

示例12: __init__

    def __init__(self, api_key=None):

        if not api_key:
            api_key =  SERVICES['ADAFRUITIO_KEY']

        self.aio = Client(api_key)
开发者ID:bassdread,项目名称:zeep,代码行数:6,代码来源:io_adafruit.py

示例13: __init__

 def __init__(self, api_key, feed, message_field = "value"):
     self.message_field = message_field
     self.client = Client(api_key)
     self.feed = feed
开发者ID:rbender,项目名称:messagebus,代码行数:4,代码来源:adafruit.py

示例14: Client

#!/usr/bin/python

# Import Library & create instance of REST client
from Adafruit_IO import Client

import time
import os
import RPi.GPIO as GPIO

aio = Client('7e01e8b5e56360efc48a27682324fc353e18d14f')

last = 0
inputNum = 20
outputNum = 21
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(outputNum,GPIO.OUT)
GPIO.setup(inputNum,GPIO.IN)


while True:
  if (time.time() - last) >= 7:
    # Retrieve the most recent value from BlockHeat01
    data = aio.receive('blockheat01')
    print('Received Value: {0}'.format(data.value))
    if data.value == "1":
      print('data = 1')
      GPIO.output(outputNum,GPIO.HIGH)
    else:
      print('data = 0')
      GPIO.output(outputNum,GPIO.LOW)
开发者ID:robingreig,项目名称:raspi-git,代码行数:31,代码来源:Relay21Output03.py

示例15: __init__

 def __init__(self, queue):
     super().__init__()
     self.queue = queue
     self.aio = Client(AIO_KEY)
     self.daemon = False
开发者ID:Buntworthy,项目名称:motey-monitor,代码行数:5,代码来源:monitor.py


注:本文中的Adafruit_IO.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。