2018-05-24 10:36:16 -06:00
|
|
|
import {SprinklersDevice} from "@common/sprinklers";
|
|
|
|
import * as mqtt from "@common/sprinklers/mqtt";
|
|
|
|
|
2018-06-25 02:20:44 -06:00
|
|
|
export class ServerState {
|
2018-05-24 10:36:16 -06:00
|
|
|
mqttClient!: mqtt.MqttApiClient;
|
|
|
|
device!: SprinklersDevice;
|
|
|
|
|
|
|
|
start() {
|
2018-06-16 23:54:03 -06:00
|
|
|
const mqttUrl = process.env.MQTT_URL;
|
|
|
|
if (!mqttUrl) {
|
|
|
|
throw new Error("Must specify a MQTT_URL to connect to");
|
|
|
|
}
|
|
|
|
this.mqttClient = new mqtt.MqttApiClient(mqttUrl);
|
2018-05-24 10:36:16 -06:00
|
|
|
this.device = this.mqttClient.getDevice("grinklers");
|
|
|
|
|
|
|
|
this.mqttClient.start();
|
|
|
|
}
|
2018-06-25 02:20:44 -06:00
|
|
|
}
|