IRKit과 Raspberry Pi로 스마트 홈
10505 단어 RaspberryPiIRKit
IRKit과 Raspberry Pi로 스마트 홈
왜 그랬어?
"Hey Siri"에서 전기, 텔레비전, 에어컨
나는 "Hey Siri"에서 모두 사라지는 타락의 규칙을 만들고 싶다.
그리고 라즈베리 파이 때문에 어쩔 수 없어요.(← 이거야)
환경
iPhone8(iOS12.1)-Raspberry Pi(2ModelB)-Homekit-IRKit-TV, 에어컨 등
- 서버 운영 체제: CentOS7
- 디바이스: iPhone8(iOS12.1), Raspberry Pi(2ModelB), IRKit
- 중간부품: Nodejs
- 소프트웨어: Homebridge
iPhone에서 IRKit 응용 프로그램 사용하기
https://itunes.apple.com/jp/app/irkit%E3%82%B7%E3%83%B3%E3%83%97%E3%83%AB%E3%83%AA%E3%83%A2%E3%82%B3%E3%83%B3/id778790928?mt=8
Raspberry Pi와 IRKit를 연결하여 작동
[centos-rpi2]# curl -i "http://192.168.10.5/messages" -H "X-Requested-With: curl"
HTTP/1.0 200 OK
Access-Control-Allow-Origin: *
Server: IRKit/3.0.0.0.g85190b1
Content-Type: text/plain
{"format":"raw","freq":38,"data":[6881,3458,873,873,873,2537,873,873,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,787,873,2537,873,65535,0,65535,0,18662,6881,3458,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,2537,873,65535,0,65535,0,18662,6881,3458,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,2537,873]}
[centos-rpi2]# curl -i "http://192.168.10.5/messages" -H "X-Requested-With: curl" -d '{"format":"raw","freq":38,"data":[6881,3458,873,873,873,2537,873,873,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,787,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,787,873,2537,873,65535,0,65535,0,18662,6881,3458,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,2537,873,65535,0,65535,0,18662,6881,3458,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,873,873,2537,873,873,873,2537,873,2537,873,2537,873,2537,873,873,873,2537,873]}'
Raspberry Pi에 Homebridge 설정
yum update
wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv6l.tar.gz
tar -xvf node-v4.0.0-linux-armv6l.tar.gz
cd node-v4.0.0-linux-armv6l
cp -R * /usr/local/
# node -v
v4.0.0
# npm -v
2.14.2
# npm install -g homebridge
오류가 발생하면 gcc와 gcc-c++를 설치하고 다시 실행한 후 정상적으로 작동합니다... # yum -y install gcc
# yum -y install gcc-c++
# npm install -g homebridge
# npm install -g homebridge-irkit
# vi /root/.homebridge/config.json
config.json
{
"bridge": {
"name": "Homebridge",
"username": "IRKitのMACアドレス",
"port": 51826,
"pin": "000-00-000"
},
"description": "IRKit Control",
"accessories": [
{
"accessory": "IRKit",
"name": "テレビ",
"irkit_host": "192.168.10.5",
"on_form": {"format":"raw","freq":38,"data":[赤外線の番号]},
"off_form": {"format":"raw","freq":38,"data":[赤外線の番号]}
}
]
}
# homebridge
[12/22/2018, 12:03:05 PM] Loaded config.json with 1 accessories and 0 platforms.
[12/22/2018, 12:03:05 PM] ---
[12/22/2018, 12:03:05 PM] Loaded plugin: homebridge-irkit
[12/22/2018, 12:03:05 PM] Registering accessory 'homebridge-irkit.IRKit'
[12/22/2018, 12:03:05 PM] ---
[12/22/2018, 12:03:05 PM] Loading 1 accessories...
[12/22/2018, 12:03:05 PM] [TV] Initializing IRKit accessory...
Setup Payload:
X-HM://0023N6U4T2F89
Scan this code with your HomeKit app on your iOS device to pair with Homebridge:
┌─────────────┐
│ QRコードが表示│
└─────────────┘
Or enter this code with your HomeKit app on youriOS device to pair with Homebridge:
┌────────────┐
│ 000-00-000 │
└────────────┘
iPhone 홈 APP에 IRKit 등록
[12/22/2018, 12:54:06 PM] Homebridge is running on port 51826.
[12/22/2018, 12:54:31 PM] [TV] Setting power state to on
[12/22/2018, 12:54:31 PM] [TV] IRKit power function succeeded!
[12/22/2018, 12:54:37 PM] [TV] Setting power state to off
[12/22/2018, 12:54:37 PM] [TV] IRKit power function succeeded!
[12/22/2018, 12:55:41 PM] [TV] Setting power state to on
[12/22/2018, 12:55:41 PM] [TV] IRKit power function succeeded!
[12/22/2018, 12:55:54 PM] [TV] Setting power state to off
[12/22/2018, 12:55:54 PM] [TV] IRKit power function succeeded!
그리고 마지막으로
HeySiri! 텔레비전을 켜라!
///텔레비전이 켜졌다!!
참고로 Homebridge의 수호 프로그램화.
vi /etc/default/homebridge
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /root/.homebridge
If you uncomment the following line, homebridge will log more
You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
vi /etc/systemd/system/homebridge.service
[Unit]
Description=Node.js HomeKit Server
After=syslog.target
[Service]
Type=simple
User=root
EnvironmentFile=/etc/default/homebridge
ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl enable homebridge
# systemctl start homebridge
이상
Reference
이 문제에 관하여(IRKit과 Raspberry Pi로 스마트 홈), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ogatea65/items/0ba1b4cf0af635b384ce텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)