Feature request: Custom services and characteristics
See original GitHub issueHi,
One easy way is to expand HomeKitTypes.js
I’m using:
- build a file
HomeKitTypes-Custom.js
with your custom characteristics and services e.g.:
var inherits = require('util').inherits;
var Characteristic = require('../Characteristic').Characteristic;
var Service = require('../Service').Service;
/**
* Characteristic "Current Air Pressure"
*/
Characteristic.CurrentAirPressure = function() {
Characteristic.call(this, 'CurrentAirPressure', '00000102-0000-1000-8000-0026BB765291');
this.setProps({
format: Characteristic.Formats.UINT16,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.value = this.getDefaultValue();
};
inherits(Characteristic.CurrentAirPressure, Characteristic);
Characteristic.CurrentAirPressure.UUID = '00000102-0000-1000-8000-0026BB765291';
/**
* Service "Air Pressure Sensor"
*/
Service.AirPressureSensor = function(displayName, subtype) {
Service.call(this, displayName, '00000101-0000-1000-8000-0026BB765291', subtype);
// Required Characteristics
this.addCharacteristic(Characteristic.CurrentAirPressure);
// Optional Characteristics
this.addOptionalCharacteristic(Characteristic.Name);
};
inherits(Service.AirPressureSensor, Service);
Service.AirPressureSensor.UUID = '00000101-0000-1000-8000-0026BB765291';
-
copy HomeKitTypes-Custom.js into the same hap-nodejs folder as HomeKitTypes.js (
/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/gen
) -
add this line a the end of HomeKitTypes.js
var HomeKitTypesCustom = require('./HomeKitTypes-Custom');
- restart homebridge
The disadvantage using this method: you have to copy/edit the files after updating homebridge/hap-nodejs.
A user friendly solution would be to be able to store HomeKitTypes-Custom.js
inside .homebridge
.
Any other suggestions?
Issue Analytics
- State:
- Created 6 years ago
- Comments:26 (15 by maintainers)
Top Results From Across the Web
Feature request: Custom services and characteristics #1453
Hi, One easy way is to expand HomeKitTypes.js I'm using: build a file HomeKitTypes-Custom.js with your custom characteristics and services e.g.:.
Read more >Bluetooth GATT: How to Design Custom Services ... - Novel Bits
That's where custom profiles, services, and characteristics come in. ... It is the device that sends commands and requests and accepts incoming ...
Read more >Chapter 4. GATT (Services and Characteristics) - O'Reilly
The Generic Attribute Profile (GATT) establishes in detail how to exchange all profile and user data over a BLE connection. In contrast with...
Read more >BLE GATT | Adafruit Feather M0 Bluefruit LE
The following commands can be used to create custom GATT services and characteristics on the BLEFriend, which are used to store and exchange...
Read more >How do you name a Custom Service
For instance - I have a custom service named DIAGNOSTICS. It has 3 custom characteristics. They are Version, Voltage, and Status. On the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should not be editing Homebridge - I apologize if it seems like I’m asking you to do that. The code I pasted is plugin code. If you are developing a custom accessory and wishing to expose it to HomeKit, then you need to either run your own HAP-NodeJS server inside your accessory, or write a plugin for Homebridge so that other end-users can use your accessory by way of Homebridge.
You can make a
Lightbulb
contain as many characteristics as you want—custom or otherwise—provided you are writing a plugin for Homebridge, you can define your accessory to be whatever you’d like.So there are three pieces here:
Provided that the user sets up those three components, your plugin can do whatever it wishes within the known limits of the HomeKit API.
Am I making sense or just making things more confusing?
Sorry Nick, I really do appreciate you taking time here, but I don’t think you’re engaging with what I’m saying.
I’m not aiming to, and shouldn’t have to, touch the code of Homebridge. I’m an accessory developer trying to use Homekit features that it appears are not supported by Homebridge.
I think the source of the confusion here is that you seem to be under the misapprehension that
Lightbulb
may only ever contain the four characteristics. This is not true.Lightbulb
may contain any number of characteristics. One mandatory, three defined optional, and as many other custom ones as the accesssory defines.It is possible for an accessory to talk to an entirely standard Homekit server and say “I support a Lightbulb but it has a
uint8
parameter calledWhateverIWant
”.People keep telling me to edit Homebridge, but this makes no sense because what I want to do is standard Homekit.