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


Python ATT_IOT.addAsset方法代码示例

本文整理汇总了Python中ATT_IOT.addAsset方法的典型用法代码示例。如果您正苦于以下问题:Python ATT_IOT.addAsset方法的具体用法?Python ATT_IOT.addAsset怎么用?Python ATT_IOT.addAsset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ATT_IOT的用法示例。


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

示例1: setupCloud

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
def setupCloud():
    IOT.on_message = on_message
    #make certain that the device & it's features are defined in the cloudapp
    IOT.connect()
    if hasLISIPAROI:
        IOT.addAsset(ToggleLISIPAROIId, "LISIPAROI", "Control the light on the camera", False, "boolean")
    IOT.addAsset(PreviewId, "Preview", "Show/close a preview on the monitor that is connected to the RPI", True, "boolean")
    IOT.addAsset(RecordId, "Record", "Start/stop recording the video stream on sd-card", True, "boolean")
    IOT.addAsset(PictureId, "Picture", "take a picture (max resoution) and store on sd-card", True, "boolean")
    IOT.addAsset(StreamServerId, "Stream server", "set the ip address of the server that manages the video", True, "string")

    # get any previously defined settings
    streamer.streamServerIp = IOT.getAssetState(StreamServerId)
    if streamer.streamServerIp:
        streamer.streamServerIp = streamer.streamServerIp['state']['value']
        logging.info("sending stream to: " + streamer.streamServerIp)
    else:
        logging.info("no stream endpoint defined")

    IOT.subscribe()              							#starts the bi-directional communication
    # set current state of the device
    IOT.send("false", ToggleLISIPAROIId)
    IOT.send("false", PreviewId)
    IOT.send("false", RecordId)
开发者ID:ATT-JBO,项目名称:RPICameraRemote,代码行数:26,代码来源:RPICameraRemote.py

示例2: tryConnect

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
def tryConnect():
    global IsConnected
    try:
        networkCheckCount = 0
        while (
            Network.isConnected() == False and networkCheckCount < 5
        ):  # we check a number of times to give the network more time to start up.
            networkCheckCount = networkCheckCount + 1
            sleep(2)
        if Network.isConnected() == False:
            logging.error("failed to set up network connection")
        else:
            # make certain that the device & it's features are defined in the cloudapp
            IOT.connect()
            # IOT.addAsset(TempSensorPin, TempSensorName, "temperature", False, "number", "Secondary")
            # IOT.addAsset(WaterLevelSensorPin, WaterLevelSensorName, "Water level", False, "number", "Secondary")
            IOT.addAsset(LightsRelaisPin, LightsRelaisName, "Turn the lights on/off", True, "boolean", "Primary")
            IOT.addAsset(WaterRelaisPin, WaterRelaisName, "Turn the water flow on/off", True, "boolean", "Primary")
            IOT.addAsset(
                ConfigSeasonId,
                ConfigSeasonName,
                "Configure the season",
                True,
                "{'type': 'string','enum': ['grow', 'flower']}",
                "Config",
            )
            try:
                season = IOT.getAssetState(ConfigSeasonId)
            except:
                logging.exception("failed to get asset state")
            LoadConfig(
                season
            )  # load the cloud settings into the appbefore closing the http connection. otherwise this call fails.
            IOT.subscribe()  # starts the bi-directional communication
            sleep(
                2
            )  # wait 2 seconds until the subscription has succeeded (bit of a hack, better would be to use the callback)
            IsConnected = True
            IOT.send(
                str(LightRelaisState).lower(), LightsRelaisPin
            )  # provide feedback to the platform of the current state of the light (after startup), this failed while loading config, cause mqtt is not yet set up.
            IOT.send(str(WaterRelaisState).lower(), WaterRelaisPin)
    except:
        logging.exception("failed to set up the connection with the cloud")
        IsConnected = False
开发者ID:ATT-JBO,项目名称:GrowMachine,代码行数:47,代码来源:GrowMachine.py

示例3: print

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
        value = value.lower()                        #make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            GPIO.output(ActuatorPin, True)
            IOT.send("true", ActuatorPin)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            GPIO.output(ActuatorPin, False)
            IOT.send("false", ActuatorPin)                #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
    else:
        print("unknown actuator: " + id)
IOT.on_message = on_message

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(SensorPin, SensorName, "Push button", False, "boolean")
IOT.addAsset(ActuatorPin, ActuatorName, "Light Emitting Diode", True, "boolean")
IOT.subscribe()              							#starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    if GPIO.input(SensorPin) == 0:                        #for PUD_DOWN, == 1
        if SensorPrev == False:
            print(SensorName + " activated")
            IOT.send("true", SensorPin)
            SensorPrev = True
    elif SensorPrev == True:
        print(SensorName + " deactivated")
        IOT.send("false", SensorPin)
        SensorPrev = False
    sleep(1)
开发者ID:miodragArsic,项目名称:first-app,代码行数:33,代码来源:NoShield_Demo.py

示例4: print

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
        value = value.lower()                        	#make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            grovepi.digitalWrite(actuatorPin, 1)
            IOT.send("true", actuatorId)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            grovepi.digitalWrite(actuatorPin, 0)
            IOT.send("false", actuatorId)               #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
    else:
        print("unknown actuator: " + id)
IOT.on_message = on_message

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(sensorId, sensorName, "Push button", False, "bool")
IOT.addAsset(actuatorId, actuatorName, "Light Emitting Diode", True, "bool")
IOT.subscribe()              							#starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    if grovepi.digitalRead(sensorPin) == 1:
        if sensorPrev == False:
            print(sensorName + " activated")
            IOT.send("true", sensorId)
            sensorPrev = True
    elif sensorPrev == True:
        print(sensorName + " deactivated")
        IOT.send("false", sensorId)
        sensorPrev = False
    sleep(.3)
开发者ID:MichielDeMey,项目名称:gif_python,代码行数:33,代码来源:ATT_RPI_Shield_Demo.py

示例5: str

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
            grovepi.digitalWrite( lightRELAY, 0 )
    if id.endswith( str( heaterRELAY ) ):
        value = value.lower()
        if value == "true":
            print "h-ON"
            grovepi.digitalWrite( heaterRELAY, 1 )
        if value == "false":
            print "h-OFF"
            grovepi.digitalWrite( heaterRELAY, 0 )

    # ignore unkown ids and values                                                                                                                                               

#make certain that the device & it's features are defined in the cloudapp
IOT.on_message = on_message
IOT.connect()
IOT.addAsset(tempSENSOR, "tempSENSOR", "Temperature Sensor", False, "float")
IOT.addAsset(humSENSOR, "humSENSOR", "Humidity Sensor", False, "float")
IOT.addAsset( lightRELAY, "lightRELAY", "Light Switch", True, "boolean" )
IOT.addAsset( heaterRELAY, "heaterRELAY", "Heater Switch", True, "boolean" )
IOT.subscribe()              							#starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    try:
        [temp, hum]=grovepi.dht(tempSENSOR,0)
        print( "t=",temp," h=",hum)
        IOT.send(temp, tempSENSOR)
        IOT.send(hum, humSENSOR)
        sleep(1)

    except IOError:
开发者ID:refap3,项目名称:refAP3repo,代码行数:33,代码来源:STITsh.py

示例6: print

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
            IOT.send("false", Out1Id)                #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
    else:
        print("unknown actuator: " + id)

#set up the ATT internet of things platform
IOT.on_message = on_message
IOT.ClientId = "put your client id here"
IOT.ClientKey = "put your client key here"
IOT.DeviceId = "put your device id here"
IOT.BrokerUserId = "put your username for the broker here"

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(In1Id, In1Name, "put your description here", False, "bool")
IOT.addAsset(Out1Id, Out1Name, "put your description here", True, "bool")
IOT.subscribe()                                        		#starts the bi-directional communication

nextVal = True;
#main loop: run as long as the device is turned on
while True:
    if nextVal == True:
        print(In1Name + " activated")
        IOT.send("true", In1Id)
        nextVal = False
    else:
        print(In1Name + " deactivated")
        IOT.send("false", In1Id)
        nextVal = True
    sleep(5)
开发者ID:MichielDeMey,项目名称:gif_python,代码行数:33,代码来源:ATT_Win_Demo.py

示例7:

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
        value = value.lower()

        if value == "true":
            print "ON"
            grovepi.digitalWrite( LED, 1 )

        if value == "false":
            print "OFF"
            grovepi.digitalWrite( LED, 0 )

    # ignore unkown ids and values                                                                                                                                               

if __name__ == '__main__':

  grovepi.pinMode( LED, 'output' )

  IOT.DeviceId   = "b8klgjaOEbLaCvncEX421VM"
  IOT.ClientId   = "itirockz"
  IOT.ClientKey  = "rcwenbi3ssg"

  IOT.on_message = on_message

  IOT.connect()
  IOT.addAsset( LED, "LED", "Light Emitting Diode", True, "boolean" )
  IOT.subscribe()

  while True:
      time.sleep( .1 )

开发者ID:refap3,项目名称:refAP3repo,代码行数:30,代码来源:ledserver.py

示例8: setup

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
def setup():
    """
    Add the watchdog asset to the device.  This can be used as visual feedback for the state of the device.
    """
    IOT.addAsset(WatchDogAssetId, "network watchdog", "used to verify the connectivity with the broker", True, "integer")
开发者ID:allthingstalk,项目名称:raspberrypi-python-client,代码行数:7,代码来源:nw_watchdog.py

示例9: on_message

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
vMotor = 2                                     # Shield pin nr & construct for AssetID

#set up the pins
grovepi.pinMode(vMotor,"OUTPUT")


#callback: handles values sent from the cloudapp to the device
def on_message(id, value):
    if id.endswith(str(vMotor)) == True:
        value = value.lower()                           #make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            grovepi.digitalWrite(vMotor, 1)
            IOT.send("true", vMotor)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            grovepi.digitalWrite(vMotor, 0)
            IOT.send("false", vMotor)               #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
    else:
        print("unknown actuator: " + id)
IOT.on_message = on_message

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(vMotor, "vMotor", "Vibration Motor", True, "boolean")
IOT.subscribe()                                                                 #starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    sleep(.3)
开发者ID:miodragArsic,项目名称:first-app,代码行数:32,代码来源:smartphoneGuard.py

示例10: print

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
IOT.ClientKey = ""

sensorPrev = False

doorBell = 2						# The Pin number of the Shield, also used to construct the AssetID



#set up the pins
grovepi.pinMode(doorBell,"INPUT")

#callback: handles values sent from the cloudapp to the device

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(doorBell, "DoorBell", "DoorBell", False, "boolean")
IOT.subscribe()                                                                 #starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    try:
        if grovepi.digitalRead(doorBell) == 1:
            if sensorPrev == False:
                print("DoorBell  activated")
                IOT.send("true", doorBell)
                sensorPrev = True
        elif sensorPrev == True:
            print("DoorBell  deactivated")
            IOT.send("false", doorBell)
            sensorPrev = False
        sleep(.3)
开发者ID:miodragArsic,项目名称:first-app,代码行数:33,代码来源:doorbell.py

示例11: on_message

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
sensorPin = 5

actuatorPin = 6

#set up the pins
grovepi.pinMode(sensorPin,"INPUT")
grovepi.pinMode(actuatorPin,"OUTPUT")

#callback: handles values sent from the cloudapp to the device
def on_message(id, value):
  print("unknown actuator: " + id)
IOT.on_message = on_message

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(sensorPin, sensorName, "Push button", False, "boolean")
IOT.subscribe()    

IOT.send("false", sensorPin)

buttonVal = False;
sensorVal = False;
while True:
  try:
    sensorRead = grovepi.digitalRead(sensorPin)
    if sensorRead == 255:
      continue
    if sensorVal != sensorRead:
      sensorVal = sensorRead
      if sensorVal:
        buttonVal = not buttonVal
开发者ID:allthingstalk,项目名称:hackathon,代码行数:33,代码来源:HouseButton.py

示例12: assetID

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
import ATT_IOT as IOT 							   #provide cloud support
from time import sleep                             #pause the app

#set up the SmartLiving IoT platform
IOT.DeviceId = ""
IOT.ClientId = ""
IOT.ClientKey = ""

lightSensor = 0                                  #the PIN number of the lichtsensor, also used to construct a Unique assetID (DeviceID+nr)

#set up the pins
grovepi.pinMode(lightSensor,"INPUT")

#callback: handles values sent from the cloudapp to the device

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(lightSensor, "lightSensor", "Light Sensor", False, "integer")
IOT.subscribe()              							#starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    try:
        lightValue =  grovepi.analogRead(lightSensor)
        print( "LightSensor = " + str(lightValue))
        IOT.send(lightValue, lightSensor)
        sleep(5)

    except IOError:
        print ""
开发者ID:miodragArsic,项目名称:first-app,代码行数:32,代码来源:lightsensor.py

示例13: between

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
#Define each asset below. provide a Name and Pin. The Pin number is used to define the Pin number on your raspberry Pi shield
#and to create a unique assetId which is a combination of deviceID+Pin number. The Pin number can be any value between (0 - 2^63)

sensorName = "Button"            		    #name of the sensor
sensorPin = 2
sensorPrev = False                                  #previous value of the sensor (only send a value when a change occured)


#set up the pins

#callback: handles values sent from the cloudapp to the device
def on_message(id, value):
    print("unknown actuator: " + id)

IOT.on_message = on_message

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(sensorPin, sensorName, "location info", False, "{\"type\": \"object\",\"properties\": {\"latitude\": { \"type\": \"number\" },\"longitude\": { \"type\": \"number\" }}}")
IOT.subscribe()              							#starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    try:
        value = {'latitude': 1, 'longitude': 2}
        IOT.send(value, sensorPin)
        sleep(2)

    except IOError:
        print ""
开发者ID:miodragArsic,项目名称:first-app,代码行数:32,代码来源:json_data.py

示例14: on_message

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]

Led = 4

#set up the pins
grovepi.pinMode(Led,"OUTPUT")


#callback: handles values sent from the cloudapp to the device
def on_message(id, value):
    if id.endswith(str(Led)) == True:
        value = value.lower()                           #make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            grovepi.digitalWrite(Led, 1)
            IOT.send("true", Led)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            grovepi.digitalWrite(Led, 0)
            IOT.send("false", Led)               #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
IOT.on_message = on_message

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(Led, "Shop Light", "Shop Window Light", True, "boolean")
IOT.subscribe()                                                                 #starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    sleep(.3)
开发者ID:miodragArsic,项目名称:first-app,代码行数:31,代码来源:shopWindow.py

示例15: print

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import addAsset [as 别名]
        value = value.lower()                           #make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            grovepi.digitalWrite(Led, 1)
            IOT.send("true", Led)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            grovepi.digitalWrite(Led, 0)
            IOT.send("false", Led)               #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
    else:
        print("unknown actuator: " + id)
IOT.on_message = on_message

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(Pir, "PIR", "PIR SENSOR", False, "boolean")
IOT.addAsset(Led, "LED", "Light Emitting Diode", True, "boolean")
IOT.subscribe()                                                                 #starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    try:
        if grovepi.digitalRead(Pir) == 1:
            if Pir_Prev == False:
                print("PIR activated")
                IOT.send("true", Pir)
                Pir_Prev = True
        elif Pir_Prev == True:
            print("PIR deactivated")
            IOT.send("false", Pir)
            Pir_Prev = False
开发者ID:miodragArsic,项目名称:first-app,代码行数:33,代码来源:motionDetector.py


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