Cov txheej txheem:

WebApp Tswj Tus Neeg Ua Haujlwm Lub Rooj Sib Tham Ntxiv-on (IoT): 20 Cov Kauj Ruam (nrog Duab)
WebApp Tswj Tus Neeg Ua Haujlwm Lub Rooj Sib Tham Ntxiv-on (IoT): 20 Cov Kauj Ruam (nrog Duab)

Video: WebApp Tswj Tus Neeg Ua Haujlwm Lub Rooj Sib Tham Ntxiv-on (IoT): 20 Cov Kauj Ruam (nrog Duab)

Video: WebApp Tswj Tus Neeg Ua Haujlwm Lub Rooj Sib Tham Ntxiv-on (IoT): 20 Cov Kauj Ruam (nrog Duab)
Video: Наука о данных с Python! Анализ типов файлов от Avro до Stata 2024, Kaum ib hlis
Anonim
WebApp Controlled Gate Operator Add-on (IoT)
WebApp Controlled Gate Operator Add-on (IoT)
WebApp Controlled Gate Operator Add-on (IoT)
WebApp Controlled Gate Operator Add-on (IoT)
WebApp Controlled Gate Operator Add-on (IoT)
WebApp Controlled Gate Operator Add-on (IoT)

Kuv muaj tus neeg siv khoom uas muaj thaj chaw ib puag ncig uas muaj coob tus neeg xav tau los thiab mus. Lawv tsis xav siv lub keyboard nyob sab nraud thiab tsuas muaj tsawg tus xov tooj ntawm cov keyfob xa mus. Nrhiav qhov peev txheej pheej yig rau keyfobs ntxiv yog qhov nyuaj. Kuv xav tias nws yuav yog lub sijhawm zoo los hloov kho tus neeg nqa khoom lub rooj vag Liftmaster no los ua IoT sib xws nrog kev cai kho vajtse, web API, thiab web app interface. Qhov no tsis tsuas yog daws qhov teeb meem nkag mus tau ntau nws tau qhib kev ua haujlwm ntxiv thiab!

Hauv daim duab kawg saum toj no yog chav ntsuas uas kuv tau siv yuav luag ib xyoos hauv lub hnab ziplock. Kuv xav tias nws yog lub sijhawm rau kev txhim kho!

Nov yog kev ua haujlwm tiav nrog txhua txoj cai, cov ntaub ntawv kho vajtse, thiab cov qauv tsim nyob ntawm no.

Tag nrho cov phiaj xwm cov ntaub ntawv tseem muaj nyob ntawm GitHub: github.com/ThingEngineer/IoT-Gate-Operator-Addon

Ib qho piv txwv ntawm CodeIgniter WebApp interface tau teeb tsa ntawm no: projects.ajillion.com/gate Qhov piv txwv no tsis txuas nrog lub rooj vag nyob tab sis yog qhov cuam tshuam ncaj qha thiab tus lej uas ua haujlwm ntawm lub rooj vag (rho tawm qee yam kev nyab xeeb).

--

Rau kev koom ua ke ntau dua koj tuaj yeem siv IFTTT lub tsev qiv ntawv rau Electric Imp.

Kauj Ruam 1: Sau Cov Khoom

Sau Qhov Chaw
Sau Qhov Chaw
  • Koj yuav xav tau Hluav Taws Xob IMP nrog tsawg kawg 4 GPIOs muaj, Kuv siv IMP001 nrog rau lub Plaub Hlis pawg thawj coj tawm.
  • Tus tswj hwm kom tso lub zog qhov hluav taws xob qis rau 5V. Kuv tab tom siv DC-DC Buck Converter Step Down Module. eBoot's MP1584EN version los ntawm Amazon.
  • Ib tus qauv sib txuas ob (lossis ntau dua) lossis cov khoom siv sib xws uas yuav ua haujlwm nrog IMPs cov zis. Kuv siv qhov no JBtek 4 Channel DC 5V Relay Module los ntawm Amazon.
  • 4 hlau ntsia hlau dav hlau. Kuv siv qhov no 5Pcs 2 Kab 12P Hlau Txuas Txuas Ntsia Hlau Terminal Barrier Thaiv 300V 20A los ntawm Amazon.

Kauj ruam 2: Cov khoom siv

Khoom siv
Khoom siv

Koj tseem yuav xav tau:

  • Nkag mus rau lub tshuab luam ntawv 3D lossis lub thawv me me
  • 4 cov ntsia hlau me txog 4mm x 6mm rau rooj plaub hau
  • Hookup hlau
  • Hlau txiav
  • Cov hlua hlau
  • Cov ntsia hlau me me
  • Soldering hlau
  • Kub kua nplaum los yog silicone
  • Zip kev sib txuas

Kauj Ruam 3: Qhov Loj Li Cas

Loj Li Cas
Loj Li Cas

Layout koj qhov chaw txhawm rau txiav txim siab qhov loj me uas koj xav tau. Nrog cov txheej txheem raws li daim duab Kuv yuav xav tau rooj plaub uas yog li 140mm dav, 70mm tob, thiab 30mm siab.

Kauj Ruam 4: Hlau DC-DC Hloov

Hlau DC-DC Converter
Hlau DC-DC Converter

Txiav 3 khub xim liab thiab dub txuas rau kev txuas hluav taws xob hauv thiab tawm ntawm DC-DC hloov pauv lub rooj tsavxwm.

  • Tswv yim: 100mm
  • Cov zis rau IMP: 90mm
  • Cov zis rau Relay Module: 130mm

Muab lawv tso rau ntawm koj lub rooj tsavxwm raws li qhia.

Kauj Ruam 5: Hlau Fais Fab rau Cov Khoom Siv

Hlau Fais Fab rau Cov Khoom Siv
Hlau Fais Fab rau Cov Khoom Siv
  • Txuas cov tswv yim ntawm DC-DC hloov pauv mus rau ob ntawm cov ntsiab lus ntawm cov ntsia hlau dav hlau thaiv.
  • Siv cov kab hluav taws xob luv 5V tso rau IMP.
  • Cov laug ntev dua 5V cov xov hluav taws xob mus rau qhov txuas txuas.

Kauj Ruam 6: Cov Qauv Txuas Hluav Taws Xob

Hlau Relay Module Cov Tswv Yim
Hlau Relay Module Cov Tswv Yim
  • Txiav 4 x 90mm xov hlau rau kev xa xov module txuas kev sib txuas. Kuv siv 4 xim sib cais kom yooj yim siv tom qab thaum coding.
  • Muab cov xov hlau tso rau qhov txuas qhov txuas nkag mus 1-4 tom qab ntawd mus rau thawj 4 IMP GPIO me ntsis (Pin1, 2, 5, & 7) feem.

Kauj Ruam 7: IMP Power Jumper

IMP fais fab Jumper
IMP fais fab Jumper

Koj yuav xav tau siv lub zog USB thaum koj tab tom pib ua haujlwm thiab ntsuas koj li IMP. Thaum koj ua tiav, nco ntsoov txav lub hwj chim jumper mus rau sab BAT.

Kauj Ruam 8: Cov Txheej Txheem Txheej Txheem Hlau

Hlau Rooj Rooj Zaum Cov Tswv Yim
Hlau Rooj Rooj Zaum Cov Tswv Yim
  • Txiav 2 x 80mm xov hlau rau cov xwm txheej sate inputs.
  • Txuas cov xov hlau mus rau 2 qhov txuas txuas ntxiv.
  • Cov xov hlau txuas mus ntxiv rau IMP GPIO me ntsis (Pin8 & 9) feem.

Kauj Ruam 9: Luam lossis Yuav Case

Luam tawm lossis Yuav Rooj plaub
Luam tawm lossis Yuav Rooj plaub

Koj tuaj yeem rub kuv tus. STL lossis. F3D rau qhov xwm txheej no ntawm GitHub lossis Thingiverse

Yog tias koj tsis muaj kev nkag mus rau lub tshuab luam ntawv 3D qhov xwm txheej me me ntawm qhov haujlwm yuav ua haujlwm.

Kauj Ruam 10: Kho Koj Cov Ntaub Ntawv

Kho Koj Cov Ntaub Ntawv
Kho Koj Cov Ntaub Ntawv

Vim!

Kuv muab qee cov ntawv nkag rau ntawm kuv thiab tsuas yog xim nws nrog lub ntsej muag dub. Yog tias koj tab tom muaj kev txaus siab koj tuaj yeem siv cov xim acrylic, txhuam cov rau tes lossis lwm yam kom ua rau nws nrawm dua.

Kauj Ruam 11: Laum Qhov Rau Cov Hluav Taws Xob

Laum Qhov Rau Cov Xov
Laum Qhov Rau Cov Xov

Laum ib lub qhov me me 10-15 hli nyob rau sab ze ntawm nruab nrab qhov twg txhua qhov xov hlau yuav los ua ke.

Kuv siv Unibit rau qhov huv, du qhov hauv cov yas.

Kauj Ruam 12: Npaj thiab Txhim Kho Cov Txuas Hluav Taws Xob

Npaj thiab Nruab Hookup Cov Xov
Npaj thiab Nruab Hookup Cov Xov
Npaj thiab Nruab Hookup Cov Xov
Npaj thiab Nruab Hookup Cov Xov

Txiav 9 x 5-600mm cov xov hlau rau txuas peb lub cuab yeej mus rau lub rooj tswj hwm lub rooj tsavxwm.

  • 2 rau 24V fais fab nkag
  • 3 rau lub rooj vag xwm txheej (2 lub tswv yim thiab ib qho hauv paus)
  • 2 rau lub teeb liab qhib lub qhov rooj
  • 2 rau lub teeb liab kaw qhov rooj

Twist ua ke txhua pawg ntawm cov npe teev saum toj no siv lub laum. Qhov no yuav ua txhua yam yooj yim dua thiab saib zoo dua.

Sawb thiab txuas txhua lub xov hlau mus rau qhov sib txuas raws li qhia.

Kauj Ruam 13: Txoj Kev Txuas Hookup

Txoj Kev Hookup Cov Xov Tooj
Txoj Kev Hookup Cov Xov Tooj

Txoj kev txuas cov xov hlau txuas los ntawm lub qhov raws li qhia.

Kauj Ruam 14: Mount Cheebtsam

Mount Cheebtsam
Mount Cheebtsam

Muab thiab ntim cov khoom siv nrog cov hlaws me me ntawm cov kua nplaum kub lossis silicone. Tsis txhob siv ntau dhau thaum koj xav tau tshem tawm ib feem, siv kom txaus los tiv thaiv lawv.

Kuv xub xav sau cov ntaub ntawv nrog cov ntawv/tab kom tuav cov laug cam nyob hauv qhov chaw tab sis kuv xav tau kom tau qhov teeb tsa no thiab tsis muaj sijhawm. Ntxiv cov ntawv tso rau hauv koj rooj plaub yuav yog qhov kov zoo.

Kauj Ruam 15: Foob Hookup Cov Hluav Taws Xob

Foob Hookup Hlau
Foob Hookup Hlau

Kaw cov hlua txuas nrog cov kua nplaum kub lossis silicone.

Kauj Ruam 16: Kaw Qhov Case

Kaw rooj plaub
Kaw rooj plaub

Kuv siv me me ~ 4mm ntsia hlau ntawm daim ntawv teev cov ntawv luam tawm 3D no. Yog tias koj txhawj xeeb txog av lossis ya raws tso cov hlaws ntawm silicone lossis cov kua nplaum kub nyob ib puag ncig lub hau ua ntej yuav kaw nws.

Kauj Ruam 17: Nruab rau hauv Tus Neeg Ua Haujlwm Rooj vag

Nruab rau hauv Tus Neeg Ua Haujlwm Rooj
Nruab rau hauv Tus Neeg Ua Haujlwm Rooj
Nruab rau hauv Tus Neeg Ua Haujlwm Rooj
Nruab rau hauv Tus Neeg Ua Haujlwm Rooj

Ntawm lub rooj tsavxwm loj:

  • Nqa ob lub xov hlau txuas nrog rau kev xa tawm 1 mus rau lub davhlau ya nyob twg qhib. (liab/xim av hauv cov duab)
  • Nqa ob lub xov hlau txuas nrog rau kev xa tawm 2 mus rau Qhov Rooj Kaw Qhov Rooj. (daj/xiav hauv cov duab)
  • Nqis ob kab txuas nrog DC-DC hloov pauv cov tswv yim rau 24V cov khoom siv fais fab ntsia hlau txuas (liab/dub hauv cov duab)

Ntawm lub rooj nthuav dav

  • Jumper qhov txuas sib txuas cov ntsia hlau txuas ua ke nrog cov kab me me
  • Txuas lub hauv paus sib txuas mus rau ib qho ntawm cov kev sib txuas txuas cov ntsia hlau txuas (ntsuab hauv cov duab)
  • Txuas 2 lub rooj vag xwm txheej nkag (IMP Pin8 & 9) mus rau qhov txuas ib txwm qhib (TSIS MUAJ) cov ntsia hlau txuas (txho/daj hauv cov duab)

Teem cov xov hlau, zip khi lawv kom zoo thiab nrhiav qhov chaw rau mount lossis teeb tsa koj rooj plaub.

Muaj cov duab ntxiv, daws teeb meem tag nrho, tuav ntawm GitHub chaw cia khoom.

Kauj Ruam 18: Teeb Aux Relay Mode

Teem Aux Relay Mode
Teem Aux Relay Mode

Teem lub chaw pabcuam sib txuas sib txuas raws li qhia hauv daim duab.

Qhov no yuav muab IMP cov cim nws xav tau los txiav txim siab yog tias lub qhov rooj raug kaw, qhib, qhib lossis kaw.

Kauj Ruam 19: Tus Neeg Sawv Cev IMP thiab Cov Cai Ntaus Ntawv

IMP Tus Neeg Sawv Cev thiab Cov Cai Ntaus Ntawv
IMP Tus Neeg Sawv Cev thiab Cov Cai Ntaus Ntawv

Fais Fab Tus Neeg Sawv Cev Cai:

  • Tsim Tus Qauv Tshiab hauv Electric Imp IDE:
  • Hloov URL los taw tes rau ntawm koj lub server

// HTTP tus tuav haujlwm ua haujlwm

muaj nuj nqi httpHandler (req, resp) {sim {hauv zos d = http.jsondecode (req.body); //server.log(d.c); yog (d.c == "btn") {//server.log(d.val); device.send ("btn", d.val); resp.send (200, "OK"); }} ntes (ex) {// Yog tias muaj qhov ua yuam kev, xa rov qab rau hauv server.log teb ("yuam kev:" + ex); resp.send (500, "Internal Server Error:" + ex); }} // Sau npe tus tuav haujlwm HTTP http.onrequest (httpHandler); // GateStateChange tus tuav haujlwm ua haujlwm muaj nuj nqi gateStateChangeHandler (cov ntaub ntawv) {// URL rau lub vev xaib pabcuam hauv zos url = "https://projects.ajillion.com/save_gate_state"; // Teeb Cov Ntsiab Lus-Hom header rau json lub zos headers = {"Content-Type": "application/json"}; // Nkag tau txais cov ntaub ntawv thiab teev lub cev hauv zos = http.jsonencode (cov ntaub ntawv); server.log (lub cev); // Xa cov ntaub ntawv mus rau koj lub vev xaib http.post (url, headers, body).sendsync (); } // Sau npe gateStateChange tus tuav tes.on ("gateStateChange", gateStateChangeHandler);

Fais Fab Tus Neeg Sawv Cev Cai:

  • Muab ib qho cuab yeej Imp rau koj tus qauv
  • Txheeb xyuas cov khoos phis tawj pins yog Aliased raws li txuas nrog

// Debouce lub tsev qiv ntawv

#require "Button.class.nut: 1.2.0" // Alias for gateOpen GPIO pin (active low) gateOpen <- hardware.pin2; // Alias rau gateClose tswj GPIO tus pin (nquag qis) gateClose <- hardware.pin7; // Kho 'gateOpen' los ua cov khoom siv digital nrog tus nqi pib ntawm digital 1 (siab) gateOpen.configure (DIGITAL_OUT, 1); // Kho 'gateClose' los ua cov khoom siv digital nrog tus nqi pib ntawm digital 1 (siab) gateClose.configure (DIGITAL_OUT, 1); // Alias rau GPIO tus pin uas qhia tias lub rooj vag txav mus (NCO) gateMovingState <- Khawm (hardware.pin8, DIGITAL_IN_PULLUP); // Alias rau GPIO tus pin uas qhia tias lub qhov rooj qhib tag nrho (NCO) gateOpenState <- Khawm (hardware.pin9, DIGITAL_IN_PULLUP); // Ntiaj teb tsis sib xws los tuav lub rooj vag xeev (Qhib = 1 / Kaw = 0) localGateOpenState = 0; // Latch Timer object local latchTimer = null agent.on ("btn", function (data) {switch (data.cmd) {case "open": gateOpen.write (0); if (latchTimer) imp.cancelwakeup (latchTimer)); latchTimer = imp.wakeup (1, releaseOpen); server.log ("Qhib cov lus txib tau txais"); tawg rooj plaub "latch30m": gateOpen.write (0); yog (latchTimer) imp.cancelwakeup (latchTimer); latchTimer = imp.wakeup (1800, releaseOpen); server.log ("Latch30m command tau txais"); tawg rooj plaub "latch8h": gateOpen.write (0); yog (latchTimer) imp.cancelwakeup (latchTimer); latchTimer = imp.wakeup (28800, releaseOpen); server.log ("Latch8h hais kom ua tau txais"); tawg rooj plaub "kaw": yog (latchTimer) imp.cancelwakeup (latchTimer); gateOpen.write (1); gateClose.write (0); latchTimer = imp.wakeup (1, releaseClose); server.log ("Kaw tam sim no tau txais cov lus txib"); ua txhaum yav dhau los: server.log ("Khawm hais kom ua tsis tau lees paub");}}); muaj nuj nqi releaseOpen () {yog (latchTimer) imp.cancelwakeup (latchTimer); gateOpen.write (1); //server.log("Timer tso tawm gateOpen hloov kev sib cuag "); } muaj nuj nqi releaseClose () {yog (latchTimer) imp.cancelwakeup (latchTimer); gateClose.write (1); //server.log("Timer tso tawm gateClose hloov kev sib cuag "); } gateMovingState.onPress (muaj nuj nqi () {// Lub relay tau qhib, lub qhov rooj txav mus //server.log("Gate tab tom qhib "); cov ntaub ntawv hauv zos = {" gatestate ": 1," timer ": hardware.millis ()}; agent.send ("gateStateChange", cov ntaub ntawv);}). onRelease (muaj nuj nqi () {// Lub relay raug tso tawm, lub rooj vag nyob ntawm so //server.log("Gate raug kaw "); cov ntaub ntawv hauv zos = {"gatestate": 0, "timer": hardware.millis ()}; agent.send ("gateStateChange", cov ntaub ntawv);}); gateOpenState.onPress (muaj nuj nqi () {// Lub relay tau qhib, lub qhov rooj qhib tag nrho //server.log("Gate tau qhib "); cov ntaub ntawv hauv zos = {" gatestate ": 2," timer ": hardware.millis ()}; agent.send ("gateStateChange", cov ntaub ntawv);}). onRelease (muaj nuj nqi () {// Lub relay raug tso tawm, lub rooj vag tsis qhib tag nrho //server.log ("Rooj vag kaw"); cov ntaub ntawv hauv zos = {"gatestate": 3, "timer": hardware.millis ()}; agent.send ("gateStateChange", cov ntaub ntawv);});

Kauj ruam 20: Web Service PHP Code

Web Service PHP Code
Web Service PHP Code

Kuv tau sau cov cai no rau CodeIgniter moj khaum vim kuv tau ntxiv nws mus rau qhov qub uas twb muaj lawm. Tus tswj hwm thiab saib cov lej tuaj yeem hloov kho tau yooj yim rau lub hauv paus uas koj xaiv.

Txhawm rau ua tej yam yooj yim Kuv tau khaws JSON cov ntaub ntawv rau hauv cov ntaub ntawv tiaj tus rau khaws cov ntaub ntawv. Yog tias koj xav tau kev nkag los lossis cov ntaub ntawv nyuaj uas cuam tshuam txog kev siv lub database.

Lub tsev qiv ntawv ajax kuv tau sau thiab siv hauv txoj haujlwm no tuaj yeem rub tawm los ntawm GitHub chaw cia khoom: ThingEngineer/Codeigniter-jQuery-Ajax

PHP Tus Tswj Xyuas Code:

  • app/controllers/projects.php
  • Ua kom ntseeg tau cov ntaub ntawv nkag tau los ntawm koj tsab ntawv PHP, ob qho chaw thiab nyeem/sau cai.

load-> pab (array ('file', 'date'));

$ data = json_decode (read_file ('../ app/cav/gatestate.data'), TSEEB); hloov ($ data ['gatestate']) {case 0: $ view_data ['gatestate'] = 'Kaw'; tawg; rooj plaub 1: $ view_data ['gatestate'] = 'Qhib…'; tawg; rooj plaub 2: $ view_data ['gatestate'] = 'Qhib'; tawg; rooj plaub 3: $ view_data ['gatestate'] = 'Kaw…'; tawg; } $ last_opened = json_decode (read_file ('../ app/cav/cov phiaj xwm/gateopened.data'), TRUE); $ view_data ['last_opened'] = timespan ($ last_opened ['last_opened'], time ()). 'dhau los'; // Load View $ t ['data'] = $ view_data; $ this-> thauj-> saib ('gate_view', $ t); } muaj nuj nqi save_gate_state () {$ qhov no-> thauj-> pab ('ntawv'); $ cov ntaub ntawv = file_get_contents ('php: // input'); write_file ('../ app/cav/projects/gatestate.data', $ data); $ data = json_decode ($ data, TSEEB); yog ($ data ['gatestate'] == 1) {$ last_opened = array ('last_opened' => time ()); write_file ('../ app/cav/projects/gateopened.data', json_encode ($ last_opened)); }} muaj nuj nqi get_gate_state () {$ qhov no-> thauj-> pab (array ('ntawv', 'hnub tim')); $ this-> thauj-> tsev qiv ntawv ('ajax'); $ data = json_decode (read_file ('../ app/cav/projects/gatestate.data'), TSEEB); $ last_opened = json_decode (read_file ('../ app/cav/cov phiaj xwm/gateopened.data'), TSEEB); $ data ['last_opened'] = timespan ($ last_opened ['last_opened'], time ()). 'dhau los'; $ this-> ajax-> output_ajax ($ data, 'json', FALSE); // xa json cov ntaub ntawv, tsis txhob yuam ajax thov}}/ * Xaus cov ntaub ntawv project.php *// * Qhov chaw:./application/controllers/projects.php */

PHP Saib Code:

Kuv siv Bootstrap rau pem hauv ntej-kawg vim nws nrawm, yooj yim thiab teb tau sai. Koj tuaj yeem rub nws ntawm no: https://getbootstrap.com (suav nrog jQuery)

  • app/cov tswj hwm/gate_view.php
  • Hloov koj li-tus neeg sawv cev-CODE nrog koj tus lej Imp Imp code

IoT Gate Opperator Addon IoT Gate Opperator Addon

  • Tsev
  • Admin

Qhib Rooj Latch Qhib rau 30 min Latch Qhib rau 8 teev Kaw Tam Sim No Qhov Rooj: Qhov kawg qhib $ (daim ntawv). Ready (muaj nuj nqi () {resetStatus ();}) muaj nuj nqi xa JSON (JSONout) {var url = 'https:// agent.electricimp.com/YOUR-AGENT-CODE '; $.post (url, JSONout); } $ ("#open_gate"). nyem (ua haujlwm () {var JSONout = '{"c": "btn", "val": {"cmd": "qhib"}}'; xa JSON (JSONout); $ ("#status"). text ("Qhib …");}); $ ("#latch30m_gate"). nyem (ua haujlwm () {var JSONout = '{"c": "btn", "val": {"cmd": "latch30m"}}'; xa JSON (JSONout); $ ("#status"). text ("Qhib …");}); $ ("#latch8h_gate"). nyem (ua haujlwm () {var JSONout = '{"c": "btn", "val": {"cmd": "latch8h"}}'; xa JSON (JSONout); $ ("#status"). text ("Qhib …");}); $ ("#close_gate"). nyem (ua haujlwm () {var JSONout = '{"c": "btn", "val": {"cmd": "kaw"}}'; xa JSON (JSONout); $ ("#status"). text ("Kaw …");}); muaj nuj nqi resetStatus () {// Lub hom phiaj url var phiaj = 'https://projects.ajillion.com/get_gate_state'; // Thov var cov ntaub ntawv = {tus sawv cev: 'app'}; // Xa ajax xa ntawv thov $.ajax ({url: target, dataType: 'json', ntaus: 'POST', cov ntaub ntawv: cov ntaub ntawv, kev ua tiav: ua haujlwm (cov ntaub ntawv, textStatus, XMLHttpRequest) {hloov (data.gatestate) {rooj plaub 0: $ ("#xwm txheej"). Text ('Kaw'); so; case 1: $ ("#status"). Text ('Opening …'); break; case 2: $ ("#status").text ('Qhib'); so; case 3: $ ("#status"). text ('Kaw …'); so; default: $ ("#status"). text ('Error');} $ ("#last_opened"). text (data.last_opened);}, error: function (XMLHttpRequest, textStatus, errorThrown) {// Error message $ ("#status"). text ('Server Error');}}); setTimeout (resetStatus, 3000); }

Pom zoo: