Skip to content

Commit

Permalink
ver. 3.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
NikDevx committed May 4, 2021
1 parent 5bf692b commit b1073e0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 48 deletions.
70 changes: 35 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge Philips Air",
"name": "homebridge-philips-air",
"version": "3.3.3",
"version": "3.3.4",
"description": "Homebridge Plugin for Philips Air Purifiers",
"main": "dist/index.js",
"repository": {
Expand Down Expand Up @@ -52,6 +52,7 @@
"watch": "npm run clean && tsc --watch"
},
"devDependencies": {
"@types/chmodr": "^1.0.0",
"@types/node": "^14.14.36",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
Expand All @@ -74,7 +75,7 @@
"sensor"
],
"dependencies": {
"log-timestamp": "^0.3.0",
"philips-air": "^0.6.0"
"philips-air": "^0.6.0",
"time-stamp": "^2.2.0"
}
}
15 changes: 5 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {AirClient, HttpClient, CoapClient, PlainCoapClient, HttpClientLegacy} fr
import {promisify} from 'util';
import {exec} from 'child_process';
import * as fs from 'fs';
import timestamp from 'time-stamp';
import {PhilipsAirPlatformConfig, DeviceConfig} from './configTypes';
import {PurifierStatus, PurifierFilters, PurifierFirmware} from './deviceTypes';

Expand Down Expand Up @@ -134,11 +135,8 @@ class PhilipsAirPlatform implements DynamicPlatformPlugin {
setInterval(function() {
exec('python3 /usr/lib/node_modules/homebridge-philips-air/node_modules/philips-air/pyaircontrol.py --ipaddr ' + purifier.config.ip + ' --protocol coap --status', (error, stdout, stderr) => {
if (error || stderr) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('log-timestamp')(function() {
return '[' + ('0' + new Date().getDate()).slice(-2) + '.' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '.' + new Date().getFullYear() + ', ' + ('0' + new Date().getHours()).slice(-2) + ':' + ('0' + new Date().getMinutes()).slice(-2) + ':' + new Date().getSeconds() + ']';
});
console.log('\x1b[36m[Philips Air] \x1b[31m[' + purifier.config.name + '] Unable to get data for polling.\x1b[0m');
console.log(timestamp('[DD.MM.YYYY, HH:mm:ss] ') + '\x1b[36m[Philips Air] \x1b[31m[' + purifier.config.name + '] Unable to get data for polling: Error: spawnSync python3 ETIMEDOUT.\x1b[0m');
console.log(timestamp('[DD.MM.YYYY, HH:mm:ss] ') + '\x1b[33mIf your have "Error: spawnSync python3 ETIMEDOUT" your need unplug the accessory from outlet for 10 seconds and plug again.\x1b[0m');
}

if (error || stderr || error && stderr) {
Expand Down Expand Up @@ -215,11 +213,8 @@ class PhilipsAirPlatform implements DynamicPlatformPlugin {
if (obj.func != 'P') {
exec('airctrl --ipaddr ' + purifier.config.ip + ' --protocol coap --func P', (error, stdout, stderr) => {
if (error || stderr) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('log-timestamp')(function() {
return '[' + ('0' + new Date().getDate()).slice(-2) + '.' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '.' + new Date().getFullYear() + ', ' + ('0' + new Date().getHours()).slice(-2) + ':' + ('0' + new Date().getMinutes()).slice(-2) + ':' + new Date().getSeconds() + ']';
});
console.log('\x1b[36m[Philips Air] \x1b[31m[' + purifier.config.name + '] Unable to get data for polling.\x1b[0m');
console.log(timestamp('[DD.MM.YYYY, HH:mm:ss] ') + '\x1b[36m[Philips Air] \x1b[31m[' + purifier.config.name + '] Unable to get data for polling: Error: spawnSync python3 ETIMEDOUT.\x1b[0m');
console.log(timestamp('[DD.MM.YYYY, HH:mm:ss] ') + '\x1b[33mIf your have "Error: spawnSync python3 ETIMEDOUT" your need unplug the accessory from outlet for 10 seconds and plug again.\x1b[0m');
}
});
}
Expand Down

0 comments on commit b1073e0

Please sign in to comment.