Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from n0rt0nthec4t/alpha
Browse files Browse the repository at this point in the history
0.1.7 release
  • Loading branch information
n0rt0nthec4t authored Sep 13, 2024
2 parents c1e4d5e + ac083a1 commit 2b0954a
Show file tree
Hide file tree
Showing 26 changed files with 2,992 additions and 2,689 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

All notable changes to `Nest_accfactory` will be documented in this file. This project tries to adhere to [Semantic Versioning](http://semver.org/).

## 0.1.7 (2024-09-13)

## 0.1.6 (2023-09-03)
- General code cleanup and bug fixes
- External dependancy reductions, dropped pbf and axios libraries
- Nest Cam with Floodlight support with light on/off and brightness control
- Fixed issued with setting range temperatures on Nest Thermostat(s)

## 0.1.6 (2024-09-07)

- Common code bases between my two projects, homebridge-nest-accfactory and Nest_accfactory
- Configuration file format has change, but for this version, we'll handle the existing one
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ RUN ./configure \
#--enable-vaapi \
--disable-ffnvcodec \
#--enable-amf \
--disable-doc \
--disable-debug \
--disable-shared \
--enable-pthreads \
--enable-static \
--enable-version3 \
--enable-pthreads \
--enable-runtime-cpudetect \
${FFMPEG_EXTRA_OPTIONS} \
&& make -j 4 \
&& make install
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ This is a HAP-NodeJS accessory I have developed to allow Nest devices to be used

The following Nest devices are supported

* Nest Thermostats (Gen 1, Gen 2, Gen 3, E)
* Nest Protects (Gen 1, Gen 2)
* Nest Temp Sensors
* Nest Cameras (Cam Indoor, IQ Indoor, Outdoor, IQ Outdoor)
* Nest Hello (Wired Gen 1)
* Nest Thermostats (1st gen, 2nd gen, 3rd gen, E, 2020 mirror edition, 4th gen)
* Nest Protects (1st and 2nd gen)
* Nest Temp Sensors (1st gen)
* Nest Cameras (Cam Indoor, IQ Indoor, Outdoor, IQ Outdoor, Cam with Floodlight)
* Nest Doorbells (wired 1st gen)

The accessory supports connection to Nest using a Nest account OR a Google (migrated Nest account) account.

Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"displayName": "Nest Accfactory",
"name": "nest-accfactory",
"homepage": "https://github.com/n0rt0nthec4t/Nest_accfactory",
"version": "0.1.6",
"version": "0.1.7",
"description": "HomeKit integration for Nest devices using HAP-NodeJS library",
"license": "Apache-2.0",
"author": "n0rt0nthec4t",
Expand Down Expand Up @@ -42,25 +42,24 @@
"thermostat",
"temperature",
"smoke",
"sensor"
"sensor",
"floodlight"
],
"devDependencies": {
"@eslint/js": "^9.9.1",
"@stylistic/eslint-plugin": "^2.7.2",
"@eslint/js": "^9.10.0",
"@stylistic/eslint-plugin": "^2.8.0",
"@types/node": "^20.16.1",
"@typescript-eslint/parser": "^8.4.0",
"@typescript-eslint/parser": "^8.5.0",
"copyfiles": "^2.4.1",
"eslint": "^9.9.1",
"eslint": "^9.10.0",
"nodemon": "^3.1.4",
"prettier": "^3.3.3",
"prettier-eslint": "^16.3.0",
"rimraf": "^6.0.1"
},
"dependencies": {
"hap-nodejs": "^1.1.0",
"axios": "^1.7.7",
"chalk": "^5.3.0",
"pbf": "^4.0.1",
"protobufjs": "^7.4.0",
"ws": "^8.18.0"
}
Expand Down
44 changes: 27 additions & 17 deletions src/HomeKitDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// HomeKitDevice.updateServices(deviceData)
// HomeKitDevice.messageServices(type, message)
//
// Code version 3/9/2024
// Code version 13/9/2024
// Mark Hulskamp
'use strict';

Expand Down Expand Up @@ -104,7 +104,8 @@ export default class HomeKitDevice {
this.#eventEmitter.addListener(this.deviceData.uuid, this.#message.bind(this));
}

// Make copy of current data and store in this object
// Make a clone of current data and store in this object
// Important that we done have a 'linked' cope of the object data
// eslint-disable-next-line no-undef
this.deviceData = structuredClone(deviceData);

Expand Down Expand Up @@ -149,7 +150,10 @@ export default class HomeKitDevice {
this.deviceData.model === '' ||
typeof this.deviceData?.manufacturer !== 'string' ||
this.deviceData.manufacturer === '' ||
(this.#platform === undefined && typeof this.deviceData?.hkPairingCode !== 'string' && this.deviceData.hkPairingCode === '') ||
(this.#platform === undefined &&
typeof this.deviceData?.hkPairingCode !== 'string' &&
(new RegExp(/^([0-9]{3}-[0-9]{2}-[0-9]{3})$/).test(this.deviceData.hkPairingCode) === true ||
new RegExp(/^([0-9]{4}-[0-9]{4})$/).test(this.deviceData.hkPairingCode) === true)) ||
(this.#platform === undefined &&
typeof this.deviceData?.hkUsername !== 'string' &&
new RegExp(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/).test(this.deviceData.hkUsername) === false)
Expand Down Expand Up @@ -239,7 +243,7 @@ export default class HomeKitDevice {
}
}

async remove() {
remove() {
this?.log?.warn && this.log.warn('Device "%s" has been removed', this.deviceData.description);

if (this.#eventEmitter === undefined && typeof this.deviceData?.uuid === 'string' && this.deviceData.uuid !== '') {
Expand All @@ -249,7 +253,7 @@ export default class HomeKitDevice {

if (typeof this.removeServices === 'function') {
try {
await this.removeServices();
this.removeServices();
} catch (error) {
this?.log?.error && this.log.error('removeServices call for device "%s" failed. Error was', this.deviceData.description, error);
}
Expand Down Expand Up @@ -278,7 +282,7 @@ export default class HomeKitDevice {
// delete this;
}

async update(deviceData, forceUpdate) {
update(deviceData, forceUpdate) {
if (typeof deviceData !== 'object' || typeof forceUpdate !== 'boolean') {
return;
}
Expand Down Expand Up @@ -357,7 +361,7 @@ export default class HomeKitDevice {

if (typeof this.updateServices === 'function') {
try {
await this.updateServices(deviceData); // Pass updated data on for accessory to process as it needs
this.updateServices(deviceData); // Pass updated data on for accessory to process as it needs
} catch (error) {
this?.log?.error && this.log.error('updateServices call for device "%s" failed. Error was', this.deviceData.description, error);
}
Expand All @@ -381,6 +385,13 @@ export default class HomeKitDevice {

// Send event with data to set
this.#eventEmitter.emit(HomeKitDevice.SET, this.deviceData.uuid, values);

// Update the internal data for the set values, as could take sometime once we emit the event
Object.entries(values).forEach(([key, value]) => {
if (this.deviceData[key] !== undefined) {
this.deviceData[key] = value;
}
});
}

async get(values) {
Expand All @@ -393,17 +404,16 @@ export default class HomeKitDevice {
return;
}

// <---- TODO
// Send event with data to get. Once get has completed, callback will be called with the requested data
//this.#eventEmitter.emit(HomeKitDevice.GET, this.deviceData.uuid, values);
//
// await ....
// return gottenValues;
// <---- TODO
// Probable need some sort of await event
// Send event with data to get
// Once get has completed, we'll get an event back with the requested data
this.#eventEmitter.emit(HomeKitDevice.GET, this.deviceData.uuid, values);

// This should always return, but we probably should put in a timeout?
let results = await EventEmitter.once(this.#eventEmitter, HomeKitDevice.GET + '->' + this.deviceData.uuid);
return results?.[0];
}

async #message(type, message) {
#message(type, message) {
switch (type) {
case HomeKitDevice.ADD: {
// Got message for device add
Expand All @@ -429,7 +439,7 @@ export default class HomeKitDevice {
// This is not a message we know about, so pass onto accessory for it to perform any processing
if (typeof this.messageServices === 'function') {
try {
await this.messageServices(type, message);
this.messageServices(type, message);
} catch (error) {
this?.log?.error &&
this.log.error('messageServices call for device "%s" failed. Error was', this.deviceData.description, error);
Expand Down
26 changes: 2 additions & 24 deletions src/HomeKitHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// -- Eve Degree/Weather2 history
// -- Eve Water guard history
//
// Credit to https://github.com/simont77/fakegato-history for the work on starting the EveHome comms protocol decoding
//
// Version 29/8/2024
// Mark Hulskamp

Expand Down Expand Up @@ -2073,15 +2075,6 @@ export default class HomeKitHistory {
numberToEveHexString(1, 8),
); // first entry

if (this?.log?.debug) {
this.log.debug(
'#EveHistoryStatus: history for "%s:%s" (%s) - Entries %s',
this.EveHome.type,
this.EveHome.sub,
this.EveHome.evetype,
this.EveHome.count,
);
}
return encodeEveData(value);
}

Expand Down Expand Up @@ -2299,26 +2292,11 @@ export default class HomeKitHistory {
}
if (this.EveHome.entry > this.EveHome.count) {
// No more history data to send back
this?.log?.debug &&
this.log.debug(
'#EveHistoryEntries: sent "%s" entries to EveHome ("%s") for "%s:%s"',
this.EveHome.send,
this.EveHome.evetype,
this.EveHome.type,
this.EveHome.sub,
);
this.EveHome.send = 0; // no more to send
dataStream += '00';
}
} else {
// We're not transferring any data back
this?.log?.debug &&
this.log.debug(
'#EveHistoryEntries: no more entries to send to EveHome ("%s") for "%s:%s',
this.EveHome.evetype,
this.EveHome.type,
this.EveHome.sub,
);
this.EveHome.send = 0; // no more to send
dataStream = '00';
}
Expand Down
Loading

0 comments on commit 2b0954a

Please sign in to comment.