def said_back(): iot.publish("messages","back") iot.say("Asking the car to move backward")
def off(): iot.say("OK, turning the fan off") iot.publish("tuuletin","off")
def full_speed(): iot.say("OK, turning the fan on") iot.publish("tuuletin","full")
def said_forward(): iot.publish("messages","forward") iot.say("Asking the car to move forward")
def print_green(): print('no ring') ser.write(b's') iot.publish("messages", "s")
def said_green(): iot.publish("messages","green")
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")
def said_back(): iot.publish("messages", "green")
def said_forward(): iot.publish("messages", "sparkle") iot.say("OK, sparkle")
def print_one(): print('blue ring') ser.write(b'k') iot.publish("messages", "k")
def said_left(): iot.publish("messages","left") iot.say("Asking the car to move left")
def said_back(): iot.publish("messages", "red glitter")
def said_right(): iot.publish("messages","right") iot.say("Asking the car to move right")
def said_back(): iot.publish("messages", "green glitter")
def said_red(): iot.publish("messages","red")
def said_back(): iot.publish("messages", "rainbow")
def said_nolight(): iot.publish("messages","nolight")
def half_speed(): iot.say("OK, turning the fan off") iot.publish("tuuletin","half")
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
def hello(): iot.publish("messages", "Hello, world!")