node-red-contrib-homekit-bridged 1.2.0

Node-RED nodes to simulate Apple HomeKit devices.

npm install node-red-contrib-homekit-bridged

Do you need help with your setup?

Join us on our Discord server (click on the logo below)!

NRCHKB Discord

⚠️ CAUTION ⚠️

Upgrading from versions 0.X to 1.X is a breaking change, all devices will be reset in the Home app. Please review the release notes thoroughly before updating!

Intro

node-red-contrib-homekit-bridged (aka NRCHKB) is a Node-RED nodes pack to simulate Apple HomeKit devices. The goal is to emulate native HomeKit devices as closely as possible. We rely on community support - please read throught the README for the basics then head over to the wiki page for details and examples. If you're still stuck please open an issue, we are glad to help.

These nodes allow the creation of fully customizable accessories for use in devices supporting HomeKit which are iPhone, iPad, iPod touch, Apple Watch or Mac. If you can get it in Node-RED, you can get it in HomeKit. The goal of the project is to create a platform where official HomeKit hardware can be emulated as closely as possible through node red.

Install

In favour to use NRCHKB which is Node-RED node (plugin) you need Node.js and Node-RED itself installed. The recommended version of Node.js is 10.x (or higher) and for Node-RED you should use the latest version.

For instructions how to install Node-RED go here. Node.js will be installed together with Node-RED.

Easy Install

If you have Node-RED already installed the recommended install method is to use the editor. To do this, select Manage palette from the Node-RED menu (top right). Then select Install tab in the palette. Search for and install this node (node-red-contrib-homekit-bridged).

Using NPM

To install NRCHKB node run the following command in your Node-RED user directory - typically ~/.node-red

npm i node-red-contrib-homekit-bridged

Docker

You can also pull a docker image containing everything needed to get started, thanks to Raymond Mouthaan.

Nodes

Bridge

The Bridge node is a configuration node (means it will be not visible in a flow like other nodes) which will be added from within the service node. It creates the bridge that HomeKit application sees, i.e. the device that is added to the Apple Home app by the user. All accessories behind a bridge node will be added automatically.

Configuration fields:

- Pin Code: Specify the Pin for the pairing process. - Port: If you are behind a Firewall, you may want to specify a port. Cannot be 1880 as it is reserved for node-red. Otherwise, leave empty. - Allow Insecure Request: Should we allow insecure request? Default false. - Manufacturer, Model, Serial Number: Can be anything you want. - Name: Can be anything you want. - Allow Message Passthrough: If you allow then message from node input will be send to node output. - Custom MDNS Configuration: Check if you would like to use custom MDNS configuration. - Multicast: Use udp multicasting. Optional. Default true. - Multicast Interface IP: Explicitly specify a network interface. Optional. Defaults to all. - Port: Set the udp port. Cannot be 1880 as it is reserved for node-red. Optional. Default 5353. - Multicast Address IP: Set the udp ip. Optional. - TTL: Set the multicast ttl. Optional. - Loopback: Receive your own packets. Optional. Default true. - Reuse Address: Set the reuseAddr option when creating the socket. Optional. Default true.

Service

The Service node represents the single device you want to control or query. Every service node can be Parent or Linked. Each Parent service creates an individual accessory in the Home app. Linked services add additional features to their Parent service - for example adding battery status to a motion detector. See examples in the wiki for details.

Configuration fields:

- Service Hierarchy: Whether the service is Parent or Linked. - Bridge: On what bridge to host this Service and its Accessory. (Available only for Parent Service) - Accessory Category: What kind of category is this Accessory. (Available only for Parent Service) - Parent Service: Which Parent service the Linked service will be connected to. (Available only for Linked Service) - Service: Choose the type of Service from the list. Services wiki - Topic: An optional property that can be configured in the node or, if left blank, can be set by msg.topic. - Manufacturer, Model, Serial Number: Can be anything you want. - Name: If you intend to simulate a rocket, then why don't you call it Rocket. - Camera Configuration: Additional configuration for CameraControl service. - Video Processor: Video processor used for Camera. Default is ffmpeg. - Source: Camera source used for video processor. Example for ffmpeg -re -i rtsp://192.168.0.227:8554/unicast - Still Image Source: Camera snapshot source used for video processor. Example for ffmpeg _-i http://faster_still_image_grab_url/this_is_optional.jpg_ - Max Streams: Maximum number of streams that will be generated for this camera, default 2. - Max Width: Maximum width reported to HomeKit, default 1280. - Max Height: Maximum height reported to HomeKit, default 720. - Max FPS: Maximum frame rate of the stream, default 10. - Max Bitrate: Maximum bit rate of the stream in kbit/s, default 300. - Video Codec: If you're running on a RPi with the omx version of ffmpeg installed, you can change to the hardware accelerated video codec with this option, default libx264. - Audio Codec: If you're running on a RPi with the omx version of ffmpeg installed, you can change to the hardware accelerated audio codec with this option, default _libfdkaac. - Audio: Can be set to true to enable audio streaming from camera. To use audio ffmpeg must be compiled with --enable-libfdk-aac, default false. - Packet Size: If audio or video is choppy try a smaller value, set to a multiple of 188, default 1316. - Vertical Flip: Flips the stream vertically, default false. - Horizontal Flip: Flips the stream horizontally, default false. - Map Video: Select the stream used for video, default 0:0. - Map Audio: Select the stream used for audio, default 0:1. - Video Filter: Allows a custom video filter to be passed to FFmpeg via -vf, defaults to scale=1280:720. - Additional Command Line: Allows additional of extra command line options to FFmpeg, default -tune zerolatency. - Debug: Show the output of ffmpeg in the log, default false. - Snapshot Output: Choose how to output camera snapshot: - Disabled: there will be no output - Path: file will be saved and path will be send to output, msg.payload.cameraSnapshot contains path value stored as a string. - Content: file content will be send to output, msg.payload.cameraSnapshot contains Buffer object {"type":"Buffer","data":[]}. - Interface Name: Selects the IP address of a given network interface. The default is to select the first available, and that may not be the same IP address that ffmpeg will use. A mismatch will cause the iOS device to discard the video stream.. - Characteristic Properties: Customise the properties of characteristics. Characteristics wiki

Input Messages

Input messages can be used to update any Characteristic that the selected Service provides. Simply pass the values-to-update as msg.payload object.

Example: to signal that an Outlet is turned on and in use, send the following payload

{
    "On": 1,
    "OutletInUse": 1
}

Hint: to find out what Characteristics you can address, just send {"foo":"bar"} and watch debug tab in node-red ;)

Output Messages

Output messages are in the same format as input messages. They are emitted from the node when it receives Characteristics updates from a paired iOS device.

Currently, there are two main and one conditional output port for homekit-service in node-red.

  1. onChange, is fired when a value has been changed, this is the most recommended to use for most cases.
  2. onSet, is fired every time a value has been set (even to the same value as before), it is used to capture repeated input like Television remote buttons.
  3. camera snapshot, is enabled only for CameraController Service and is used to retrieve camera snapshot data

Supported Types

The following is a list of Services that are currently supported. Check for more details on the wiki.

Supported Services:

- AccessControl - AccessoryInformation - AirPurifier - AirQualitySensor - BatteryService - CameraRTPStreamManagement - CarbonDioxideSensor - CarbonMonoxideSensor - ContactSensor - Door - Doorbell - Fan - Fanv2 - FilterMaintenance - Faucet - GarageDoorOpener - HeaterCooler - HumidifierDehumidifier - HumiditySensor - IrrigationSystem - LeakSensor - LightSensor - Lightbulb - LockManagement - LockMechanism - Microphone - MotionSensor - OccupancySensor - Outlet - SecuritySystem - ServiceLabel - Slat - SmokeSensor - SmartSpeaker - Speaker - StatelessProgrammableSwitch - Switch - TemperatureSensor - Thermostat - Valve - Window - WindowCovering - CameraOperatingMode - CameraEventRecordingManagement - WiFiRouter - WiFiSatellite - PowerManagement - TransferTransportManagement - AccessoryRuntimeInformation - Diagnostics - WiFiTransport - CameraControl - StatefulProgrammableSwitch - BridgeConfiguration - BridgingState - Pairing - ProtocolInformation - Relay - TimeInformation - TunneledBTLEAccessoryService - Television - InputSource - TelevisionSpeaker - TargetControlManagement - TargetControl - AudioStreamManagement - Siri - DataStreamTransportManagement

If you encounter problems with any of them please create new Issue.

If you need help with the setup itself then please write on our Discord.

Context

Context info can be provided as part of the input message and will be available in the output message as hap.context.

Example:

{
    "On": 1,
    "Context": "set_from_mqtt_topic"
}

No Response

You can set accessory "No Response" status by sending "NO_RESPONSE" as a value for any available characteristic.

Example:

{
    "On": "NO_RESPONSE"
}

After "No Response" status was triggered, the accessory is marked accordingly when you try to control it or reopen Home.app. Any subsequent update of any characteristic value will reset this status. However, the NO_RESPONSE status won't be visible until you exit and reopen the app. This is how the NO_RESPONSE status works in HomeKit and this behaviour can't be changed. Subsequent updates after NO_RESPONSE may also need an app restart to pick up the new state

Topic

An optional property that can be configured in the node or, if left blank, can be set by msg.topic.

If Filter on Topic is selected msg.topic of incoming messages must match the configured value for the message to be accepted. If Filter on Topic is selected and no Topic is set on the node, then msg.topic must match the node's Name.

The Topic parameter can be used to filter incoming messages, making it possible to connect multiple HomeKit services to, for example, one MQTT-in node and filter directly on the MQTT Topic. It can also be used to add additional metadata to the outgoing msg, making it possible to connect multiple HomeKit services directly to an MQTT-out node or filter the flow in another way.

FAQ

How can I get started?

Our wiki page has a growing list of examples and explanations of how to use many features of these nodes. After you've gone through the wiki page and you are still having questions, please open an issue.

How can I upgrade from the non-bridged node-red-contrib-homekit?

How to upgrade from node-red-homekit

How can I generate Debug logs?

Stop your node-red instance and start it again using the following command: DEBUG=NRCHKB*,HAP-NodeJS*,Accessory,HAPServer,EventedHTTPServer node-red

This should output detailed information regarding everything in the homekit context.

The same command gets sent over and over. How do I stop that?

The built in rbe node may be placed as needed to only pass on messages if they are different from previous messages.

I only want to get messages when something has been changed in the Home app, but also all messages I send into the homekit node get forwarded, too. How do I stop that?

Set Allow Message Passthrough to false in the Bridge configuration or...

Insert this node right after your homekit node:

[{"id":"","type":"switch","z":"","name":"check hap.context","property":"hap.context","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":0,"y":0,"wires":[]}]

This will filter out all messages with their payload property hap.context not set, which means they are events that have been sent to homekit via node-red, not via the Home app.

Contributors

Big thanks to all who have contributed to the project.

Also, thanks to creators of HAP-NodeJS - NodeJS implementation of Apple's HomeKit Accessory Server

Contact us

## Build Status codebeat badge Known Vulnerabilities

Node Info

Version: 1.2.0
Updated 2 months, 2 weeks ago
License: Apache-2.0
Rating: 4.6 9

Downloads

99 in the last day
639 in the last week
2369 in the last month

Keywords

  • homekit
  • hap-nodejs
  • node-red
  • iot
  • homebridge
  • home
  • NRCHKB

Maintainers

Contributors

  • Marius Schmeding
  • Oliver Rahner