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 { update } from "serializr";
|
|
|
|
|
|
|
|
import * as s from "@common/sprinklersRpc";
|
|
|
|
import * as schema from "@common/sprinklersRpc/schema";
|
|
|
|
|
|
|
|
export class MqttProgram extends s.Program {
|
|
|
|
onMessage(payload: string, topic: string | undefined) {
|
|
|
|
if (topic === "running") {
|
|
|
|
this.running = payload === "true";
|
|
|
|
} else if (topic == null) {
|
|
|
|
this.updateFromJSON(JSON.parse(payload));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateFromJSON(json: any) {
|
|
|
|
update(schema.program, this, json);
|
|
|
|
}
|
|
|
|
}
|