Exemplo n.º 1
0
def said_back():
    iot.publish("messages","back")
    iot.say("Asking the car to move backward")
Exemplo n.º 2
0
def off():
    iot.say("OK, turning the fan off")
    iot.publish("tuuletin","off")
Exemplo n.º 3
0
def full_speed():
    iot.say("OK, turning the fan on")
    iot.publish("tuuletin","full")
Exemplo n.º 4
0
def said_forward():
    iot.publish("messages","forward")
    iot.say("Asking the car to move forward")
Exemplo n.º 5
0
def print_green():
    print('no ring')
    ser.write(b's')
    iot.publish("messages", "s")
Exemplo n.º 6
0
def said_green():
    iot.publish("messages","green")
Exemplo n.º 7
0
def said_animation():
    iot.publish("messages","animation")
def said_left():
    iot.publish("messages", "blue")
def said_left():
    iot.publish("messages", "red")
def bounce():
    print("lähetettiin komento c")
    iot.say("Deploying bounce")
    ser.write(b"c")
    iot.publish("messages", "green")
def cycle():
    print("lähetettiin komento e")
    iot.say("Deploying wipe")
    ser.write(b"e")
    iot.publish("messages", "green")
Exemplo n.º 12
0
def said_back():
    iot.publish("messages", "green")
Exemplo n.º 13
0
def said_forward():
    iot.publish("messages", "sparkle")
    iot.say("OK, sparkle")
Exemplo n.º 14
0
def print_one():
    print('blue ring')
    ser.write(b'k')
    iot.publish("messages", "k")
Exemplo n.º 15
0
def said_left():
    iot.publish("messages","left")
    iot.say("Asking the car to move left")
def said_back():
    iot.publish("messages", "red glitter")
Exemplo n.º 17
0
def said_right():
    iot.publish("messages","right")
    iot.say("Asking the car to move right")
def said_back():
    iot.publish("messages", "green glitter")
Exemplo n.º 19
0
def said_red():
    iot.publish("messages","red")
def said_back():
    iot.publish("messages", "rainbow")
Exemplo n.º 21
0
def said_nolight():
    iot.publish("messages","nolight")
Exemplo n.º 22
0
def half_speed():
    iot.say("OK, turning the fan off")
    iot.publish("tuuletin","half")
Exemplo n.º 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
Exemplo n.º 24
0
def hello():
    iot.publish("messages", "Hello, world!")