You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import {SprinklersDevice} from "@common/sprinklers";
|
|
|
|
import * as mqtt from "@common/sprinklers/mqtt";
|
|
|
|
|
|
|
|
export class ServerState {
|
|
|
|
mqttClient!: mqtt.MqttApiClient;
|
|
|
|
device!: SprinklersDevice;
|
|
|
|
|
|
|
|
start() {
|
|
|
|
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);
|
|
|
|
this.device = this.mqttClient.getDevice("grinklers");
|
|
|
|
|
|
|
|
this.mqttClient.start();
|
|
|
|
}
|
|
|
|
}
|