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
+11 -9
View File
@@ -94,15 +94,17 @@ export class powerSocketAccessory extends accessory {
.then((response) => {
const devices = JSON.parse(response.body)
for (const device of devices.powersocket) {
if (device.id == this.accessory.context.device.typeId) {
if (device.state == 'on') {
this.state.On = true
} else {
this.state.On = false
if (devices.hasOwnProperty('powersocket')) {
for (const device of devices.powersocket) {
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)
break
}
this.service.updateCharacteristic(this.platform.Characteristic.On, this.state.On)
break
}
}
})
@@ -115,7 +117,7 @@ export class powerSocketAccessory extends accessory {
this.state.On = value as boolean
// http://$domoticaIP/external/WebUpdate.php?data=PowerSocket/$id/$state/
httpRequest("http://" + this.platform.config.hostname + '/external/WebUpdate.php?data=PowerSocket/' + this.accessory.context.device.typeId + '/' + (this.state.On? '1': '0') + '/')
httpRequest("http://" + 'administration-container:8080' + '/external/WebUpdate.php?data=PowerSocket/' + this.accessory.context.device.typeId + '/' + (this.state.On? '1': '0') + '/')
.catch((error) => {
this.platform.log.debug('powerSocketAccessory::setOn Error ->' + error)
})