Cov txheej txheem:

Ua Haujlwm Nrog URL API hauv Node-RED: 10 Cov Kauj Ruam
Ua Haujlwm Nrog URL API hauv Node-RED: 10 Cov Kauj Ruam

Video: Ua Haujlwm Nrog URL API hauv Node-RED: 10 Cov Kauj Ruam

Video: Ua Haujlwm Nrog URL API hauv Node-RED: 10 Cov Kauj Ruam
Video: Yuam Kev Ua Koj Sev - Pajai Yang/Paj Ntsais Yaj (Official Music Video) 2024, Hlis ntuj nqeg
Anonim
Ua Haujlwm Nrog URL API hauv Node-RED
Ua Haujlwm Nrog URL API hauv Node-RED

Cov lus qhia no yuav qhia koj yuav siv URL API li cas (http tau txais) hauv node-RED. Nws yog txhob txwm yooj yim. Thiab yog tias koj tseem tshiab rau node-RED ces qhov piv txwv no yog rau koj. Kuv yuav qhia koj yuav siv node-RED ib puag ncig thiab yog dab tsi, thiab yuav siv URL API li cas.

Rau kev qhia lub hom phiaj kuv yuav siv NETIO 4Txhua lub ntsej muag ntse ntse, tab sis tsis txhob txhawj NETIO muaj qhov zoo hauv online demo uas peb yuav siv yog li koj tsis tas yuav yuav dab tsi.

Kauj ruam 1: URL API

*Rau kev qhia lub hom phiaj Kuv yuav piav qhia nrog lub hwj chim ntse NETIO 4All

Cov hlua ntawm cov cim tau txais los ntawm NETIO lub cuab yeej hauv URL tau muab faib ua cov lus txib ib leeg thiab cov cuab yeej tom qab teeb nws cov txiaj ntsig rau lub xeev xav tau raws li tus lej ua.

Kev ua nrog cov zis:

  • 0 = Cov zis tso tawm (Tawm)
  • 1 = Cov zis tau qhib rau (On)
  • 2 = Cov zis tawm rau lub sijhawm luv (luv luv)
  • 3 = Cov zis tau qhib rau lub sijhawm luv (luv luv)
  • 4 = Cov zis hloov pauv los ntawm ib lub xeev mus rau lwm qhov (toggle)
  • 5 = Lub xeev tso tawm tsis hloov (tsis hloov)

URL API piv txwv (toggles lub xeev cov zis 1):

netio-4all.netio-products.com:8080/netio.cgi?pass=netio-psw&output1=4

Kauj Ruam 2: Node-RED

Node-RED
Node-RED

Tab sis dab tsi yog node-RED?

Node-RED yog lub cuab yeej rau kev txuas ua ke cov cuab yeej kho vajtse, APIs thiab kev pabcuam online hauv txoj hauv kev tshiab thiab nthuav. Node-RED muab qhov browser-based flow editor thiab xaiv dav ntawm cov nodes thiab kev xaiv.

Nws tau tsim ntawm Node. JS, ua rau nws zoo tagnrho rau kev ua haujlwm ntawm tus nqi qis xws li Raspberry Pi ntxiv rau hauv huab.

Node-RED yog lub platform nrov rau IoT (Internet ntawm Yam) kev thov. Kev ntws (uas yog, tsab ntawv lossis ib qhov project) tuaj yeem hloov pauv tau yooj yim raws li teeb tsa json cov ntaub ntawv.

Kauj ruam 3: Txaus

Txaus
Txaus

Thiab tam sim no qhov tseem ceeb. Nov yog yuav ua li cas node-RED ib puag ncig zoo li. Hauv cov kauj ruam tom ntej kuv yuav qhia koj yuav ua li cas ntshuam ntws.

Raws li koj tuaj yeem pom Node-RED muab qhov browser-based flow editor uas ua rau nws yooj yim rau xaim ua ke ntws siv ntau yam ntawm cov nodes hauv cov xim. Cov dej ntws tuaj yeem xa mus rau lub sijhawm ua haujlwm hauv ib-nias.

JavaScript lub luag haujlwm tuaj yeem tsim nyob hauv tus kws kho mob siv cov ntawv nplua nuj. Lub tsev qiv ntawv built-in tso cai rau koj khaws cov haujlwm muaj txiaj ntsig, tus qauv lossis cov dej ntws rov los siv dua.

Kauj Ruam 4: Yuav Ua Li Cas Txaus Ntshai - Kauj Ruam 1

Yuav ua li cas ntshuam Flow - Kauj Ruam 1
Yuav ua li cas ntshuam Flow - Kauj Ruam 1

Hauv cov ntawv qhia zaub mov, xaiv Ntshuam -> Clipboard.

Kauj Ruam 5: Yuav Ua Li Cas Txaus Ntshai - Kauj Ruam 2

Yuav ua li cas ntshuam Flow - Kauj Ruam 2
Yuav ua li cas ntshuam Flow - Kauj Ruam 2

Tom qab ntawd, theej cov ntawv hauv qab no mus rau qhov chaw qhia thiab nyem Ntshuam.

[{"id": "53632275.7d628c", "type": "tab", "label": "NETIO AN29 (URL API)", "xiam oob qhab": tsis tseeb, "info": ""}, {"id": "bf404b4d.c9abf8", "type": "http request", "z": "53632275.7d628c", "name": "HTTP Request (GET)", "method": "GET", "ret": " txt "," url ":" https://netio-4all.netio-products.com:8080/netio.cgi?pass=&{{msg.payload}} "," tls ":" "," x ": 600, "y": 160, "xov hlau":

Kauj Ruam 6: Txhim Kho Qhov Tsis Pom Zoo

Txhim Kho Qhov Tsis Muaj Cov Ntsiab Lus
Txhim Kho Qhov Tsis Muaj Cov Ntsiab Lus
Txhim Kho Qhov Tsis Muaj Cov Ntsiab Lus
Txhim Kho Qhov Tsis Muaj Cov Ntsiab Lus

Cov nodes raug thauj mus rau qhov kev xaiv uas tau xaiv. Nws muaj peev xwm hais tias cov lus yuam kev tau tshwm nrog cov npe ntawm cov khoom thaiv uas tau raug xa tab sis tseem tsis tau teeb tsa hauv Node-RED tseem. Hauv qhov no, cov thaiv uas ploj lawm yuav tsum tau teeb tsa. Yog tias muaj cov nodes uas ploj lawm, xaiv Manage palette hauv cov ntawv qhia zaub mov.

Tom qab ntawd xaiv Nruab thiab nrhiav thiab teeb tsa cov node koj ploj lawm.

Kauj ruam 7: Dashboard

Dashboard
Dashboard
Dashboard
Dashboard

Dashboard yog Graphical interface uas koj tuaj yeem ua haujlwm koj li haujlwm yog tias koj xav tau.

Lub Dashboard tuaj yeem qhib los ntawm txhaj lub cim qhia, lossis ntawm qhov chaw nyob ntawm koj li Node-RED server nrog ui txuas ntxiv, piv txwv: 127.0.0.1:1880/ui

Kauj Ruam 8: Nws Ua Haujlwm Li Cas

Nws Ua Haujlwm Li Cas
Nws Ua Haujlwm Li Cas
Nws Ua Haujlwm Li Cas
Nws Ua Haujlwm Li Cas
  • Tsib lub khawm tsim hauv Flow tau tshwm rau hauv Dashboard.
  • Tom qab nyem qhov Output 1 = ON khawm hauv Dashboard, qhov them nyiaj tau teeb tsa rau 1 (txhais hauv txhua tus khawm kom txhawm rau txheeb xyuas qhov ua).
  • Qhov Action Selector node xaiv txoj hlua uas sib haum rau qhov kev nqis tes ua (nkag mus rau qhov them nyiaj) thiab tsim qhov URL qhov tshwm sim rau kev tswj hwm lub qhov hluav taws xob ntse.
  • Qhov Kev Thov HTTP (Tau Txais) node sib txuas tus IP chaw nyob + kev nqis tes ua los ntawm tus nqi them tus nqi nkag, thiab xa cov txiaj ntsig uas tau siv HTTP Tau Txais Kev Thov. Cov lus teb server (xwm txheej) raug xa rov qab raws li qhov tso tawm.
  • msg.payload node qhia cov lus teb los ntawm HTTP server khiav hauv netio 4Txhua yam khoom siv.
  • Thiab Cov Lus Teb los ntawm server node qhia cov lus teb server hauv Dashboard

Kauj Ruam 9: Cov Ntsiab Lus Hais Txog Saum Toj thiab Lawv Cov Chaw

Nodes Hais Txog Saum Toj thiab Lawv Cov Chaw
Nodes Hais Txog Saum Toj thiab Lawv Cov Chaw
Nodes Hais Txog Saum Toj thiab Lawv Cov Chaw
Nodes Hais Txog Saum Toj thiab Lawv Cov Chaw
Nodes Hais Txog Saum Toj thiab Lawv Cov Chaw
Nodes Hais Txog Saum Toj thiab Lawv Cov Chaw

Kauj Ruam 10: Cov Lus Qhia Ntxiv

Ua tsaug rau koj nyeem kuv cov lus qhia. Kuv vam tias koj nyiam nws thiab kawm tau qee yam tshiab.

Cov lus qhia no tau qhia sai ntawm Yuav siv URL API li cas nrog node-RED

Rau cov lus qhia ntxaws nyem rau ntawm qhov link hauv qab no.

www.netio-products.com/en/application-notes/an29-node-red-example-of-url-api-communication-with-netio-4x

Tsis tas li muaj cov lus qhia zoo ib yam txog ntau yam kev siv ntawm node-RED yog li yog koj xav paub xav tshawb fawb ntxiv:

Ua haujlwm nrog REST JSON hauv node-RED

www.netio-products.com/en/application-notes/an30-node-red-example-of-rest-json-communication-with-netio-4x

Ua haujlwm nrog REST XML hauv node-RED

www.netio-products.com/en/application-notes/an31-node-red-example-of-rest-xml-communication-with-netio-4x

Ua haujlwm nrog TCP/Modbus hauv node-RED

Yuav los sai sai

Pom zoo: