Siri HomeKit 树莓派4

再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
威锋网7月10日消锋网7月10日消息,《植物大战僵尸2》 如今...
威锋网7月10日消息,《植物大...
近日,开发商 Esquilax Games ..
说到方块游戏,相信有很多朋友应该还会记得 Gavina Games 早...
威锋网7月10日消息,《植物大...
近日,开发商 Esquilax Games ..
说到方块游戏,相信有很多朋友应该还会记得 Gavina Games 早...
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
再吸金!SE推出《最终幻想:全员勇者》钥匙扣
您需要通过验证再能继续浏览 3秒后开始验证
威锋旗下产品
Hi~我是威威!
 粤公网安备 11号
新三板上市公司威锋科技(836555)
增值电信业务经营许可证:
Powered by Discuz!5783人阅读
raspberry pi3(3)
目前已知实验成功的树莓派版本为:树莓派2和3
由于我是用Word排版的,直接复制粘贴,因此部分命令可能缺少空格,请注意!
This tutorial only works with Jessie
(此教程只适用于Jessie版本!)
如何安装HAP_Nodejs
(不要安装在/root文件夹下面)
sudo apt-get updatesudo apt-get upgrade
sudo apt-get remove nodejs-legacy
sudo apt-get install python-dev python-pip
sudo apt-get install libavahi-compat-libdnssd-dev
sudo wget http://node-/node_latest_armhf.deb
dpkg -i node_latest_armhf.deb
git clone /KhaosT/HAP-NodeJS.git
cd HAP-NodeJS
sudo npm install -g node-gyp
sudo npm install node-persist
sudo npm install srp
sudo npm install mdns
sudo npm install ed25519
sudo npm install curve25519-n
sudo npm install debug
sudo npm install python-shell
cd accessories
sudo nano deskLamp_accessory.jscopy this into:
(把下面的代码复制进去)
var PythonShell = require('python-shell');
// HomeKit types required
var types = require(&./types.js&)
var exports = module.exports ={};
var execute = function(accessory,characteristic,value){ console.log(&executed accessory:& + accessory + &, and characteristic: & + characteristic +&, with value: & +
value +&.&); }
exports.accessory = {
displayName: &desk Lamp&,
username: &1A:2B:3C:4D:1E:FF&, #mac addressneeds to be unique
pincode: &031-45-154&,
services: [{
sType: types.ACCESSORY_INFORMATION_STYPE,
characteristics: [{
cType:types.NAME_CTYPE,
onUpdate:null,
perms:[&pr&],
format: &string&,
initialValue: &desk Lamp&, #initialValue needs to besame as displayName
supportEvents: false,
supportBonjour: false,
manfDescription: &Bla&,
designedMaxLength: 255
cType:types.MANUFACTURER_CTYPE,
onUpdate:null,
perms:[&pr&],
format: &string&,
initialValue: &Oltica&,
supportEvents: false,
supportBonjour: false,
manfDescription: &Bla&,
designedMaxLength: 255
cType:types.MODEL_CTYPE,
onUpdate:null,
perms:[&pr&],
format: &string&,
initialValue: &Rev-1&,
supportEvents: false,
supportBonjour: false,
manfDescription: &Bla&,
designedMaxLength: 255
cType:types.SERIAL_NUMBER_CTYPE,
onUpdate:null,
perms:[&pr&],
format: &string&,
initialValue: &A1S2NASF88EW&,
supportEvents: false,
supportBonjour: false,
manfDescription: &Bla&,
designedMaxLength: 255
cType:types.IDENTIFY_CTYPE,
onUpdate:null,
perms:[&pw&],
format: &bool&,
initialValue: false,
supportEvents: false,
supportBonjour: false,
manfDescription: &Identify Accessory&,
designedMaxLength: 1
sType: types.LIGHTBULB_STYPE,
characteristics: [{
cType:types.NAME_CTYPE,
onUpdate:null,
perms:[&pr&],
format: &string&,
initialValue: &Light 1 Light Service&,
supportEvents: false,
supportBonjour: false,
manfDescription: &Bla&,
designedMaxLength: 255
cType:types.POWER_STATE_CTYPE,
onUpdate:function(value)
console.log(&Change:&,value);
if(value) {
PythonShell.run('/python/light1.py', function (err) {
console.log('OnSuccess');
});# light1.py is the python script you want to run when turningon the light
PythonShell.run('/python/light0.py',function (err) {
console.log(&OffSuccess&);
});# light0.py isthe python script you want to run when turning off the light
perms:[&pw&,&pr&,&ev&],
format: &bool&,
initialValue: false,
supportEvents: false,
supportBonjour: false,
manfDescription: &Turn On the Light&,
designedMaxLength: 1
cType:types.HUE_CTYPE,
onUpdate:function(value) { console.log(&Change:&,value); execute(&TestAccessory 1&, &Light - Hue&, value); },
perms:[&pw&,&pr&,&ev&],
format: &int&,
initialValue: 0,
supportEvents: false,
supportBonjour: false,
manfDescription: &Doesn’t actually adjust Hue of Light&,
designedMinValue: 0,
designedMaxValue: 360,
designedMinStep: 1,
unit: &arcdegrees&
cType:types.BRIGHTNESS_CTYPE,
onUpdate:function(value) { console.log(&Change:&,value); execute(&TestAccessory 1&, &Light - Brightness&, value); },
perms:[&pw&,&pr&,&ev&],
format: &int&,
initialValue: 0,
supportEvents: false,
supportBonjour: false,
manfDescription: &Doesn’t actually adjust Brightness ofLight&,
designedMinValue: 0,
designedMaxValue: 100,
designedMinStep: 1,
cType:types.SATURATION_CTYPE,
onUpdate:function(value) { console.log(&Change:&,value); execute(&TestAccessory 1&, &Light - Saturation&, value); },
perms:[&pw&,&pr&,&ev&],
format: &int&,
initialValue: 0,
supportEvents: false,
supportBonjour: false,
manfDescription: &Doesn’t actually adjust Saturation ofLight&,
designedMinValue: 0,
designedMaxValue: 100,
designedMinStep: 1,
mkdir python
nano light1.py
Copy this into:
(复制下面的代码进去)
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(16, GPIO.OUT)
GPIO.output(16, 1)
Save, and close the file
(保存,关闭文件)
nano light0.py
Copy this into:
(复制下面的代码进去)
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(16, GPIO.OUT)
GPIO.output(16, 0)
Save, and close the file
(保存,关闭文件)
Connect a led GND into one of the RPi GND pin. and connect the led &+& pin tho the RPi GPIO.16 pin. That’s the 8 pin in the outer line.
(将led正极接GPIO16引脚,负极接地)
Test the python codes:
(测试下刚才的python代码)
python light1.py
(led should turn on)(led应该点亮)
python light0.py
(led should turn off)(led应该熄灭)
If everything is ok, go back to HAP-NodeJS folder.
(如果一切顺利,回到HAP-NodeJS文件夹)
npm rebuild
node Core.js
Now you can open you Homekit app, parsing it with your accessories!
(现在你可以打开你的homekit软件,开始配对,输入pincode即为deskLamp_accessory.js中的031-45-154)
(Let’ssay we want code.js to run automatically, then we need install forever.)
how to install forever on your Raspberry Pi.
(如何安装forever)
Only install this if you are installing the HAP-NodeJS server
The first command you want to run is:&
The second command you want to run is:&
sudo npm install forever -g
That should complete the installation! Now, you can use the forever command wherever youneed it. Ensure you do use&sudo&or elseit won't work.
cd HAP-NodeJS
sudo forever start Core.js
Then it’s done
Start HAP on Reboot
(开机自启HAP-NodeJS)
Ensure your HAP-NodeJS directory is&/home/pi/HAP-NodeJS
(确保你的HAP-NodeJS安装在/home/pi/HAP-NodeJS文件夹下)
sudo nano /etc/rc.local
Now, you want to add the code before the &exit0& line. Add this line before &exit 0&:
(在&exit 0&前面加上下面这段代码)
cd /home/pi/HAP-NodeJS
sudo forever start Core.jsThen you're ready to go!
(大功告成!)
参考链接:1. &/KhaosT/HAP-NodeJS
& & 2. &/id/Raspberry-Pi-2-Homekit-from-zero-to-Hey-Siri/?ALLSTEPS
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:8642次
排名:千里之外
(window.slotbydup = window.slotbydup || []).push({
id: '4740887',
container: s,
size: '250,250',
display: 'inlay-fix'

我要回帖

更多关于 树莓派 的文章

 

随机推荐