Skip to content

Commit

Permalink
Update HK definition files
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Sep 4, 2024
1 parent 116759b commit 9a12cb4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 166 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to `hap-nodejs` will be documented in this file. This projec
### Changed

- Set `Avahi` as the default advertiser when available, otherwise fallback to `Ciao`
- Update HK definition files
- Updated dependencies

### Homebridge Dependencies
Expand Down
10 changes: 0 additions & 10 deletions src/lib/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import type {
CameraRTPStreamManagement,
CarbonDioxideSensor,
CarbonMonoxideSensor,
CloudRelay,
ContactSensor,
DataStreamTransportManagement,
Diagnostics,
Expand Down Expand Up @@ -71,7 +70,6 @@ import type {
Thermostat,
ThreadTransport,
TransferTransportManagement,
Tunnel,
Valve,
WiFiRouter,
WiFiSatellite,
Expand Down Expand Up @@ -235,10 +233,6 @@ export class Service extends EventEmitter {
* @group Service Definitions
*/
public static CarbonMonoxideSensor: typeof CarbonMonoxideSensor;
/**
* @group Service Definitions
*/
public static CloudRelay: typeof CloudRelay;
/**
* @group Service Definitions
*/
Expand Down Expand Up @@ -435,10 +429,6 @@ export class Service extends EventEmitter {
* @group Service Definitions
*/
public static TransferTransportManagement: typeof TransferTransportManagement;
/**
* @group Service Definitions
*/
public static Tunnel: typeof Tunnel;
/**
* @group Service Definitions
*/
Expand Down
2 changes: 1 addition & 1 deletion src/lib/definitions/CharacteristicDefinitions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// THIS FILE IS AUTO-GENERATED - DO NOT MODIFY
// V=884
// V=886

import { Access, Characteristic, Formats, Perms, Units } from "../Characteristic";

Expand Down
44 changes: 0 additions & 44 deletions src/lib/definitions/ServiceDefinitions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,28 +357,6 @@ describe("ServiceDefinitions", () => {
});
});

describe("CloudRelay", () => {
it("should be able to construct", () => {
const service0 = new Service.CloudRelay();
const service1 = new Service.CloudRelay("test name");
const service2 = new Service.CloudRelay("test name", "test sub type");

expect(service0.displayName).toBe("");
expect(service0.testCharacteristic(Characteristic.Name)).toBe(false);
expect(service0.subtype).toBeUndefined();

expect(service1.displayName).toBe("test name");
expect(service1.testCharacteristic(Characteristic.Name)).toBe(true);
expect(service1.getCharacteristic(Characteristic.Name).value).toBe("test name");
expect(service1.subtype).toBeUndefined();

expect(service2.displayName).toBe("test name");
expect(service2.testCharacteristic(Characteristic.Name)).toBe(true);
expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name");
expect(service2.subtype).toBe("test sub type");
});
});

describe("ContactSensor", () => {
it("should be able to construct", () => {
const service0 = new Service.ContactSensor();
Expand Down Expand Up @@ -1457,28 +1435,6 @@ describe("ServiceDefinitions", () => {
});
});

describe("Tunnel", () => {
it("should be able to construct", () => {
const service0 = new Service.Tunnel();
const service1 = new Service.Tunnel("test name");
const service2 = new Service.Tunnel("test name", "test sub type");

expect(service0.displayName).toBe("");
expect(service0.testCharacteristic(Characteristic.Name)).toBe(false);
expect(service0.subtype).toBeUndefined();

expect(service1.displayName).toBe("test name");
expect(service1.testCharacteristic(Characteristic.Name)).toBe(true);
expect(service1.getCharacteristic(Characteristic.Name).value).toBe("test name");
expect(service1.subtype).toBeUndefined();

expect(service2.displayName).toBe("test name");
expect(service2.testCharacteristic(Characteristic.Name)).toBe(true);
expect(service2.getCharacteristic(Characteristic.Name).value).toBe("test name");
expect(service2.subtype).toBe("test sub type");
});
});

describe("Valve", () => {
it("should be able to construct", () => {
const service0 = new Service.Valve();
Expand Down
42 changes: 3 additions & 39 deletions src/lib/definitions/ServiceDefinitions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// THIS FILE IS AUTO-GENERATED - DO NOT MODIFY
// V=880
// V=886

import { Characteristic } from "../Characteristic";
import { Service } from "../Service";
Expand Down Expand Up @@ -66,6 +66,7 @@ export class AccessoryInformation extends Service {
this.addOptionalCharacteristic(Characteristic.AccessoryFlags);
this.addOptionalCharacteristic(Characteristic.AppMatchingIdentifier);
this.addOptionalCharacteristic(Characteristic.ConfiguredName);
this.addOptionalCharacteristic(Characteristic.MatterFirmwareRevisionNumber);
this.addOptionalCharacteristic(Characteristic.HardwareFinish);
this.addOptionalCharacteristic(Characteristic.HardwareRevision);
this.addOptionalCharacteristic(Characteristic.ProductData);
Expand Down Expand Up @@ -363,24 +364,6 @@ export class CarbonMonoxideSensor extends Service {
}
Service.CarbonMonoxideSensor = CarbonMonoxideSensor;

/**
* Service "Cloud Relay"
*/
export class CloudRelay extends Service {

public static readonly UUID: string = "0000005A-0000-1000-8000-0026BB765291";

constructor(displayName?: string, subtype?: string) {
super(displayName, CloudRelay.UUID, subtype);

// Required Characteristics
this.addCharacteristic(Characteristic.RelayControlPoint);
this.addCharacteristic(Characteristic.RelayState);
this.addCharacteristic(Characteristic.RelayEnabled);
}
}
Service.CloudRelay = CloudRelay;

/**
* Service "Contact Sensor"
*/
Expand Down Expand Up @@ -590,6 +573,7 @@ export class FirmwareUpdate extends Service {
this.addCharacteristic(Characteristic.FirmwareUpdateStatus);

// Optional Characteristics
this.addOptionalCharacteristic(Characteristic.MatterFirmwareUpdateStatus);
this.addOptionalCharacteristic(Characteristic.StagedFirmwareVersion);
this.addOptionalCharacteristic(Characteristic.SupportedFirmwareUpdateConfiguration);
}
Expand Down Expand Up @@ -1469,26 +1453,6 @@ export class TransferTransportManagement extends Service {
}
Service.TransferTransportManagement = TransferTransportManagement;

/**
* Service "Tunnel"
*/
export class Tunnel extends Service {

public static readonly UUID: string = "00000056-0000-1000-8000-0026BB765291";

constructor(displayName?: string, subtype?: string) {
super(displayName, Tunnel.UUID, subtype);

// Required Characteristics
this.addCharacteristic(Characteristic.AccessoryIdentifier);
this.addCharacteristic(Characteristic.TunnelConnectionTimeout);
this.addCharacteristic(Characteristic.TunneledAccessoryAdvertising);
this.addCharacteristic(Characteristic.TunneledAccessoryConnected);
this.addCharacteristic(Characteristic.TunneledAccessoryStateNumber);
}
}
Service.Tunnel = Tunnel;

/**
* Service "Valve"
*/
Expand Down
19 changes: 13 additions & 6 deletions src/lib/definitions/generate-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import assert from "assert";
import { Command } from "commander";
import fs from "fs";
import path from "path";
import plist from "simple-plist";
import { readFileSync } from "simple-plist";
import { Access, Characteristic, Formats, Units } from "../Characteristic";
import { toLongForm } from "../util/uuid";
import {
Expand Down Expand Up @@ -33,7 +33,7 @@ const command = new Command("generate-definitions")
.option("-f, --force")
.option("-m, --metadata <path>", "Define a custom location for the plain-metadata.config file",
"/System/Library/PrivateFrameworks/HomeKitDaemon.framework/Resources/plain-metadata.config")
.requiredOption("-s, --simulator <path>", "Define the path to the accessory simulator.");
.option("-s, --simulator <path>", "Define the path to the accessory simulator.", "/Users/benpotter/Desktop/a.app");

command.parse(process.argv);
const options = command.opts();
Expand Down Expand Up @@ -148,9 +148,11 @@ export interface GeneratedService {
optionalCharacteristics?: string[];
}

const plistData = plist.readFileSync(metadataFile);
const simulatorPlistData = plist.readFileSync(defaultPlist);
const simulatorMfiPlistData = fs.existsSync(defaultMfiPlist)? plist.readFileSync(defaultMfiPlist): undefined;
/* eslint-disable @typescript-eslint/no-explicit-any */
const plistData = readFileSync(metadataFile) as any;
const simulatorPlistData = readFileSync(defaultPlist)as any;
const simulatorMfiPlistData = fs.existsSync(defaultMfiPlist)? readFileSync(defaultMfiPlist): undefined as any;
/* eslint-enable @typescript-eslint/no-explicit-any */

if (plistData.SchemaVersion !== 1) {
console.warn(`Detected unsupported schema version ${plistData.SchemaVersion}!`);
Expand Down Expand Up @@ -348,7 +350,12 @@ for (const generated of Object.values(generatedCharacteristics)
if (!name) {
continue;
}
characteristicOutput.write(` public static readonly ${name} = ${value};\n`);
// fix a weird edge case, still present in V=886
let printName = name;
if (name === "PROGRAM_SCHEDULED_MANUAL_MODE_") {
printName = "PROGRAM_SCHEDULED_MANUAL_MODE";
}
characteristicOutput.write(` public static readonly ${printName} = ${value};\n`);
}
characteristicOutput.write("\n");
}
Expand Down
73 changes: 7 additions & 66 deletions src/lib/definitions/generator-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ export const CharacteristicDeprecatedNames: Map<string, string> = new Map([ // k
]);

export const CharacteristicValidValuesOverride: Map<string, Record<string, string>> = new Map([
["camera-operating-mode-indicator", { "0": "Disable", "1": "Enable" }],
["closed-captions", { "0": "Disabled", "1": "Enabled" }],
["event-snapshots-active", { "0": "Disable", "1": "Enable" }],
["homekit-camera-active", { "0": "Off", "1": "On" }],
["input-device-type", { "0": "Other", "1": "TV", "2": "Recording", "3": "Tuner", "4": "Playback", "5": "Audio System" }],
["input-source-type", { "0": "Other", "1": "Home Screen", "2": "Tuner", "3": "HDMI", "4": "Composite Video", "5": "S Video",
"6": "Component Video", "7": "DVI", "8": "AirPlay", "9": "USB", "10": "Application" }],
["managed-network-enable", { "0": "Disabled", "1": "Enabled" }],
["manually-disabled", { "0": "Enabled", "1": "Disabled" }],
["media-state.current", { "0": "Play", "1": "Pause", "2": "Stop", "4": "LOADING", "5": "Interrupted" }],
["media-state.target", { "0": "Play", "1": "Pause", "2": "Stop" }],
["periodic-snapshots-active", { "0": "Disable", "1": "Enable" }],
["picture-mode", { "0": "Other", "1": "Standard", "2": "Calibrated", "3": "Calibrated Dark", "4": "Vivid", "5": "Game", "6": "Computer", "7": "Custom" }],
["power-mode-selection", { "0": "Show", "1": "Hide" }],
["recording-audio-active", { "0": "Disable", "1": "Enable" }],
Expand All @@ -60,18 +64,15 @@ export const CharacteristicValidValuesOverride: Map<string, Record<string, strin
["router-status", { "0": "Ready", "1": "Not Ready" }],
["siri-input-type", { "0": "Push Button Triggered Apple TV" }],
["sleep-discovery-mode", { "0": "Not Discoverable", "1": "Always Discoverable" }],
["third-party-camera-active", { "0": "Off", "1": "On" }],
["visibility-state.current", { "0": "Shown", "1": "Hidden" }],
["visibility-state.target", { "0": "Shown", "1": "Hidden" }],
["volume-control-type", { "0": "None", "1": "Relative", "2": "Relative With Current", "3": "Absolute" }],
["volume-selector", { "0": "Increment", "1": "Decrement" }],
["wifi-satellite-status", { "0": "Unknown", "1": "Connected", "2": "Not Connected" }],
] as [string, Record<string, string>][]);

export const CharacteristicClassAdditions: Map<string, string[]> = new Map([
["humidifier-dehumidifier.state.target", [
"/**\n * @deprecated Removed in iOS 11. Use {@link HUMIDIFIER_OR_DEHUMIDIFIER} instead.\n */\n public static readonly AUTO = 0;",
]],
]);
export const CharacteristicClassAdditions: Map<string, string[]> = new Map([]);

export const CharacteristicOverriding: Map<string, (generated: GeneratedCharacteristic) => void> = new Map([
["rotation.speed", generated => {
Expand Down Expand Up @@ -219,39 +220,6 @@ export const CharacteristicManualAdditions: Map<string, GeneratedCharacteristic>
properties: 2, // paired read
maxLength: 64,
}],
["target-air-quality", { // some legacy characteristic, don't know where it comes from or where it was used
id: "target-air-quality",
UUID: "000000AE-0000-1000-8000-0026BB765291",
name: "Target Air Quality",
className: "TargetAirQuality",
deprecatedNotice: "Removed and not used anymore",

format: "uint8",
properties: 7, // read, write, notify
minValue: 0,
maxValue: 2,
validValues: {
"0": "EXCELLENT",
"1": "GOOD",
"2": "FAIR",
} as Record<string, string>,
}],
["target-slat-state", { // some legacy characteristic, don't know where it comes from or where it was used
id: "target-slat-state",
UUID: "000000BE-0000-1000-8000-0026BB765291",
name: "Target Slat State",
className: "TargetSlatState",
deprecatedNotice: "Removed and not used anymore",

format: "uint8",
properties: 7, // read, write, notify
minValue: 0,
maxValue: 1,
validValues: {
"0": "MANUAL",
"1": "AUTO",
} as Record<string, string>,
}],
]);

export const ServiceNameOverrides: Map<string, string> = new Map([
Expand All @@ -264,13 +232,7 @@ export const ServiceNameOverrides: Map<string, string> = new Map([
["nfc-access", "NFC Access"],
]);

export const ServiceDeprecatedNames: Map<string, string> = new Map([
["battery", "Battery Service"],
["camera-recording-management", "Camera Event Recording Management"],
["cloud-relay", "Relay"],
["slats", "Slat"],
["tunnel", "Tunneled BTLE Accessory Service"],
]);
export const ServiceDeprecatedNames: Map<string, string> = new Map([]);

interface CharacteristicConfigurationOverride {
addedRequired?: string[],
Expand All @@ -295,27 +257,6 @@ export const ServiceManualAdditions: Map<string, GeneratedService> = new Map([
requiredCharacteristics: ["mute"],
optionalCharacteristics: ["active", "volume"],
}],
["camera-control", {
id: "camera-control",
UUID: "00000111-0000-1000-8000-0026BB765291",
name: "Camera Control",
className: "CameraControl",
deprecatedNotice: "This service has no usage anymore and will be ignored by iOS",

requiredCharacteristics: ["on"],
optionalCharacteristics: [
"horizontal-tilt.current",
"vertical-tilt.current",
"horizontal-tilt.target",
"vertical-tilt.target",
"night-vision",
"optical-zoom",
"digital-zoom",
"image-rotation",
"image-mirroring",
"name",
],
}],
]);

export const CharacteristicSinceInformation: Map<string, string> = new Map([
Expand Down

0 comments on commit 9a12cb4

Please sign in to comment.