heating stuff

This commit is contained in:
Wolfgang Hottgenroth 2018-09-03 21:38:03 +02:00
parent e1b6d15bd5
commit e3e8429108
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
2 changed files with 33 additions and 11 deletions

View File

@ -27,7 +27,7 @@
<p class="clear"></p>
</mat-tab>
<mat-tab label="Heizung">
<heatingcontroller></heatingcontroller>
<heatingcontroller topicPre="testTopic" label="testLabel"></heatingcontroller>
</mat-tab>
</mat-tab-group>

View File

@ -9,36 +9,58 @@ import { MqttclientService } from '../mqttclient.service'
'font-family': 'sans-serif' }">
{{label}}<br/>
<button mat-mini-fab color="primary" (click)="clickOff()" [ngStyle]="{'font-size':'100%'}">off</button>
<button mat-mini-fab color="primary" (click)="clickAbsent()" [ngStyle]="{'font-size':'100%'}">absent</button>
<button mat-mini-fab color="primary" (click)="clickOn()" [ngStyle]="{'font-size':'100%'}">on</button>
<button mat-mini-fab color="primary" (click)="clickForceOn()" [ngStyle]="{'font-size':'100%'}">forceOn</button>
<br/>
<!-- <input type="text" [value]="currentTemperature"></input> -->
<br/>
<!-- <input type="text" [value]="presetTemperature"></input> -->
</div>
`
})
export class HeatingControllerComponent implements OnInit {
@Input() topic : string = 'invalid'
@Input() topicPre : string = 'invalid'
commandTopic : string = 'invalid'
presetTopic : string = 'invalid'
feedbackPresetTopic : string = 'invalid'
temperatureTopic : string = 'invalid'
feedbackTemperatureTopic : string = 'invalid'
@Input() label : string = 'invalid'
currentTemperature : string
presetTemperature : string
constructor(private mqttclientService : MqttclientService) { }
ngOnInit() {
this.commandTopic = this.topicPre + '/command'
this.presetTopic = this.topicPre + '/presetTemperature'
this.feedbackPresetTopic = this.topicPre + '/presetTemperature/feedback'
this.temperatureTopic = this.topicPre + '/temperature'
this.feedbackTemperatureTopic = this.topicPre + '/temperature/feedback'
this.mqttclientService.register(this.feedbackTemperatureTopic, (message: string) => {
this.currentTemperature = message
})
this.mqttclientService.register(this.feedbackPresetTopic, (message: string) => {
this.presetTemperature = message
})
}
clickOn() {
console.log(`click on for ${this.topic}`)
this.mqttclientService.publish(this.topic, "ON")
console.log(`click on for ${this.commandTopic}`)
this.mqttclientService.publish(this.commandTopic, "ON")
}
clickAbsent() {
console.log(`click absent for ${this.topic}`)
this.mqttclientService.publish(this.topic, "ABSENT")
clickForceOn() {
console.log(`click absent for ${this.commandTopic}`)
this.mqttclientService.publish(this.commandTopic, "FORCE_ON")
}
clickOff() {
console.log(`click off for ${this.topic}`)
this.mqttclientService.publish(this.topic, "OFF")
console.log(`click off for ${this.commandTopic}`)
this.mqttclientService.publish(this.commandTopic, "OFF")
}
}