Reset sunset times every time enabled

This commit is contained in:
watsonb8 2020-04-11 16:44:55 -04:00
parent 106a1280dd
commit 6625ce952a
2 changed files with 22 additions and 2 deletions

21
deploy.sh Executable file
View File

@ -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

View File

@ -31,7 +31,6 @@ export class FluxAccessory implements IAccessory {
private _switchService: HAPNodeJS.Service; private _switchService: HAPNodeJS.Service;
private _infoService: HAPNodeJS.Service; private _infoService: HAPNodeJS.Service;
private _isEnabled: boolean;
private _hue: Api; private _hue: Api;
private _lights: Array<Light> = []; private _lights: Array<Light> = [];
@ -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 = new Scheduler(this._config.delay ? this._config.delay : 60000, 60000, this._log);
this._scheduler.addTask({ delegate: this.updateDelegate, title: "Update" }) this._scheduler.addTask({ delegate: this.updateDelegate, title: "Update" })
this._isEnabled = false;
this._hue = props.hue; this._hue = props.hue;
this.name = this._config.name; 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) => { private onSetEnabled = async (activeState: boolean, callback: (error?: Error | null | undefined) => void) => {
if (activeState) { if (activeState) {
this._times = getTimes(new Date(), this._config.latitude, this._config.longitude);
this._scheduler.start(); this._scheduler.start();
} else { } else {
this._scheduler.stop(); this._scheduler.stop();