Cov txheej txheem:

RaspberryPi Tsev Automation Siv OpenHAB: 9 Cov Kauj Ruam
RaspberryPi Tsev Automation Siv OpenHAB: 9 Cov Kauj Ruam

Video: RaspberryPi Tsev Automation Siv OpenHAB: 9 Cov Kauj Ruam

Video: RaspberryPi Tsev Automation Siv OpenHAB: 9 Cov Kauj Ruam
Video: Marlin Firmware 2.0.x Explained 2024, Hlis ntuj nqeg
Anonim
RaspberryPi Tsev Automation Siv OpenHAB
RaspberryPi Tsev Automation Siv OpenHAB

Tsev automation siv Raspberry Pi 3B thiab OpenHAB. [Tsis teb los tau] Peb yuav siv Google Tsev (lossis Google Assistant) los pab tswj lub suab.

Kauj Ruam 1: Qhov Yuav Tsum Tau

Rau qhov project no peb yuav xav tau-

HARDWARE

  1. Raspberry Pi (Kuv siv 3B board)
  2. Google Tsev Mini [Tsis teb los tau) (Koj tuaj yeem siv tus pabcuam ib yam nkaus!)
  3. Jumper Hlau
  4. Relay Module

SOFTWARE

  1. OpenHABian Pi [Koj tuaj yeem siv Raspbian OS ib yam nkaus]
  2. IFTTT

Kauj ruam 2: Pib Nrog Software Xav Tau

Koj muaj ob qho ntawm cov kev xaiv hauv qab no-

  1. Flash Raspbian thiab tom qab ntawd nruab OpenHAB rau nws. (Txaus siab thiab tsis zoo)
  2. Ncaj nraim qhib OpenHABian mus rau SD daim npav thiab khiav ncaj qha (Damn Easy)

Kuv siv qhov kev xaiv thib ob thiab qhib OpenHABian mus rau SD-daim npav thiab muab tso rau hauv RPi. Yog li kuv yuav tham txog txoj hauv kev no. Yog tias koj xav ua raws thawj tus, ua raws phau ntawv qhia no, Kev Nruab Nrab.

Lwm yam ua raws cov theem hauv qab no:

  • Rub tawm qhov tseeb OpenHABian cov duab system.
  • Nyem nws mus rau SD-daim npav siv Etcher.io
  • Tom qab ua tiav qhov ua tiav, muab daim npav SD rau hauv Rpi thiab txuas Ethernet rau Rpi. (Koj kuj tseem tuaj yeem siv WiFi).
  • Nkag mus rau Rpi. Koj tsis xav tau lub vijtsam thiab/lossis nas thiab keyboard li SSH thiab Samba tau qhib lawm!
  • Tos 30-45 feeb rau OpenHAB kom ua tiav nws qhov kev teeb tsa thawj zaug.
  • Tom qab ntawd, mus rau https:// openhabianpi: 8080 Qhov no yuav yog qhov chaw nyob ntawm koj Rpi los ntawm qhov chaw koj tuaj yeem nkag mus tau.

Qhov ntawd yog txhua yam rau thawj ntu kev teeb tsa.

Configuring OpenHAB

Tom qab OpenHAB ua tiav nws qhov kev teeb tsa thawj zaug, mus rau https:// openhabianpi: 8080

  • Muaj kev mus rau Paper UI.
  • Muaj, mus rau Addons> Bindings. Tshawb nrhiav GPIO hauv kab tshawb nrhiav. Nruab GPIO losis tswvyim dabtsi. Tom qab ntawv mus rau MISC tab thiab teeb tsa openHAB Cloud Connector.

Kauj Ruam 3: teeb tsa OpenHAB -Ua Khoom

Tam sim no peb yuav tsum nkag mus rau peb Rpi los ntawm SSH. Kuv yuav siv PuTTY. Yog tias koj nyob ntawm MacOS lossis Linux, koj tuaj yeem siv davhlau ya nyob twg.

SSH dhau PuTTY-

  • Qhib PuTTY.
  • Mus rau koj tus router tus thawj tswj hwm nplooj ntawv thiab nrhiav tus IP chaw nyob. Nws yuav raug hu ua OpenHABian.
  • Luam tus IP chaw nyob thiab muab tso rau hauv PuTTY thiab nyem Qhib.
  • Tam sim no koj yuav tsum nkag mus -
  • ID nkag mus li: openhabianpassword: openhabian
  • Tom qab nkag mus, ntaus cov lus txib hauv qab no-
  • $ cd /etc /openhab2 $ ls
  • Tam sim no nws yuav qhia koj txhua cov npe muaj. Peb yuav siv - cov khoom (los tsim cov khoom sib txawv), cov cai (kom qhib lub suab hais kom ua) thiab cov vev xaib (kom tsim lub vev xaib rau kev taw qhia). Peb yuav tsim qhov chaw nyob raws li -home.sitemap. Cov ntaub ntawv yuav yog - home.items. Thiab cov ntaub ntawv cov cai yuav yog - home.rules.
  • $ sudo nano khoom/home.items $ password: openhabian
  • Qhov no yuav qhib daim ntawv dawb paug. Peb yuav nyob ntawm no, tsim peb cov khoom uas peb yuav tswj hwm los ntawm Rpi. Hauv kuv qhov xwm txheej, kuv siv 4 yam khoom. Koj tuaj yeem siv ntau npaum li koj xav tau.

  • // Cov Khoom Hloov Cov kiv cua "Ntxuam" {gpio = "pin: 17 activelow: yog initialValue: qis"} Hloov night_light "Night Lamp" {gpio = "pin: 27 activelow: yog initialValue: high"} Hloov cov pa "Tso kiv cua "{gpio =" pin: 23 activelow: yog initialValue: high "} Hloov lub teeb" Teeb "{gpio =" pin: 5 activelow: yog initialValue: low "}

    Txoj hlua VoiceCommand

Ntawm no, kuv yuav piav qhia qhov saum toj no nrog piv txwv- Hloov kiv cua "Ntxuam" {gpio = "tus pin: 17 activelow: yog initialValue: tsawg"} Dab tsi tshwm sim ntawm no yog raws li hauv qab no-

  • Hloov - nws yog lo lus tseem ceeb uas txhais tau tias yam khoom yog hloov.
  • kiv cua (generic - npe nws txhua yam koj xav tau) - nws yog tus neeg siv tus cim qhia rau npe cov khoom sib txawv uas ib tus xav tswj.
  • "Kiv cua" (generic - npe nws txhua yam koj xav tau) - nws yog lub npe zaub uas yuav tshwm rau hauv UI.

  • (lub npe cim)- Nws yog lub npe ntawm lub cim uas yuav tshwm nrog rau lub npe.
  • {gpio = "pin: 17 activelow: yog initialValue: low"} - ntawm no gpio yog qhov uas qhia OpenHAB tias cov khoom txuas nrog los ntawm gpio. tus pin: 17 yog tus pin uas koj txuas txuas rau. activelow: yog (lossis tsis yog) - Qes qis txhais tau hais tias thaum qhov hloov pauv tawm yuav tsis muaj qhov hluav taws xob siv rau tus pin gpio thiab thaum hloov mus rau ntawm yuav muaj qhov siv hluav taws xob. initialValue: siab (lossis qis) - Tom qab ntawd yog qhov pibValue thiab qhov no ua li cas yog qhia qhib rau dab tsi los teeb tsa tus nqi pib ntawm yam khoom thaum pib. Qhov no tau teeb tsa siab vim tias kuv xav kom hloov mus rau thaum lub sijhawm pib.
  • Txoj hlua VoiceCommand - nws yog cov khoom uas yuav siv los tswj hwm lwm yam khoom siv lub suab hais kom ua.
  • Koj tuaj yeem tsim ntau yam khoom raws li koj xav siv cov syntax-
  • ntaus yam khoom-npe "yam khoom-display_name" {gpio = "tus pin: tus pin-tsis muaj activelow: (yog lossis qis) thawj tus nqi: (siab lossis qis)
  • Tom qab ua qhov no, nias Ctrl+X, tom qab ntawd Y thiab Nkag mus.
  • cd ua $..

Kauj Ruam 4: Tsim Tus Kheej Sitemap

Sitemap yuav raug siv rau kev taw qhia thiab kev tswj ntawm cov hloov pauv.

  • Xav tias koj tab tom txuas ntxiv tom qab ua tiav cov kauj ruam saum toj no, ntaus hauv cov davhlau ya nyob twg
  • $ sudo nano sitemaps/home.sitemap
  • Cov ntaub ntawv no yuav yog lub vev xaib raug cai rau kev taw qhia. Cov lus txib saum toj no yuav qhib cov ntaub ntawv tsis muaj dab tsi. Koj yuav tsum tsim lub vev xaib raws li hauv qab no-

sitemap daim ntawv lo tsev = "Smart Home"

{

Ncej daim ntawv lo = "Kuv Chav" {

Hloov cov khoom = kiv cua

Hloov cov khoom = lub teeb

Hloov cov khoom = tso tawm

Hloov cov khoom = hmo ntuj_ teeb

}

}

  • sitemap home label = "Smart Home (generic use anything you want)" - qhov no yog lub npe ntawm lub vev xaib. Koj tuaj yeem siv txhua yam koj xav tau.
  • Ncej daim ntawv lo = "Kuv Chav (siv txhua yam koj xav tau)" - qhov no yuav yog ntu ntu. Nws lub taub hau tuaj yeem yog txhua yam koj xav tau.
  • Hloov cov khoom = kiv cua - qhov no nrog rau lwm tus yuav txhais cov khoom koj xav pom thiab tswj los ntawm lub vev xaib. Koj yuav tsum nkag mus rau yam khoom-npe peb tsim. TSIS TXHOB NPAJ Lub Npe Lub Npe Ntawm Cov Khoom.
  • Tom qab nias no, CTRL+X, Y thiab Enter.

Kauj Ruam 5: Tsim Txoj Cai rau VoiceCommand-

Rau qhov no, koj yuav tsum tsim txoj cai yooj yim. Kuv siv cov ntaub ntawv los ntawm phau ntawv qhia no. Yog li rau lub suab hais kom ua, cia tsim cov cai txoj cai yooj yim-

$ sudo nano cov cai/home.rules

Qhov no yuav tsim cov ntaub ntawv tsis raug.rules.

Koj tuaj yeem nkag tau cov ntaub ntawv cov cai ntawm no

Zoo, qhov no yog tus lej ntev nrog ntau cov ntaub ntawv thiab cov lus txib. Tab sis koj tsuas yog yuav tsum xav txog cov hauv qab no los tsim koj tus kheej cov lus txib.

  • yog (command.contains ("tig rau kiv cua") || (command.contains ("tig rau kiv cua"))) - ntawm no kuv tau teev ob qhov kev xaiv uas kuv tuaj yeem hais kom ua cov lus txib ua haujlwm. Dab tsi tshwm sim hauv qhov tseeb yog, thaum kuv hais kab tshwj tseg, OpenHAB lees paub nws thiab tshawb xyuas rau txoj cai tshwj xeeb los ua dab tsi tshwm sim tom ntej.
  • fan.sendCommand (ON) - Thaum qhov xwm txheej saum toj no muaj tseeb, txoj haujlwm no xa cov lus txib ON rau cov khoom ntxuam. Qhov no tuaj yeem hloov kho raws li koj xaiv.

Zoo, yog tias koj tau ua rau ntawm no yam tsis muaj teeb meem, Zoo siab, vim tias feem ntau ntawm txoj haujlwm tau ua tiav. Tam sim no peb yuav tsum teeb tsa UI thiab ua kom muaj kev nkag mus deb rau peb OpenHAB.

Kauj Ruam 6: Teeb tsa BasicUI

Tam sim no, peb yuav tsum qhia rau OpenHAB kom siv cov sitemap peb tsim los siv nws ua qhov qub.

Nov yog yuav ua li cas-

  • Mus rau https:// openhabianpi: 8080
  • Qhib Ntawv UI
  • Configurations> Services> UI> Configure Basic UI
  • Ntawm no koj tuaj yeem xaiv lub ntsiab lus thiab lub cim cim, thiab lwm yam. Qhov tseem ceeb tshaj plaws uas koj yuav tsum tau ua yog hloov lub sitemap lub neej ntawd mus tsev
  • Nyem Txuag
  • Koj tuaj yeem saib nws los ntawm kev mus rau https:// openhabianpi: 8080
  • Nyem rau ntawm Basic UI thiab voila koj yuav pom koj tus kheej lub vev xaib nyob ntawd

Kauj Ruam 7: Pab Kom Nkag Mus Rau Cov Chaw Taws Teeb

Txhawm rau pab kom nkag mus tau deb, ua raws cov theem no-

  • Mus rau https:// openhabianpi: 8080
  • Qhib Ntawv UI
  • Kev teeb tsa> Kev Pabcuam> IO> Kho Kho Mob OpenHAB Cloud
  • Hloov hom rau Cov Ntawv Ceeb Toom thiab Kev Nkag Mus Rau Chaw Nyob, Hauv paus URL -> https://myopenhab.org/ thiab cov khoom kom nthuav tawm -> Xaiv tag nrho lawv
  • Nyem Txuag
  • Mus rau
  • Sau npe nrog email chaw nyob thiab tus password.
  • Rau openHAB UUID ->
  • $ sudo nano/var/lib/openhab2/uuid
  • Luam thiab muab cov UUID no tso rau hauv kab ntawv UUID.
  • Rau OpenHAB zais->
  • $ sudo nano/var/lib/openhab2/openhabcloud/zais
  • Luam thiab muab nws tso rau hauv kab lus zais thiab ntaus Sau Npe.
  • Tam sim no tom qab Rpi rov pib ua tiav, koj yuav pom cov xwm txheej zoo li online hauv thehttps://myopenhab.org
  • Mus rau cov khoom tab
  • Ntawm no koj tuaj yeem pom tag nrho koj cov khoom koj tsim. Yog tias koj tsis pom dab tsi, koj yuav tsum toggle tag nrho cov khoom yam tsawg ib zaug.

Kauj ruam 8: HARDWARE !!

HARDWARE !!!!
HARDWARE !!!!

Ua tib zoo saib, vim tias peb yuav tau tuav 220V thiab lwm yam khoom siv hluav taws xob.

CUAB TSHUAJ

Koj yuav ua qhov no ntawm koj tus kheej RISK

Txuas Txuas Txuas mus rau Raspberry Pi-

Txhawm rau txuas qhov txuas mus rau Raspberry Pi, txuas VCC rau 5V ntawm Rpi.

  • Txuas GND ntawm kev xa mus rau GND ntawm Raspberry Pi
  • Tom ntej txuas IN1, IN2, … mus rau GPIO muab rau hauv home.items

Txhawm rau txheeb xyuas yog tias txhua yam ua haujlwm, mus rau BasicUI thiab sim tua thiab ntawm cov khoom sib txawv. Koj yuav tsum hnov lub suab Nyem rau ntawm txhua qhov toggle.

Koj tseem tuaj yeem rub tawm OpenHAB app los ntawm Play Store kom tswj tau yooj yim ntawm koj li Automation System.

Ceev faj thiab ua raws li koj qhov kev pheej hmoo ntawm tus kheej

Tam sim no peb yuav tsum txuas cov xov hlau ntawm cov khoom siv uas koj xav tau siv lub tshuab hloov mus rau qhov hloov pauv. Tua Rpi thiab Cov Khoom Tseem Ceeb ua ntej ua qhov no kom nyob nyab xeeb dua.

Tom qab txuas cov xov hlau, xyuas kom tseeb tias tsis muaj xov hlau nyob sab laug uas tsis pom uas yuav ua pov thawj tias ua rau tuag taus.

Tam sim no tig rov qab rau koj Rpi thiab muab sijhawm rau khau raj. Tom qab khau raj, koj yuav tuaj yeem tswj cov cuab yeej siv los ntawm Basic UI lossis los ntawm mobile app. Yog tias koj tsis xav tau lub suab siv lub tshuab, koj tsis tas yuav ua raws cov kauj ruam net.

Kauj Ruam 9: Txuas Nrog Google Assistant

Rau qhov no peb yuav siv

  • Mus rau IFTTT.com
  • Tsim ib tus as khauj yog tias koj tsis muaj
  • Nyem rau ntawm Applet tshiab
  • Xaiv Qhov no thiab xaiv Google Assistant thiab xaiv Hais ib kab lus nrog cov ntawv sau
  • Koj xav hais dab tsi, nkag mus- Tig $ yam khoom-npe Ex- Tig $ tus kiv cua
  • Nyem tsim txhais
  • Xaiv qhov ntawd thiab xaiv OpenHAB. Txuas koj tus account
  • Xaiv xa cov lus txib Xaiv cov khoom raws li VoiceCommand
  • Hais kom xa raws li - Tig {{TextField}} cov khoom npe. Ex-Turn {{TextField}} tus kiv cua
  • Tsim Kev Ua

Muab ib ncig 10 vib nas this rau nws kom pib thiab tom qab ntawd Voila, siv google tus pab xa cov lus txib.

Qhov ntawd yog nws. Yog tias koj muaj kev ua xyem xyav lossis muaj qhov ua yuam kev xav tawm tswv yim. Kuv yuav pab koj kom paub tseeb.

Yog tias koj muaj teeb meem lossis lus nug, thov hu rau kuv ntawm [email protected]

Pom zoo: