From 6625ce952a273b1d5fa8a95781380efbc867da8e Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Sat, 11 Apr 2020 16:44:55 -0400 Subject: [PATCH] Reset sunset times every time enabled --- deploy.sh | 21 +++++++++++++++++++++ src/fluxAccessory.ts | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 deploy.sh diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..893a97f --- /dev/null +++ b/deploy.sh @@ -0,0 +1,21 @@ +#!/bin/bash +remote_user="bmw" +remote_server="192.168.1.31" +deploy_location="/home/bmw/homebridge-flux" + +#build +tsc --build +#copy files to remote machine +scp -r bin $remote_user@$remote_server:$deploy_location +scp package.json $remote_user@$remote_server:$deploy_location + +#install package +ssh -t $remote_user@$remote_server "sudo npm install -g --unsafe-perm $deploy_location" + +#restart service +ssh -t +ssh -t $remote_user@$remote_server "sudo systemctl restart homebridge.service" +ssh -t $remote_user@$remote_server "sudo systemctl status homebridge.service" + +echo done +exit diff --git a/src/fluxAccessory.ts b/src/fluxAccessory.ts index 78fbb3a..b9078e9 100644 --- a/src/fluxAccessory.ts +++ b/src/fluxAccessory.ts @@ -31,7 +31,6 @@ export class FluxAccessory implements IAccessory { private _switchService: HAPNodeJS.Service; private _infoService: HAPNodeJS.Service; - private _isEnabled: boolean; private _hue: Api; private _lights: Array = []; @@ -51,7 +50,6 @@ export class FluxAccessory implements IAccessory { this._scheduler = new Scheduler(this._config.delay ? this._config.delay : 60000, 60000, this._log); this._scheduler.addTask({ delegate: this.updateDelegate, title: "Update" }) - this._isEnabled = false; this._hue = props.hue; this.name = this._config.name; @@ -88,6 +86,7 @@ export class FluxAccessory implements IAccessory { */ private onSetEnabled = async (activeState: boolean, callback: (error?: Error | null | undefined) => void) => { if (activeState) { + this._times = getTimes(new Date(), this._config.latitude, this._config.longitude); this._scheduler.start(); } else { this._scheduler.stop();