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.
20 lines
562 B
20 lines
562 B
import {SprinklersDevice} from "@common/sprinklers"; |
|
import * as mqtt from "@common/sprinklers/mqtt"; |
|
|
|
export class State { |
|
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(); |
|
} |
|
} |
|
|
|
export const state: State = new State();
|
|
|