Skip to content

Commit da572e6

Browse files
committed
added variable based thermostat
1 parent 33e2623 commit da572e6

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const path = require('path')
2+
const HomeMaticAccessory = require(path.join(__dirname, 'HomeMaticAccessory.js'))
3+
4+
class HomeMaticVarBasedThermometerAccessory extends HomeMaticAccessory {
5+
publishServices (Service, Characteristic) {
6+
let self = this
7+
this.temperature = this.getService(Service.TemperatureSensor)
8+
this.enableLoggingService('weather')
9+
10+
this.cctemp = this.temperature.getCharacteristic(Characteristic.CurrentTemperature)
11+
.setProps({
12+
minValue: -100
13+
})
14+
.on('get', async (callback) => {
15+
let newValue = await self._ccu.getVariableValue(self._serial)
16+
if (callback) callback(null, parseFloat(newValue))
17+
})
18+
19+
this.cctemp.eventEnabled = true
20+
this.queryData()
21+
}
22+
23+
async queryData () {
24+
var self = this
25+
let newValue = await this._ccu.getVariableValue(this._serial)
26+
if (this.cctemp) {
27+
this.cctemp.updateValue(parseFloat(newValue), null)
28+
this.addLogEntry({temp: parseFloat(newValue), pressure: 0, humidity: 0})
29+
}
30+
31+
this.refreshTimer = setTimeout(() => {
32+
self.queryData()
33+
}, 10 * 60 * 1000)
34+
}
35+
36+
updateVariable () {
37+
this.queryData()
38+
}
39+
40+
shutdown () {
41+
this.log.debug('[VBT] shutdown')
42+
super.shutdown()
43+
clearTimeout(this.refreshTimer)
44+
}
45+
46+
static channelTypes () {
47+
return ['VARIABLE']
48+
}
49+
50+
static configurationItems () {
51+
return {
52+
}
53+
}
54+
}
55+
56+
module.exports = HomeMaticVarBasedThermometerAccessory

0 commit comments

Comments
 (0)