Update Accessories
This commit is contained in:
+17
-15
@@ -94,21 +94,23 @@ export class klikAanKlikUitAccessory extends accessory {
|
||||
.then((response) => {
|
||||
const devices = JSON.parse(response.body)
|
||||
|
||||
for (const device of devices.klikaanklikuit) {
|
||||
if (device.id == this.accessory.context.device.typeId) {
|
||||
if (device.state == 'on') {
|
||||
this.state.On = true
|
||||
} else {
|
||||
this.state.On = false
|
||||
}
|
||||
this.service.updateCharacteristic(this.platform.Characteristic.On, this.state.On)
|
||||
if (devices.hasOwnProperty('klikaanklikuit')) {
|
||||
for (const device of devices.klikaanklikuit) {
|
||||
if (device.id == this.accessory.context.device.typeId) {
|
||||
if (device.state == 'on') {
|
||||
this.state.On = true
|
||||
} else {
|
||||
this.state.On = false
|
||||
}
|
||||
this.service.updateCharacteristic(this.platform.Characteristic.On, this.state.On)
|
||||
|
||||
if (device.dimmable != 'false') { // WTF?
|
||||
this.state.Brightness = device.dimLevel;
|
||||
this.service.updateCharacteristic(this.platform.Characteristic.Brightness, this.state.Brightness)
|
||||
}
|
||||
if (device.dimmable != 'false') { // WTF?
|
||||
this.state.Brightness = device.dimLevel;
|
||||
this.service.updateCharacteristic(this.platform.Characteristic.Brightness, this.state.Brightness)
|
||||
}
|
||||
|
||||
break
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -121,7 +123,7 @@ export class klikAanKlikUitAccessory extends accessory {
|
||||
this.state.On = value as boolean
|
||||
|
||||
// http://$domoticaIP/external/WebUpdate.php?data=KlikAanKlikUit/$id/$state/
|
||||
httpRequest("http://" + this.platform.config.hostname + '/external/WebUpdate.php?data=KlikAanKlikUit/' + this.accessory.context.device.typeId + '/' + (this.state.On? '1': '0') + '/')
|
||||
httpRequest("http://" + 'administration-container:8080' + '/external/WebUpdate.php?data=KlikAanKlikUit/' + this.accessory.context.device.typeId + '/' + (this.state.On? '1': '0') + '/')
|
||||
.catch((error) => {
|
||||
this.platform.log.debug('klikAanKlikUitAccessory::setOn Error ->' + error)
|
||||
})
|
||||
@@ -135,7 +137,7 @@ export class klikAanKlikUitAccessory extends accessory {
|
||||
this.state.Brightness = value as number
|
||||
|
||||
// http://$domoticaIP/external/WebUpdate.php?data=KlikAanKlikUit/$id/$state/$dimLevel
|
||||
httpRequest("http://" + this.platform.config.hostname + '/external/WebUpdate.php?data=KlikAanKlikUit/' + this.accessory.context.device.typeId + '//' + this.state.Brightness)
|
||||
httpRequest("http://" + 'administration-container:8080' + '/external/WebUpdate.php?data=KlikAanKlikUit/' + this.accessory.context.device.typeId + '//' + this.state.Brightness)
|
||||
.catch((error) => {
|
||||
this.platform.log.debug('klikAanKlikUitAccessory::setBrightness Error ->' + error)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user