コード例 #1
0
def said_back():
    iot.publish("messages","back")
    iot.say("Asking the car to move backward")
コード例 #2
0
def off():
    iot.say("OK, turning the fan off")
    iot.publish("tuuletin","off")
コード例 #3
0
def full_speed():
    iot.say("OK, turning the fan on")
    iot.publish("tuuletin","full")
コード例 #4
0
def said_forward():
    iot.publish("messages","forward")
    iot.say("Asking the car to move forward")
コード例 #5
0
def print_green():
    print('no ring')
    ser.write(b's')
    iot.publish("messages", "s")
コード例 #6
0
def said_green():
    iot.publish("messages","green")
コード例 #7
0
def said_animation():
    iot.publish("messages","animation")
コード例 #8
0
def said_left():
    iot.publish("messages", "blue")
コード例 #9
0
def said_left():
    iot.publish("messages", "red")
コード例 #10
0
def bounce():
    print("lähetettiin komento c")
    iot.say("Deploying bounce")
    ser.write(b"c")
    iot.publish("messages", "green")
コード例 #11
0
def cycle():
    print("lähetettiin komento e")
    iot.say("Deploying wipe")
    ser.write(b"e")
    iot.publish("messages", "green")
コード例 #12
0
def said_back():
    iot.publish("messages", "green")
コード例 #13
0
def said_forward():
    iot.publish("messages", "sparkle")
    iot.say("OK, sparkle")
コード例 #14
0
def print_one():
    print('blue ring')
    ser.write(b'k')
    iot.publish("messages", "k")
コード例 #15
0
def said_left():
    iot.publish("messages","left")
    iot.say("Asking the car to move left")
コード例 #16
0
def said_back():
    iot.publish("messages", "red glitter")
コード例 #17
0
def said_right():
    iot.publish("messages","right")
    iot.say("Asking the car to move right")
コード例 #18
0
def said_back():
    iot.publish("messages", "green glitter")
コード例 #19
0
def said_red():
    iot.publish("messages","red")
コード例 #20
0
def said_back():
    iot.publish("messages", "rainbow")
コード例 #21
0
def said_nolight():
    iot.publish("messages","nolight")
コード例 #22
0
def half_speed():
    iot.say("OK, turning the fan off")
    iot.publish("tuuletin","half")
コード例 #23
0
def handle_non_discovery_v3(request):
    request_namespace = request["directive"]["header"]["namespace"]
    request_name = request["directive"]["header"]["name"]
    request_device = request["directive"]["endpoint"]["endpointId"]

    if request_namespace == "Alexa.PowerController":
        if request_name == "TurnOn":
            value = "ON"
        else:
            value = "OFF"

        iot.publish(request_device, value)

        response = {
            "context": {
                "properties": [{
                    "namespace": "Alexa.PowerController",
                    "name": "powerState",
                    "value": value,
                    "timeOfSample": get_utc_timestamp(),
                    "uncertaintyInMilliseconds": 500
                }]
            },
            "event": {
                "header": {
                    "namespace":
                    "Alexa",
                    "name":
                    "Response",
                    "payloadVersion":
                    "3",
                    "messageId":
                    get_uuid(),
                    "correlationToken":
                    request["directive"]["header"]["correlationToken"]
                },
                "endpoint": {
                    "scope": {
                        "type": "BearerToken",
                        "token": "access-token-from-Amazon"
                    },
                    "endpointId": request_device
                },
                "payload": {}
            }
        }
        return response

    elif request_namespace == "Alexa":
        if request_name == "ReportState":
            response = {
                "context": {
                    "properties": [{
                        "namespace": "Alexa.PowerController",
                        "name": "powerState",
                        "value": iot.read_state(request_device),
                        "timeOfSample": get_utc_timestamp(),
                        "uncertaintyInMilliseconds": 500
                    }]
                },
                "event": {
                    "header": {
                        "namespace":
                        "Alexa",
                        "name":
                        "StateReport",
                        "payloadVersion":
                        "3",
                        "messageId":
                        get_uuid(),
                        "correlationToken":
                        request["directive"]["header"]["correlationToken"]
                    },
                    "endpoint": {
                        "endpointId": request_device
                    },
                    "payload": {}
                }
            }
            return response
コード例 #24
0
def hello():
    iot.publish("messages", "Hello, world!")