Update Accessories
This commit is contained in:
+11
-9
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user