Files
smartclient/src/app/app.component.ts

31 lines
736 B
TypeScript

import { Component, OnInit } from '@angular/core';
import { MqttclientService } from './mqttclient.service'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'app';
private topic : string = 'smartclient/configuration'
configuration : any = {
'switches': [],
'windows': []
}
constructor(private mqttclientService : MqttclientService) {
}
ngOnInit() {
this.mqttclientService.register(this.topic, (message: string) => {
try {
this.configuration = JSON.parse(message)
} catch (e) {
alert(`Error when parsing received configuration: ${e}`)
}
})
}
}