Cov txheej txheem:

Tau Kuaj Rau Koj Lub Tsev Google Siv Raspberry Pi thiab Dialogflow (Chromecast Alternative): 13 Cov Kauj Ruam
Tau Kuaj Rau Koj Lub Tsev Google Siv Raspberry Pi thiab Dialogflow (Chromecast Alternative): 13 Cov Kauj Ruam

Video: Tau Kuaj Rau Koj Lub Tsev Google Siv Raspberry Pi thiab Dialogflow (Chromecast Alternative): 13 Cov Kauj Ruam

Video: Tau Kuaj Rau Koj Lub Tsev Google Siv Raspberry Pi thiab Dialogflow (Chromecast Alternative): 13 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Tau txais Screen rau Koj Lub Tsev Google Siv Raspberry Pi thiab Dialogflow (Chromecast Alternative)
Tau txais Screen rau Koj Lub Tsev Google Siv Raspberry Pi thiab Dialogflow (Chromecast Alternative)

Puas tau txij li thaum kuv yuav kuv lub tsev Google Kuv tau xav tswj hwm kuv cov cuab yeej hauv tsev siv lub suab hais kom ua. Nws ua haujlwm txaus nyob rau txhua txoj hauv kev, tab sis kuv xav tias tsis zoo rau nws cov yeeb yaj kiab. Peb tuaj yeem saib Youtube thiab Netflix tsuas yog tias peb muaj Chromecast ntaus ntawv lossis TV nrog built -in Chromecast. Kuv muaj Raspberry Pi nrog kuv, yog li kuv xav siv nws los ua si kuv cov vis dis aus thiab cov yeeb yaj kiab nrog lub suab hais kom ua.

Kauj ruam 1:

Image
Image

Txog qhov no, kuv tau teeb tsa hauv qab no

Google Tsev -> Dialogflow -> Rpi IP chaw nyob ntawm Dataplicity -> Nodejs Server -> Code qhib URLs

Dialogflow yog google tib neeg-khoos phis tawj sib cuam tshuam thev naus laus zis raws li kev sib tham lus ib txwm. Nrog kev pab los ntawm qhov no, peb tuaj yeem txhim kho peb tus kheej kev sib tham lossis ua haujlwm los muab ua tswv yim rau Google tsev. Qhov no ua haujlwm raws li hauv qab no

Lub hom phiaj [Lub tswv yim, lus nug, kev sib tham, hais kom ua….] -> Google Tsev -> nqis tes ua [teb]

Ntawm no, cov lus teb tuaj yeem yog kev sib tham yooj yim lossis lwm cov ntaub ntawv khaws los ntawm lub webhook, uas peb tab tom yuav siv Rpi server. Yog li, mus rau Dialogflow lub vev xaib thiab tsim tus as khauj thiab tus neeg sawv cev tshiab.

Tom qab ntawd tsim lub hom phiaj tshiab….

Kauj ruam 2:

Duab
Duab

Tom qab ntawd nkag mus rau kab lus qhia. Cov no yog cov lus txib uas cov neeg siv tham thaum lawv sim nkag mus ua haujlwm tshwj xeeb los ntawm Google Tsev.

Kauj ruam 3:

Ntawm no, Lo lus 'lub vev xaib' tuaj yeem hloov mus rau txhua yam zoo li youtube, Netflix, amazon prime thiab lwm yam … Yog li, lo lus no ua raws li qhov sib txawv thiab thaum koj xaiv lo lus lub vev xaib [siv nas] koj tau txais cov hauv qab no

Kauj ruam 4:

Duab
Duab

Los ntawm, cov ntawv qhia zaub mov nco, xaiv '@sys.any' thiab nias nkag mus.

Kauj ruam 5:

Duab
Duab

Tom qab ntawd nkag mus rau tib lub npe ntsuas hauv ntu kev ua. Cov txiaj ntsig tau hais hauv ntu no raug xa mus rau lub webhook ua JSON cov ntaub ntawv, uas peb xav tau los khaws hauv tus neeg rau zaub mov kom paub lub vev xaib twg muaj tus neeg siv thov.

Tus nqi ntawm qhov sib txawv tau muab rov qab siv '$ variable_name'

Kauj Ruam 6:

Duab
Duab

Ntxiv cov lus teb uas peb xav hnov tom qab hais cov lus txib rau Google Tsev. Tom qab ntawd txuag lub hom phiaj. Yog tias xav tau teeb tsa lub hom phiaj no yog qhov kawg ntawm kev sib tham.

Kauj ruam 7:

Tam sim no peb yuav teeb tsa peb qhov kev pabcuam tom qab kawg kom tau txais cov lus nug no kom qhib cov vis dis aus thiab cov vev xaib ntawm peb cov raspberry pi.

Qhov teeb tsa ntxiv

Dataplicity -> Nodejs server -> chaws

Vim li cas peb thiaj xav tau dataplicity? vim tias Google Tsev txuas rau webhooks uas nkag mus tau yooj yim hauv is taws nem. Txawm hais tias peb GHome txuas nrog lub network hauv zej zog, cov lus nug tau los ntawm Google huab kev pabcuam thiab yog li ntawd, xav tau kev xa peb cov server rau hauv internet. Hloov chaw ntawm kev mob taub hau, peb tuaj yeem siv cov kev pabcuam dataplicity tso peb cov raspberry pi hauv internet tau yooj yim.

Ua ntej, txuas rau raspberry pi [ncaj qha nrog HDMI lossis txawm nrog SSh] Tau txais qhov tseeb nodejs khiav-sijhawm los ntawm cov lus txib hauv qab no hauv lub davhlau ya nyob twg.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E tsoo -

Tom qab ntawd nruab nws siv

sudo apt -tau nruab -y nodejs

Tom qab ntawd tsim cov ntawv tshiab

nano webserver.js

Kauj ruam 8:

Tom qab ntawd, ntxig cov cai hauv qab no rau hauv cov ntawv

Ntawm no, rau kev ua qauv qhia, Kuv siv tsuas yog ob lub vev xaib (google, youtube). Ib tus tuaj yeem hloov kho cov cai thiab hloov raws li.

bodyParser = xav tau ('lub cev-parser'); var exec = xav tau ('child_process'). exec; var nthuav tawm = xav tau ('nthuav tawm'); var app = nthuav tawm (); app.use (bodyParser.json ()); app.post ('/', function (req, res) {let variable = req.body.queryResult.parameters.website; exec ("midori www."+variable+". com", muaj nuj nqi (yuam kev, stdout, stderr) {console.log ("stdout:" + stdout); console.log ("stderr:" + stderr); yog (yuam kev! == null) {console.log ("exec errror:" + yuam kev);}}); rov res.end ();}); app.listen (80);

Kauj ruam 9:

Duab
Duab

Cov cai saum toj no tau sau tsuas yog piav qhia lub tswv yim. Kuv siv Midori browser hauv qhov chaws vim chromium tsis ua haujlwm nrog cov lus txib nyob deb. Peb tuaj yeem siv Firefox ib yam. [Peb yuav tsum teeb tsa lub cev-parser, nthuav qhia cov qauv nrog kev pab ntawm npm ua ntej sau cov cai]

Nco ntsoov tias peb yuav tsum tsuas yog mloog ntawm chaw nres nkoj 80 raws li dataplicity tuaj yeem xa mus tsuas yog chaw nres nkoj 80 ntawm raspberry pi.

Tam sim no peb yuav tsum teeb tsa Dataplicity

Mus rau Dataplicity lub vev xaib thiab tsim koj tus lej nyiaj thiab ua raws cov lus qhia ntxiv rau raspberry pi rau ntawm lub dashboard.

Kauj ruam 10:

Duab
Duab

Tom qab ntawd, qhib raspberry pi los ntawm cov npe khoom thiab xaiv wormhole kom tau txais IP Chaw Nyob tshwj xeeb rau raspberry pi uas peb tuaj yeem xa peb cov node server.

Luam tus IP chaw nyob rau hauv ntawv teev cia.

Kauj ruam 11:

Duab
Duab

Tam sim no khiav cov cai los ntawm raspberry pi davhlau ya nyob twg

sudo node webserver.js

Yog tias nws qhia qhov ua yuam kev txog zaub lossis hais txog cov kev cai…. ua

sudo xhost +

Tam sim no rov qab mus rau dialogflow, thiab nyem rau ntawm ntu ua tiav

Kauj ruam 12:

Duab
Duab

Nkag mus rau IP Chaw Nyob lossis URL los ntawm dataplicity hauv qhov chaw saum toj no.

Kauj ruam 13:

Duab
Duab

Thaum kawg, mus rau ntu kev xav thiab ua kom lub webhook hu los ntawm kev ua tiav tab.

Qhov ntawd yog nws! Tam sim no rov qab mus rau koj lub tsev google thiab tshawb xyuas seb nws ua haujlwm li cas!

Txog rau lub sijhawm tom ntej, Zoo Siab Hacking:)

Pom zoo: