Update Accessories

This commit is contained in:
2025-03-03 14:27:52 +01:00
parent 90c728a2be
commit e9459044a0
8 changed files with 102 additions and 124 deletions
+17 -15
View File
@@ -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)
})