Walabot can be used inside the hotel rooms to detect if room is empty or how many users inside the room. Based om such information many actions can be done:
- In case of empty room, Room service can go directly to room to clean it
- In case of empty room, a power saving procedure can be put in place (close lights, lower the air conditions,..)
- In case of nun empty room, ensure that number of guests inside the room is equal to what is saved in hotel records while registration
So supervisor can ask Alexa about certain hotel room, Alexa will ask corresponding walabot device which will return with number of guests inside the room and based on this value, supervisor can act accordingly
For simplicity we implement the idea to check one room only.
Amazon avail easy tutorials to create skill & lambda function. To create Skill, Lambda function and trigger lambda using the skill follow steps in trivia skill tutorial
Skill Name is "Empty Rooms" and it is pass certification in 12 Dec 2017
Skill Interaction model
The main intent we have in this skill is the intent that get room number from user, which will be a normal integer.
RoomIntent number {room_number}
Related intent schema will be
{
"slots": [
{
"name": "room_number",
"type": "AMAZON.NUMBER"
}
],
"intent": "RoomIntent"
}
Lambda function
Here we use Alexa Skill Kit SDK for node.js.
Below code to ensure that input room number is an integer value, if not function will return -1.
function isRoomSlotValid(intent) {
const answerSlotFilled = intent && intent.slots && intent.slots.room_number && intent.slots.room_number.value;
const answerSlotIsInt = answerSlotFilled && !isNaN(parseInt(intent.slots.room_number.value, 10)) && (parseInt(intent.slots.room_number.value, 10) > 0) ;
return answerSlotIsInt ? parseInt(intent.slots.room_number.value, 10) : -1 ;
}
In case of valid room number, HTTP request will be sent to RPi, output will be the number of persons in room
if (roomNumber > 0){
var url = urlRPi + "//" + roomNumber;
request(url,
(function (error, response, body) {
this.handler.state = SKILL_STATES.ANSWER_Q;
var nofPersons = isBodyValid(body);
if (nofPersons < 0) { //wrong OP
speechOutput = this.t('WRONG_HTML');
} else if (nofPersons > 0) { // room isn't empty
speechOutput = this.t('NOT_EMPTY_ROOM', nofPersons.toString());
}
else {//room is empty
speechOutput = this.t('EMPTY_ROOM');
}
this.emit(':tell', speechOutput);
}).bind(this)
);
RaspberryYou need to prepare below components
- Ngrok
ngrok is a command-line program that opens a secure tunnel to localhost and exposes that tunnel behind an HTTPS endpoint. ngrok makes it so Alexa can talk to your code right away. Follow the next three steps to generate a public HTTPS endpoint to 127.0.0.1:5000.
Download ngrok get the latest Linux ARM release as a zip and unzip inside the home directory of RPi.
unzip /home/pi/ngrok-stable-linux-arm.zip
sudo ./ngrok http 5000
The result will be the ngrok URL that will be used in Lambda function as urlRPi.
- Flask
Flask is a lightweight web framework, to install Flask from RPi terminal window
sudo apt-get install python3-flask
To build the web application, open terminal session and create new file
nano get_room_number.py
and Past below code
from flask import Flask
import sys
import subprocess
app = Flask(__name__)
@app.route('/<int:roomNumber>')
def roomNumber(roomNumber):
return subprocess.check_output([sys.executable, "people_counter.py", roomNumber])
if __name__ == '__main__':
app.run(debug=True)
This code will receive the room number from Alexa and direct it to another python module that count number of moving objects and return back this number to Alexa
This code assume that only one Walabot is connecting to raspberry so room number is received but never used
- Walabot
Install the Walabot SDK and the WalabotAPI Python library using pip. Then open terminal session and create new file
nano people_counter.py
This script will count how many people go in or go out the room. Code in this file will be found in attachment - code section. It is exactly the same as one of Walabot Projects that get people counter, small modification added to get the room number as input and return the people count to get_room_number.py.
Comments