separate actionTopic and feedbackTopic
This commit is contained in:
64
sample-configuration.json
Normal file
64
sample-configuration.json
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"switches": [
|
||||
{
|
||||
"room": "Wohnzimmer",
|
||||
"switches": [
|
||||
{
|
||||
"label": "kleine Lampe",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/LivingRoom/SmallLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/LivingRoom/SmallLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "große Lampe",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/LivingRoom/LargeLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/LivingRoom/LargeLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Sterne",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/LivingRoom/Stars/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/LivingRoom/Stars/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Stehlampe",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/LivingRoom/StandLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/LivingRoom/StandLight/state/feedback"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"room": "Esszimmer",
|
||||
"switches": [
|
||||
{
|
||||
"label": "kleine Lampe",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/DiningRoom/SmallLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/DiningRoom/SmallLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Stehlampe",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/DiningRoom/StandLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/DiningRoom/StandLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Schranklicht",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/DiningRoom/CupboardLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/DiningRoom/CupboardLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Naehkaestchenlicht",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/DiningRoom/NaehkaestchenLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/DiningRoom/NaehkaestchenLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Regallicht",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/DiningRoom/ShelfLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/DiningRoom/ShelfLight/state/feedback"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"windows": [
|
||||
{ "label": "Fenster 1", "topic": "test/fenster1" },
|
||||
{ "label": "Fenster 2", "topic": "test/fenster2" },
|
||||
{ "label": "Fenster 3", "topic": "test/fenster3" }
|
||||
]
|
||||
}
|
@ -8,16 +8,16 @@
|
||||
{{room.room}}
|
||||
</mat-panel-title>
|
||||
</mat-expansion-panel-header >
|
||||
<ledbutton2 *ngFor="let switch of room.switches" [topic]="switch.topic" [label]="switch.label"></ledbutton2>
|
||||
<ledbutton2 *ngFor="let switch of room.switches"
|
||||
[actionTopic]="switch.actionTopic" [feedbackTopic]="switch.feedbackTopic"
|
||||
[label]="switch.label"></ledbutton2>
|
||||
<p class="clear"></p>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</mat-tab>
|
||||
<mat-tab label="Fenster">
|
||||
<ledbox topic="led/test4" label="test4"></ledbox>
|
||||
<ledbox topic="led/test4" label="test4"></ledbox>
|
||||
<p class="clear"></p>
|
||||
|
||||
<ledbox *ngFor="let window of configuration.windows" [topic]="window.topic" [label]="window.label"></ledbox>
|
||||
<p class="clear"></p>
|
||||
</mat-tab>
|
||||
<mat-tab label="Heizung">
|
||||
|
||||
|
@ -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}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -16,16 +16,13 @@ import { MqttclientService } from '../mqttclient.service'
|
||||
})
|
||||
export class LedButtonGroup2Component implements OnInit {
|
||||
|
||||
actionTopic : string
|
||||
feedbackTopic : string
|
||||
@Input('topic') topicPre : string
|
||||
@Input() actionTopic : string
|
||||
@Input() feedbackTopic : string
|
||||
@Input() label : string
|
||||
|
||||
constructor(private mqttclientService : MqttclientService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.actionTopic = this.topicPre + '/state'
|
||||
this.feedbackTopic = this.topicPre + '/state/feedback'
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ export class MqttclientService {
|
||||
private callbacks : Map<string, callbackFunc> = new Map()
|
||||
|
||||
constructor() {
|
||||
this.mqttClient = Mqtt.connect('ws://mqttbroker:9001')
|
||||
this.mqttClient = Mqtt.connect('ws://127.0.0.1:9001')
|
||||
this.mqttClient.on('connect', () => {
|
||||
console.log('MQTT connected')
|
||||
this.callbacks.forEach((value: callbackFunc, key: string) => {
|
||||
|
Reference in New Issue
Block a user