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


Python ATT_IOT.getAssetState方法代码示例

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


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

示例1: tryConnect

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import getAssetState [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

示例2: setupCloud

# 需要导入模块: import ATT_IOT [as 别名]
# 或者: from ATT_IOT import getAssetState [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


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