【教程-智能家居】通过Siri用树莓派和homekit进行交互

本教程详细介绍了如何利用树莓派2或3,配合HomeKit和Siri来实现智能家居的交互。首先,确保运行的是Jessie系统,然后配置并测试Python代码以控制LED灯的开关。接着,安装forever以实现自动运行代码。最后,设置HAP-NodeJS开机自启,完成与Homekit的连接。参考提供的链接获取更多资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目前已知实验成功的树莓派版本为:树莓派2和3

由于我是用Word排版的,直接复制粘贴,因此部分命令可能缺少空格,请注意!


This tutorial only works with Jessie

(此教程只适用于Jessie版本!)

STEP 1
如何安装HAP_Nodejs
(不要安装在/root文件夹下面)
sudo apt-get update
sudo 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-arm.herokuapp.com/node_latest_armhf.deb
dpkg -i node_latest_armhf.deb
node -v
npm -v
git clone https://github.com/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.js
copy 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: "Bl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值