homebridge-sony-audio-extended 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;CAStC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;;;CAKvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wCAAwC;;;;;CAKpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;;CAKvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;CAKpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;;;CAKnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC;;;;;CAK7C,CAAC;AAGF,oBAAY,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,EAAE,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,kCAAkC;IACjD,MAAM,EAAE,mBAAmB,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE;QACN;YACE,IAAI,EAAE,IAAI,GAAG,KAAK,GAAG,QAAQ,GAAG,EAAE,CAAC;YACnC,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SACf;KACH,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC;IAClC,MAAM,EAAE;QACN,WAAW;KACZ,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H,EAAE,YAAY;IACd;;OAEG;IACH,MAAM,gBAAgB;IACtB;;OAEG;IACH,WAAW,qBAAqB;IAChC;;OAEG;IACH,0BAA0B,oCAAoC;IAC9D;;OAEG;IACH,MAAM,gBAAgB;IACtB;;OAEG;IACH,OAAO,iBAAiB;IACxB;;OAEG;IACH,QAAQ,kBAAkB;IAC1B;;OAEG;IACH,KAAK,eAAe;IACpB;;OAEG;IACH,WAAW,qBAAqB;CAChC;AAED,0BAAkB,mBAAmB;IACnC,KAAK,sBAAsB;IAC3B,MAAM,4BAA4B;IAClC,QAAQ,iCAAiC;IACzC,OAAO,6BAA6B;CACrC"}
package/dist/api.js ADDED
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IncompatibleDeviceCategoryError = exports.UnsupportedVersionApiError = exports.GenericApiError = exports.ApiRequestGetInterfaceInformation = exports.ApiRequestGetSchemeList = exports.ApiRequestGetPowerStatus = exports.ApiRequestVolumeInformation = exports.ApiRequestCurrentExternalTerminalsStatus = exports.ApiRequestSystemInformation = exports.ApiRequestSupportedApiInfo = void 0;
4
+ /**
5
+ * Request to get a supported services and its information
6
+ * Docs [here](https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_getsupportedapiinfo_v1_0).
7
+ */
8
+ exports.ApiRequestSupportedApiInfo = {
9
+ id: 5,
10
+ method: 'getSupportedApiInfo',
11
+ params: [
12
+ {
13
+ services: null,
14
+ },
15
+ ],
16
+ version: '1.0',
17
+ };
18
+ /**
19
+ * Request to get a general system information for the device.
20
+ * Docs [here](https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_getsysteminformation_v1_4).
21
+ */
22
+ exports.ApiRequestSystemInformation = {
23
+ method: 'getSystemInformation',
24
+ id: 65,
25
+ params: [],
26
+ version: '1.4',
27
+ };
28
+ /**
29
+ * Request to get an information about the current status of all external input and output terminal sources of the device.
30
+ * For a device that has no external input or output connectors, this APi should return an empty result with no error codes.
31
+ * Docs [here](https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_getcurrentexternalterminalsstatus_v1_0).
32
+ */
33
+ exports.ApiRequestCurrentExternalTerminalsStatus = {
34
+ method: 'getCurrentExternalTerminalsStatus',
35
+ id: 66,
36
+ params: [],
37
+ version: '1.0',
38
+ };
39
+ /**
40
+ * Gets the current volume level and mute status.
41
+ * Uses for init info about volume settings.
42
+ * Docs [here](https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_getvolumeinformation_v1_1)
43
+ */
44
+ exports.ApiRequestVolumeInformation = {
45
+ method: 'getVolumeInformation',
46
+ id: 33,
47
+ params: [{}],
48
+ version: '1.1',
49
+ };
50
+ /**
51
+ * Gets the current power status of the device.
52
+ * Docs [here](https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_getpowerstatus_v1_1)
53
+ */
54
+ exports.ApiRequestGetPowerStatus = {
55
+ id: 50,
56
+ method: 'getPowerStatus',
57
+ params: [],
58
+ version: '1.1',
59
+ };
60
+ /**
61
+ * This API provides the list of schemes that device can handle.
62
+ * Lib: `avContent`
63
+ * Docs [here](https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_getschemelist_v1_0)
64
+ */
65
+ exports.ApiRequestGetSchemeList = {
66
+ method: 'getSchemeList',
67
+ id: 1,
68
+ params: [],
69
+ version: '1.0',
70
+ };
71
+ /**
72
+ * This API provides information of WebAPI interface provided by the server.
73
+ * Lib: `system`
74
+ * This API must not include private information.
75
+ * Docs [here](https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_getinterfaceinformation_v1_0)
76
+ */
77
+ exports.ApiRequestGetInterfaceInformation = {
78
+ method: 'getInterfaceInformation',
79
+ id: 33,
80
+ params: [],
81
+ version: '1.0',
82
+ };
83
+ class GenericApiError extends Error {
84
+ constructor(message) {
85
+ super(message);
86
+ Object.setPrototypeOf(this, UnsupportedVersionApiError.prototype);
87
+ if (Error.captureStackTrace) {
88
+ Error.captureStackTrace(this, GenericApiError);
89
+ }
90
+ this.name = 'GENERIC_API_ERROR';
91
+ this.code = 1;
92
+ }
93
+ }
94
+ exports.GenericApiError = GenericApiError;
95
+ class UnsupportedVersionApiError extends GenericApiError {
96
+ constructor(message) {
97
+ super(message);
98
+ this.name = 'UNSUPPORTED_VERSION_API';
99
+ this.code = 14;
100
+ }
101
+ }
102
+ exports.UnsupportedVersionApiError = UnsupportedVersionApiError;
103
+ class IncompatibleDeviceCategoryError extends Error {
104
+ constructor(message) {
105
+ super(message);
106
+ Object.setPrototypeOf(this, IncompatibleDeviceCategoryError.prototype);
107
+ if (Error.captureStackTrace) {
108
+ Error.captureStackTrace(this, IncompatibleDeviceCategoryError);
109
+ }
110
+ this.name = 'INCOMPATIBLE_DEVICE_CATEGORY';
111
+ }
112
+ }
113
+ exports.IncompatibleDeviceCategoryError = IncompatibleDeviceCategoryError;
114
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,0BAA0B,GAAG;IACxC,EAAE,EAAE,CAAC;IACL,MAAM,EAAE,qBAAqB;IAC7B,MAAM,EAAC;QACL;YACE,QAAQ,EAAE,IAAI;SACf;KACF;IACD,OAAO,EAAE,KAAK;CACf,CAAC;AAEF;;;GAGG;AACU,QAAA,2BAA2B,GAAG;IACzC,MAAM,EAAE,sBAAsB;IAC9B,EAAE,EAAE,EAAE;IACN,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,KAAK;CACf,CAAC;AAEF;;;;GAIG;AACU,QAAA,wCAAwC,GAAG;IACtD,MAAM,EAAE,mCAAmC;IAC3C,EAAE,EAAE,EAAE;IACN,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,KAAK;CACf,CAAC;AAEF;;;;GAIG;AACU,QAAA,2BAA2B,GAAG;IACzC,MAAM,EAAE,sBAAsB;IAC9B,EAAE,EAAE,EAAE;IACN,MAAM,EAAE,CAAE,EAAE,CA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vE,IAAI,KAAK,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC;SAChE;QACD,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AATD,0EASC"}
@@ -0,0 +1,44 @@
1
+ /// <reference types="node" />
2
+ import { SonyDevice } from './sonyDevice';
3
+ import { Logger } from 'homebridge';
4
+ import { AxiosResponse } from 'axios';
5
+ import { URL } from 'url';
6
+ import EventEmitter from 'events';
7
+ export declare const enum DiscoveryEvents {
8
+ NewDeviceFound = "new-device-found"
9
+ }
10
+ /**
11
+ * An instance of this class is periodically try to discover a new or
12
+ * already found Sony audio devices and emit events about it
13
+ */
14
+ export declare class Discoverer extends EventEmitter {
15
+ private readonly log;
16
+ private devices;
17
+ private ssdpClient;
18
+ private axiosInstance;
19
+ private poller?;
20
+ /**
21
+ * Storage of the errors to prevent errors flooding
22
+ */
23
+ private errors;
24
+ constructor(log: Logger);
25
+ /**
26
+ * The discovery process to find products connected to your network,
27
+ * uses the Universal Plug and Play (UPnP) protocols and the Simple Service Discovery Protocol (SSDP).
28
+ */
29
+ startDiscovery(): void;
30
+ /**
31
+ * Stop periodicaly discovering
32
+ */
33
+ stopDiscovery(): void;
34
+ handleSsdpResponse(headers: Record<string, string>, code: number): void;
35
+ registerDevice(usn: string, location: URL): void;
36
+ createDevice(baseUrl: string, upnpBaseUrl: string, udn: string, opt: Record<string, string>): Promise<SonyDevice>;
37
+ /**
38
+ * Check the API response for returned error
39
+ * Decsription of errors [here](https://developer.sony.com/develop/audio-control-api/api-references/error-codes).
40
+ * @param response
41
+ */
42
+ responseInterceptor(response: AxiosResponse): AxiosResponse<any, any> | Promise<never>;
43
+ }
44
+ //# sourceMappingURL=discoverer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discoverer.d.ts","sourceRoot":"","sources":["../src/discoverer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAc,EAAiB,aAAa,EAAc,MAAM,OAAO,CAAC;AAGxE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,YAAY,MAAM,QAAQ,CAAC;AAOlC,0BAAkB,eAAe;IAC/B,cAAc,qBAAqB;CACpC;AAID;;;GAGG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAWxC,OAAO,CAAC,QAAQ,CAAC,GAAG;IAVtB,OAAO,CAAC,OAAO,CAA0C;IACzD,OAAO,CAAC,UAAU,CAAC;IACnB,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAiB;IAChC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAsB;gBAGjB,GAAG,EAAE,MAAM;IAiB9B;;;OAGG;IACI,cAAc;IAOrB;;OAEG;IACI,aAAa;IAMpB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM;IA8BhE,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG;IAuFzC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA0B3F;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,aAAa;CAS5C"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Discoverer = void 0;
7
+ /* eslint-disable max-len */
8
+ const sonyDevice_1 = require("./sonyDevice");
9
+ const api_1 = require("./api");
10
+ const node_ssdp_1 = require("node-ssdp");
11
+ const axios_1 = __importDefault(require("axios"));
12
+ const fast_xml_parser_1 = __importDefault(require("fast-xml-parser"));
13
+ const url_1 = require("url");
14
+ const events_1 = __importDefault(require("events"));
15
+ /**
16
+ * The search target for devices supporting Audio Control API
17
+ */
18
+ const SSDP_SEARCH_TARGET = 'urn:schemas-sony-com:service:ScalarWebAPI:1';
19
+ /**
20
+ * An instance of this class is periodically try to discover a new or
21
+ * already found Sony audio devices and emit events about it
22
+ */
23
+ class Discoverer extends events_1.default {
24
+ constructor(log) {
25
+ super();
26
+ this.log = log;
27
+ this.devices = new Map();
28
+ this.errors = new Map();
29
+ this.axiosInstance = axios_1.default.create();
30
+ this.axiosInstance.interceptors.response.use(this.responseInterceptor);
31
+ // init the SSDP client
32
+ this.ssdpClient = new node_ssdp_1.Client({
33
+ // customLogger: log,
34
+ });
35
+ this.ssdpClient.on('response', (headers, code) => this.handleSsdpResponse(headers, code));
36
+ }
37
+ /**
38
+ * The discovery process to find products connected to your network,
39
+ * uses the Universal Plug and Play (UPnP) protocols and the Simple Service Discovery Protocol (SSDP).
40
+ */
41
+ startDiscovery() {
42
+ this.ssdpClient.search(SSDP_SEARCH_TARGET);
43
+ this.poller = setInterval(() => {
44
+ this.ssdpClient.search(SSDP_SEARCH_TARGET);
45
+ }, 5000);
46
+ }
47
+ /**
48
+ * Stop periodicaly discovering
49
+ */
50
+ stopDiscovery() {
51
+ if (this.poller) {
52
+ clearInterval(this.poller);
53
+ }
54
+ }
55
+ handleSsdpResponse(headers, code) {
56
+ // this.log.debug('Got a response to an m-search:\n%s', JSON.stringify(headers, null, ' '));
57
+ // Don't handle non 200 code
58
+ if (code !== 200) {
59
+ return;
60
+ }
61
+ const usn = headers === null || headers === void 0 ? void 0 : headers.USN;
62
+ const location = headers === null || headers === void 0 ? void 0 : headers.LOCATION;
63
+ if (!usn || !location) {
64
+ return;
65
+ }
66
+ // According (https://developer.sony.com/develop/audio-control-api/hardware-overview/discovery-process)
67
+ // The value of the ST header is identical to the one sent in the M-SEARCH request
68
+ if ((headers === null || headers === void 0 ? void 0 : headers.ST) !== SSDP_SEARCH_TARGET) {
69
+ // Found device is not supported by this plugin.
70
+ // So, add it as a fake device to stop further processing
71
+ this.devices.set(usn, null);
72
+ return;
73
+ }
74
+ // If the discovered device is already registered, skip it
75
+ if (this.devices.has(usn)) {
76
+ return;
77
+ }
78
+ this.log.debug(`Start registering a new device from the description: ${location}`);
79
+ this.registerDevice(usn, new url_1.URL(location));
80
+ }
81
+ registerDevice(usn, location) {
82
+ if (location.pathname === '/') {
83
+ // Found device is not supported by this plugin.
84
+ // So, add it as a fake device to stop further processing
85
+ this.devices.set(usn, null);
86
+ return;
87
+ }
88
+ // retrieve the device description
89
+ axios_1.default.get(location.href)
90
+ .then((response) => {
91
+ var _a, _b, _c;
92
+ this.errors.delete(location.href); // clear error if device responded
93
+ let deviceDescription;
94
+ try {
95
+ deviceDescription = fast_xml_parser_1.default.parse(response.data);
96
+ }
97
+ catch (error) {
98
+ this.log.debug(`ERROR: Can't parse the response from device during discovery. Error: ${error.code}, ${error.msg}`);
99
+ return;
100
+ }
101
+ // Check for the presence of the `av:X_ScalarWebAPI_DeviceInfo` tag. If not, then this plugin does not support the device. Fix #7
102
+ if (!((_b = (_a = deviceDescription === null || deviceDescription === void 0 ? void 0 : deviceDescription.root) === null || _a === void 0 ? void 0 : _a.device) === null || _b === void 0 ? void 0 : _b['av:X_ScalarWebAPI_DeviceInfo'])) {
103
+ // Found device is not supported by this plugin.
104
+ // So, add it as a fake device to stop further processing
105
+ this.devices.set(usn, null);
106
+ return;
107
+ }
108
+ // Set device status as Registration to prevent double registration
109
+ if (this.devices.get(usn) === 'REGISTERING') {
110
+ return;
111
+ }
112
+ this.devices.set(usn, 'REGISTERING');
113
+ // Retrive IRCC service url
114
+ const serviceList = deviceDescription.root.device.serviceList.service;
115
+ let irccServiceUrl = '';
116
+ let irccServiceExist = false;
117
+ for (let i = 0; i < serviceList.length; i++) {
118
+ const service = serviceList[i];
119
+ if (service.serviceId === 'urn:schemas-sony-com:serviceId:IRCC') {
120
+ irccServiceUrl = service.controlURL;
121
+ irccServiceExist = true;
122
+ break;
123
+ }
124
+ }
125
+ const reAbsoluteUrl = new RegExp('^(?:[a-z]+:)?//', 'i');
126
+ const upnpBaseUrl = irccServiceExist ? reAbsoluteUrl.test(irccServiceUrl) ? irccServiceUrl : location.protocol + '//' + location.hostname + ':' + location.port + irccServiceUrl : '';
127
+ const deviceBaseUrl = (_c = deviceDescription.root.device['av:X_ScalarWebAPI_DeviceInfo']) === null || _c === void 0 ? void 0 : _c['av:X_ScalarWebAPI_BaseURL'];
128
+ // const deviceServices = deviceDescription.root.device['av:X_ScalarWebAPI_DeviceInfo']?.['av:X_ScalarWebAPI_ServiceList']?.['av:X_ScalarWebAPI_ServiceType'];
129
+ const deviceFriendlyName = deviceDescription.root.device.friendlyName;
130
+ const deviceManufacturer = deviceDescription.root.device.manufacturer;
131
+ const deviceModelName = deviceDescription.root.device.modelName;
132
+ const deviceUDN = deviceDescription.root.device.UDN;
133
+ if (!deviceBaseUrl || !deviceUDN) {
134
+ this.log.error(`Error response from device during discovery. Url or UDN is not found: Url:${deviceBaseUrl}, UDN:${deviceUDN}`);
135
+ // Found device is not supported by this plugin.
136
+ // So, add it as a fake device to stop further processing
137
+ this.devices.set(usn, null);
138
+ return;
139
+ }
140
+ this.createDevice(deviceBaseUrl, upnpBaseUrl, deviceUDN, { friendlyName: deviceFriendlyName, manufacturer: deviceManufacturer, modelName: deviceModelName })
141
+ .then(device => {
142
+ this.devices.set(usn, device);
143
+ // emit an event about new found device
144
+ this.emit("new-device-found" /* NewDeviceFound */, device);
145
+ this.log.info('Compatible device found, added:', device.systemInfo.name);
146
+ })
147
+ .catch((err) => {
148
+ this.devices.set(usn, null);
149
+ if (err instanceof api_1.IncompatibleDeviceCategoryError) {
150
+ this.log.info('Incompatible device found, skipped:', deviceFriendlyName, '-', err.message);
151
+ }
152
+ else {
153
+ this.log.info('Incompatible device found, skipped:', deviceFriendlyName);
154
+ }
155
+ });
156
+ })
157
+ .catch((err) => {
158
+ // Fixed #1 to stop error log flooding when some devices illegally answer to discovering
159
+ if (this.errors.get(location.href) !== err.message) {
160
+ this.log.debug(`ERROR: Can't retrieve the device description at ${location.href}: ${err}.\nIt looks like you have a problem in your network environment. All the same errors will be omitted.`);
161
+ this.errors.set(location.href, err.message);
162
+ this.devices.delete(usn);
163
+ }
164
+ });
165
+ }
166
+ createDevice(baseUrl, upnpBaseUrl, udn, opt) {
167
+ return new Promise((resolve, reject) => {
168
+ const deviceUrl = new url_1.URL(baseUrl);
169
+ const upnpUrl = upnpBaseUrl !== '' ? new url_1.URL(upnpBaseUrl) : undefined;
170
+ sonyDevice_1.SonyDevice.createDevice(deviceUrl, upnpUrl, udn, this.log)
171
+ .then((device) => {
172
+ device.systemInfo.name = opt.friendlyName ? opt.friendlyName : '';
173
+ device.manufacturer = opt.manufacturer ? opt.manufacturer : device.manufacturer;
174
+ device.systemInfo.model = opt.modelName ? opt.modelName : '';
175
+ resolve(device);
176
+ })
177
+ .catch(err => {
178
+ if (err instanceof api_1.UnsupportedVersionApiError) {
179
+ this.log.debug(err.message);
180
+ }
181
+ else if (err instanceof api_1.IncompatibleDeviceCategoryError) {
182
+ this.log.debug(err.message);
183
+ }
184
+ else {
185
+ this.log.error('message' in err ? err.message : err);
186
+ }
187
+ reject();
188
+ });
189
+ });
190
+ }
191
+ /**
192
+ * Check the API response for returned error
193
+ * Decsription of errors [here](https://developer.sony.com/develop/audio-control-api/api-references/error-codes).
194
+ * @param response
195
+ */
196
+ responseInterceptor(response) {
197
+ if ('error' in response.data) {
198
+ // TODO: add a device ip address for identification of the device
199
+ const errMsg = `Device API got an error: ${JSON.stringify(response.data)}`;
200
+ return Promise.reject(new api_1.GenericApiError(errMsg));
201
+ }
202
+ else {
203
+ return response;
204
+ }
205
+ }
206
+ }
207
+ exports.Discoverer = Discoverer;
208
+ //# sourceMappingURL=discoverer.js.map
@@ -0,0 +1 @@
1
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AC,GAAG,CAAC,CAAC;iBACtD;gBACD,MAAM,EAAE,CAAC;YACX,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,QAAuB;QACzC,IAAI,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;YAC5B,iEAAiE;YACjE,MAAM,MAAM,GAAG,4BAA4B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3E,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,qBAAe,CAAC,MAAM,CAAC,CAAC,CAAC;SACpD;aAAM;YACL,OAAO,QAAQ,CAAC;SACjB;IACH,CAAC;CACF;AA7MD,gCA6MC"}
@@ -0,0 +1,7 @@
1
+ import { API } from 'homebridge';
2
+ declare const _default: (api: API) => void;
3
+ /**
4
+ * This method registers the platform with Homebridge
5
+ */
6
+ export = _default;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;8BAQlB,GAAG;AAHlB;;GAEG;AACH,kBAEE"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ const settings_1 = require("./settings");
3
+ const platform_1 = require("./platform");
4
+ module.exports = (api) => {
5
+ api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.SonyAudioHomebridgePlatform);
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,yCAA2C;AAC3C,yCAAyD;AAKzD,iBAAS,CAAC,GAAQ,EAAE,EAAE;IACpB,GAAG,CAAC,gBAAgB,CAAC,wBAAa,EAAE,sCAA2B,CAAC,CAAC;AACnE,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from 'homebridge';
2
+ import { SonyDevice } from './sonyDevice';
3
+ /**
4
+ * HomebridgePlatform
5
+ * This class is the main constructor for your plugin, this is where you should
6
+ * parse the user config and discover/register accessories with Homebridge.
7
+ */
8
+ export declare class SonyAudioHomebridgePlatform implements DynamicPlatformPlugin {
9
+ readonly log: Logger;
10
+ readonly config: PlatformConfig;
11
+ readonly api: API;
12
+ readonly Service: typeof Service;
13
+ readonly Characteristic: typeof Characteristic;
14
+ readonly accessories: PlatformAccessory<SonyDevice>[];
15
+ readonly devices: SonyDevice[];
16
+ private discoverer;
17
+ constructor(log: Logger, config: PlatformConfig, api: API);
18
+ /**
19
+ * This function is invoked when homebridge restores cached accessories from disk at startup.
20
+ * It should be used to setup event handlers for characteristics and update respective values.
21
+ */
22
+ configureAccessory(accessory: PlatformAccessory<SonyDevice>): void;
23
+ /**
24
+ * This is an example method showing how to register discovered accessories.
25
+ * Accessories must only be registered once, previously created accessories
26
+ * must not be registered again to prevent "duplicate UUID" errors.
27
+ */
28
+ discoverDevices(): void;
29
+ publishDevice(device: SonyDevice): void;
30
+ }
31
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAc,MAAM,YAAY,CAAC;AAKxI,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AACH,qBAAa,2BAA4B,YAAW,qBAAqB;aAWrD,GAAG,EAAE,MAAM;aACX,MAAM,EAAE,cAAc;aACtB,GAAG,EAAE,GAAG;IAZ1B,SAAgB,OAAO,EAAE,OAAO,OAAO,CAAwB;IAC/D,SAAgB,cAAc,EAAE,OAAO,cAAc,CAA+B;IAGpF,SAAgB,WAAW,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAM;IAElE,SAAgB,OAAO,EAAE,UAAU,EAAE,CAAM;IAC3C,OAAO,CAAC,UAAU,CAAa;gBAGb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG;IAuB1B;;;OAGG;IACH,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,CAAC,UAAU,CAAC;IAO3D;;;;OAIG;IACH,eAAe;IAQf,aAAa,CAAC,MAAM,EAAE,UAAU;CA2CjC"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SonyAudioHomebridgePlatform = void 0;
4
+ const settings_1 = require("./settings");
5
+ const sonyAudioAccessory_1 = require("./sonyAudioAccessory");
6
+ const discoverer_1 = require("./discoverer");
7
+ /**
8
+ * HomebridgePlatform
9
+ * This class is the main constructor for your plugin, this is where you should
10
+ * parse the user config and discover/register accessories with Homebridge.
11
+ */
12
+ class SonyAudioHomebridgePlatform {
13
+ constructor(log, config, api) {
14
+ this.log = log;
15
+ this.config = config;
16
+ this.api = api;
17
+ this.Service = this.api.hap.Service;
18
+ this.Characteristic = this.api.hap.Characteristic;
19
+ // this is used to track restored cached accessories
20
+ this.accessories = [];
21
+ this.devices = [];
22
+ this.log.debug('Finished initializing platform:', this.config.platform);
23
+ this.discoverer = new discoverer_1.Discoverer(this.log);
24
+ // When this event is fired it means Homebridge has restored all cached accessories from disk.
25
+ // Dynamic Platform plugins should only register new accessories after this event was fired,
26
+ // in order to ensure they weren't added to homebridge already. This event can also be used
27
+ // to start discovery of new accessories.
28
+ this.api.on('didFinishLaunching', () => {
29
+ log.debug('Started discovery process to find network connected Sony Audio products');
30
+ this.discoverDevices();
31
+ });
32
+ this.api.on('shutdown', () => {
33
+ this.discoverer.stopDiscovery();
34
+ this.devices.forEach(device => {
35
+ log.debug(`Device ${device.systemInfo.name} unsubscribing...`);
36
+ device.unsubscribe();
37
+ });
38
+ });
39
+ }
40
+ /**
41
+ * This function is invoked when homebridge restores cached accessories from disk at startup.
42
+ * It should be used to setup event handlers for characteristics and update respective values.
43
+ */
44
+ configureAccessory(accessory) {
45
+ this.log.info('Loading accessory from cache:', accessory.displayName);
46
+ // add the restored accessory to the accessories cache so we can track if it has already been registered
47
+ this.accessories.push(accessory);
48
+ }
49
+ /**
50
+ * This is an example method showing how to register discovered accessories.
51
+ * Accessories must only be registered once, previously created accessories
52
+ * must not be registered again to prevent "duplicate UUID" errors.
53
+ */
54
+ discoverDevices() {
55
+ // Start discovering Sony devices on the network
56
+ this.discoverer.startDiscovery();
57
+ this.discoverer.on("new-device-found" /* NewDeviceFound */, device => this.publishDevice(device));
58
+ }
59
+ publishDevice(device) {
60
+ // generate a unique id for the accessory this should be generated from
61
+ const uuid = this.api.hap.uuid.generate(device.UDN + (process.env.HOMEBRIDGE_SONY_AUDIO_DEV || ''));
62
+ // see if an accessory with the same uuid has already been registered and restored from
63
+ // the cached devices we stored in the `configureAccessory` method above
64
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
65
+ if (existingAccessory) {
66
+ // the accessory already exists
67
+ if (device) {
68
+ this.log.info('Restoring existing accessory from cache:', existingAccessory.displayName);
69
+ // create the accessory handler for the restored accessory
70
+ // this is imported from `platformAccessory.ts`
71
+ new sonyAudioAccessory_1.SonyAudioAccessory(this, existingAccessory);
72
+ // update accessory cache with any changes to the accessory details and information
73
+ this.api.updatePlatformAccessories([existingAccessory]);
74
+ }
75
+ else if (!device) {
76
+ // it is possible to remove platform accessories at any time using `api.unregisterPlatformAccessories`, eg.:
77
+ // remove platform accessories when no longer present
78
+ this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [existingAccessory]);
79
+ this.log.info('Removing existing accessory from cache:', existingAccessory.displayName);
80
+ }
81
+ }
82
+ else {
83
+ // the accessory does not yet exist, so we need to create it
84
+ this.log.info('Adding new accessory:', device.systemInfo.name);
85
+ // create a new Sony Audio accessory
86
+ const accessory = new this.api.platformAccessory(device.systemInfo.name, uuid, 34 /* AUDIO_RECEIVER */);
87
+ // store a copy of the device object in the `accessory.context`
88
+ accessory.context = device;
89
+ // create the accessory handler for the newly create accessory
90
+ new sonyAudioAccessory_1.SonyAudioAccessory(this, accessory);
91
+ // publish external accessories (the accessory has a television service)
92
+ this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [accessory]);
93
+ }
94
+ // save Sony Device for the next correct shutdown
95
+ this.devices.push(device);
96
+ }
97
+ }
98
+ exports.SonyAudioHomebridgePlatform = SonyAudioHomebridgePlatform;
99
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAEA,yCAAwD;AACxD,6DAA0D;AAC1D,6CAA2D;AAG3D;;;;GAIG;AACH,MAAa,2BAA2B;IAUtC,YACkB,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QAZV,YAAO,GAAmB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/C,mBAAc,GAA0B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;QAEpF,oDAAoD;QACpC,gBAAW,GAAoC,EAAE,CAAC;QAElD,YAAO,GAAiB,EAAE,CAAC;QAQzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxE,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE3C,8FAA8F;QAC9F,4FAA4F;QAC5F,2FAA2F;QAC3F,yCAAyC;QACzC,IAAI,CAAC,GAAG,C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D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACF;AAvGD,kEAuGC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
3
+ */
4
+ export declare const PLATFORM_NAME = "SonyAudio";
5
+ /**
6
+ * This must match the name of your plugin as defined the package.json
7
+ */
8
+ export declare const PLUGIN_NAME = "homebridge-sony-audio";
9
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,WAAW,0BAA0B,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
4
+ /**
5
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
6
+ */
7
+ exports.PLATFORM_NAME = 'SonyAudio';
8
+ /**
9
+ * This must match the name of your plugin as defined the package.json
10
+ */
11
+ exports.PLUGIN_NAME = 'homebridge-sony-audio';
12
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,aAAa,GAAG,WAAW,CAAC;AAEzC;;GAEG;AACU,QAAA,WAAW,GAAG,uBAAuB,CAAC"}