separate actionTopic and feedbackTopic
This commit is contained in:
@ -9,56 +9,9 @@ import { MqttclientService } from './mqttclient.service'
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'app';
|
||||
private topic : string = 'smartclient/configuration'
|
||||
configuration : any = {
|
||||
'switches': [
|
||||
{
|
||||
'room': 'Wohnzimmer',
|
||||
'switches': [
|
||||
{
|
||||
'label': 'kleine Lampe',
|
||||
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/SmallLight'
|
||||
},
|
||||
{
|
||||
'label': 'große Lampe',
|
||||
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/LargeLight'
|
||||
},
|
||||
{
|
||||
'label': 'Sterne',
|
||||
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/Stars'
|
||||
},
|
||||
{
|
||||
'label': 'Stehlampe',
|
||||
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/StandLight'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'room': 'Esszimmer',
|
||||
'switches': [
|
||||
{
|
||||
'label': 'kleine Lampe',
|
||||
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/SmallLight'
|
||||
},
|
||||
{
|
||||
'label': 'Stehlampe',
|
||||
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/StandLight'
|
||||
},
|
||||
{
|
||||
'label': 'Schranklicht',
|
||||
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/CupboardLight'
|
||||
},
|
||||
{
|
||||
'label': 'Naehkaestchenlicht',
|
||||
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/NaehkaestchenLight'
|
||||
},
|
||||
{
|
||||
'label': 'Regallicht',
|
||||
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/ShelfLight'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
configuration : any = {
|
||||
'switches': [],
|
||||
'windows': []
|
||||
}
|
||||
|
||||
constructor(private mqttclientService : MqttclientService) {
|
||||
@ -66,6 +19,11 @@ export class AppComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.mqttclientService.register(this.topic, (message: string) => {
|
||||
try {
|
||||
this.configuration = JSON.parse(message)
|
||||
} catch (e) {
|
||||
alert(`Error when parsing received configuration: ${e}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user