Skip to content

Commit

Permalink
Fix error logging in bin-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
LeLunZ committed Sep 3, 2024
1 parent 8cbe4a4 commit 63c9be6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/scripts/alwaysOnTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ const hostname = values['hostname'] as string;

let pictureSettingsOff: null|PictureSetting = null;

const logger = {
error: rl.write,
};

(async () => {
rl.write('Running first test to determine if TV is always on or off');
await rl.question('Turn your TV off now and press enter when ready: ');
rl.write('Wait for a few seconds...');
try {
const mqttHelper = new HisenseMQTTClient({sslmode: sslMode, ipaddress: hostname, sslcertificate: sslCertificate, sslprivatekey: sslPrivateKey}, macaddress, console);
const mqttHelper = new HisenseMQTTClient({sslmode: sslMode, ipaddress: hostname, sslcertificate: sslCertificate, sslprivatekey: sslPrivateKey}, macaddress, logger);
const timeout = setTimeout(() => {
mqttHelper.mqttClient.end(true);
rl.write('Could not detect always on TV');
Expand Down
6 changes: 5 additions & 1 deletion src/scripts/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ const sslPrivateKey = (values['keyfile'] ?? '') as string;
const macaddress = values['mac'] as string;
const hostname = values['hostname'] as string;

const logger = {
error: rl.write,
};

try {
const mqttHelper = new HisenseMQTTClient({sslmode: sslMode, ipaddress: hostname, sslcertificate: sslCertificate, sslprivatekey: sslPrivateKey}, macaddress, console);
const mqttHelper = new HisenseMQTTClient({sslmode: sslMode, ipaddress: hostname, sslcertificate: sslCertificate, sslprivatekey: sslPrivateKey}, macaddress, logger);

mqttHelper.mqttClient.on('connect', () => {
mqttHelper.callService('ui_service', 'gettvstate');
Expand Down
8 changes: 6 additions & 2 deletions src/scripts/sendCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {parseArgs} from 'node:util';
import {HisenseMQTTClient} from '../hisenseMQTTClient';
import {HisenseMQTTClient} from '../hisenseMQTTClient.js';
import readline from 'node:readline/promises';

const args = process.argv.slice(2);
Expand Down Expand Up @@ -52,8 +52,12 @@ if(!(action in getCommands)) {
process.exit(1);
}

const logger = {
error: rl.write,
};

try{
const mqttHelper = new HisenseMQTTClient({sslmode: sslMode, ipaddress: hostname, sslcertificate: sslCertificate, sslprivatekey: sslPrivateKey}, macaddress);
const mqttHelper = new HisenseMQTTClient({sslmode: sslMode, ipaddress: hostname, sslcertificate: sslCertificate, sslprivatekey: sslPrivateKey}, macaddress, logger);

mqttHelper.mqttClient.on('connect', () => {

Expand Down

0 comments on commit 63c9be6

Please sign in to comment.