brief introduction
In our daily use , The smart device itself supports HomeKit, In other words, users can use Apple's “ family ” Connect the device 、 control . But this operation has obvious limitations , Android phones don't work , And you can't connect to a network that doesn't support HomeKit Linkage of equipment . For example, use iPhone Remote switch home lights ;
take Home Assistant Come on , It's based on Python Smart home open source system , Can support access to many brands of smart devices , However, there are also advantages and disadvantages to a certain extent : The first advantage is centralized management ; Another disadvantage is that it can only be accessed within the LAN , Unable to remotely control through the Internet ;
Many people here don't know , The first comprehensive open source agreement adopting the software characteristics of smart home manufacturers in China , It can run offline in the LAN , And get more powerful functions by binding to zhiting cloud , Rising Rookies . When running in a LAN environment , Users can use zhiting APP Discover and manage zhiting family cloud , Install plug-ins to manage and control the device .
secondly , Through zhiting cloud account , Associate zhiting home cloud devices to the cloud , Then, the device can be controlled on the external network through cloud transfer .
At the same time, it provides the function of direct access to cloud virtual home , It is convenient for users of wuzhiting home cloud devices ; Zhiting cloud also provides an interface for virtual home data migration to physical home .
For families connected to the cloud , Zhiting cloud provides cloud to cloud access , User can authorize a small degree , Tmall elves ,Google Nest And other intelligent speakers directly control the equipment .
Two 、 Install third-party plug-ins
Zhiting family cloud runs on Linux Under the main engine , adopt Docker To deploy and isolate the services . Some of the core service containers need to be pre configured , And it runs automatically with the start of the system ; And plug-ins (plugin) Class services are provided by SA call docker API The way to manage .
After the plug-in starts, it will run a gRPC Service and an optional HTTP service ,SA adopt docker API Monitor the running status of plug-ins , adopt gRPC Interface to get plug-in information , Sample plug-ins for the plug-in implementation tutorial ; Refer to the literature :golang | Zhiting technology development document
Development paradigm
1. Image compilation and deployment
For the time being, only plug-ins installed in image mode are supported , After normal commissioning , Compile into an image and provide it to SA
- Dockerfile The sample reference
FROM golang:1.16-alpine as builder
RUN apk add build-base
COPY . /app
WORKDIR /app
RUN go env -w GOPROXY="goproxy.cn,direct"
RUN go build -ldflags="-w -s" -o demo-plugin
FROM alpine
WORKDIR /app
COPY --from=builder /app/demo-plugin /app/demo-plugin
# static file
COPY ./html ./html
ENTRYPOINT ["/app/demo-plugin"]
- Compile image
docker build -f your_plugin_Dockerfile -t your_plugin_name- Running plug-ins
docker run -net=host your_plugin_name
// Be careful :-net=host Parameter only linux Environment is useful .Contrast HomeBridge: Is a dynamic plug-in , The main function is to make homekit Identify to Home Assistant The connected equipment acts as a bridge .
Homebridge The installation of requires npm, Raspberry pie under the installation npm A little bit of a problem , It will not be described in detail here . Install well npm After installation, just enter the following statements in sequence homebridge And its related dependent packages .
sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp
cd /usr/local/lib/node_modules/homebridge/
sudo npm install --unsafe-perm bignum
cd /usr/local/lib/node_modules/hap-nodejs/node_modules/mdns
sudo node-gyp BUILDTYPE=Release rebuildNext you can install homebridge-mqtt 了 .
npm install -g homebridge-mqtt
On raspberry pie ,Homebridge The configuration of is mainly editing 「/home/pi/.homebridge」 Under the 「config.json」 file . Here is homebridge-mqtt Configuration example .
{
"bridge": {
"name": "Homebridge",
"username": "12:34:56:78:90:AB",
"port": 38960,
"pin": "123-45-678"
},
"platforms": [{
"platform": "mqtt",
"name": "mqtt",
"url": "mqtt://127.0.0.1",
"port": 61613,
"topic_type": "multiple",
"topic_prefix": "homebridge",
"username": "admin",
"password": "password",
"cert": "/path/to/certificate.pem",
"key": "path/to/key.pem",
"ca": "/path/to/ca_certificate.pem"
}]







