Update Accessories
This commit is contained in:
+4
-14
@@ -23,9 +23,9 @@ export class activityAccessory extends accessory {
|
|||||||
typeId: device.id,
|
typeId: device.id,
|
||||||
uniqueId: "Activity." + device.id,
|
uniqueId: "Activity." + device.id,
|
||||||
deviceName: device.name,
|
deviceName: device.name,
|
||||||
switchable: device.switchable,
|
switchable: "false",
|
||||||
dimmable: "true",
|
dimmable: "false",
|
||||||
detailedType: device.type
|
detailedType: ""
|
||||||
}
|
}
|
||||||
activityDevices.push(object)
|
activityDevices.push(object)
|
||||||
}
|
}
|
||||||
@@ -49,22 +49,12 @@ export class activityAccessory extends accessory {
|
|||||||
.setCharacteristic(this.platform.Characteristic.Model, 'Domotica-Activity')
|
.setCharacteristic(this.platform.Characteristic.Model, 'Domotica-Activity')
|
||||||
.setCharacteristic(this.platform.Characteristic.SerialNumber, '08000' + accessory.context.device.typeId)
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, '08000' + accessory.context.device.typeId)
|
||||||
|
|
||||||
//*
|
|
||||||
this.service = this.accessory.getService(this.platform.Service.Switch) || this.accessory.addService(this.platform.Service.Switch)
|
this.service = this.accessory.getService(this.platform.Service.Switch) || this.accessory.addService(this.platform.Service.Switch)
|
||||||
|
|
||||||
this.service.getCharacteristic(this.platform.Characteristic.On)
|
this.service.getCharacteristic(this.platform.Characteristic.On)
|
||||||
.onGet(this.getOn.bind(this))
|
.onGet(this.getOn.bind(this))
|
||||||
.onSet(this.setOn.bind(this));
|
.onSet(this.setOn.bind(this));
|
||||||
/*/
|
|
||||||
this.service = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch) || this.accessory.addService(this.platform.Service.StatefulProgrammableSwitch)
|
|
||||||
|
|
||||||
this.service.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent)
|
|
||||||
.onGet(this.getOn.bind(this));
|
|
||||||
|
|
||||||
this.service.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
|
|
||||||
.onGet(this.getOn.bind(this))
|
|
||||||
.onSet(this.setOn.bind(this));
|
|
||||||
//*/
|
|
||||||
this.setName(accessory.context.device.deviceName)
|
this.setName(accessory.context.device.deviceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +75,7 @@ export class activityAccessory extends accessory {
|
|||||||
|
|
||||||
async setOn(value: CharacteristicValue) {
|
async setOn(value: CharacteristicValue) {
|
||||||
// http://$domoticaIP/external/WebUpdate.php?data=Activity/$id/
|
// http://$domoticaIP/external/WebUpdate.php?data=Activity/$id/
|
||||||
httpRequest("http://" + this.platform.config.hostname + '/external/WebUpdate.php?data=Activity/' + this.accessory.context.device.typeId + '/')
|
httpRequest("http://" + 'administration-container:8080' + '/external/WebUpdate.php?data=Activity/' + this.accessory.context.device.typeId + '/')
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('activityAccessory::setOn Error ->' + error)
|
this.platform.log.debug('activityAccessory::setOn Error ->' + error)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ export class cameraAccessory extends accessory {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const devices = JSON.parse(response.body)
|
const devices = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if (devices.hasOwnProperty('camera')) {
|
||||||
for (const device of devices.camera) {
|
for (const device of devices.camera) {
|
||||||
if (device.id == this.accessory.context.device.typeId) {
|
if (device.id == this.accessory.context.device.typeId) {
|
||||||
if (device.motionstate == 'absent') {
|
if (device.motionstate == 'absent') {
|
||||||
@@ -101,6 +102,7 @@ export class cameraAccessory extends accessory {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('cameraAccessory::update Error ->' + error)
|
this.platform.log.debug('cameraAccessory::update Error ->' + error)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export class doorWindowSensorAccessory extends accessory {
|
|||||||
private service: Service
|
private service: Service
|
||||||
|
|
||||||
private state = {
|
private state = {
|
||||||
Position: this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED
|
ContactSensorState: this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
static async discoverDevices(platform: domoticaPlatform): Promise<device[]> {
|
static async discoverDevices(platform: domoticaPlatform): Promise<device[]> {
|
||||||
@@ -61,16 +61,7 @@ export class doorWindowSensorAccessory extends accessory {
|
|||||||
|
|
||||||
this.service.getCharacteristic(this.platform.Characteristic.ContactSensorState)
|
this.service.getCharacteristic(this.platform.Characteristic.ContactSensorState)
|
||||||
.onGet(this.getContactSensorState.bind(this));
|
.onGet(this.getContactSensorState.bind(this));
|
||||||
/*
|
|
||||||
this.service.getCharacteristic(this.platform.Characteristic.CurrentPosition)
|
|
||||||
.onGet(this.getCurrentPosition.bind(this));
|
|
||||||
|
|
||||||
this.service.getCharacteristic(this.platform.Characteristic.PositionState)
|
|
||||||
.onGet(this.getPositionState.bind(this));
|
|
||||||
|
|
||||||
this.service.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
||||||
.onGet(this.getTargetPosition.bind(this))
|
|
||||||
*/
|
|
||||||
this.setName(accessory.context.device.deviceName)
|
this.setName(accessory.context.device.deviceName)
|
||||||
this.update()
|
this.update()
|
||||||
}
|
}
|
||||||
@@ -82,14 +73,11 @@ export class doorWindowSensorAccessory extends accessory {
|
|||||||
setValue(key, value) {
|
setValue(key, value) {
|
||||||
if (key == "state" && value != "") {
|
if (key == "state" && value != "") {
|
||||||
if (value == "Off") {
|
if (value == "Off") {
|
||||||
this.state.Position = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED
|
this.state.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED
|
||||||
} else {
|
} else {
|
||||||
this.state.Position = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED
|
this.state.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED
|
||||||
}
|
}
|
||||||
/*
|
this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.state.ContactSensorState)
|
||||||
this.service.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.state.Position)
|
|
||||||
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.state.Position)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,43 +91,28 @@ export class doorWindowSensorAccessory extends accessory {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const devices = JSON.parse(response.body)
|
const devices = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if (devices.hasOwnProperty('doorwindow')) {
|
||||||
for (const device of devices.doorwindow) {
|
for (const device of devices.doorwindow) {
|
||||||
if (device.id == this.accessory.context.device.typeId) {
|
if (device.id == this.accessory.context.device.typeId) {
|
||||||
if (device.state == 'closed') {
|
if (device.state == 'closed') {
|
||||||
this.state.Position = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED
|
this.state.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED
|
||||||
} else { // open
|
} else { // open
|
||||||
this.state.Position = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED
|
this.state.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
this.service.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.state.Position)
|
this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.state.ContactSensorState)
|
||||||
this.service.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.state.Position)
|
|
||||||
*/
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('doorWindowSensorAccessory::update Error ->' + error)
|
this.platform.log.debug('doorWindowSensorAccessory::update Error ->' + error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
getCurrentPosition(): CharacteristicValue {
|
|
||||||
return this.state.Position
|
|
||||||
}
|
|
||||||
|
|
||||||
getPositionState(): CharacteristicValue {
|
|
||||||
return this.platform.Characteristic.PositionState.STOPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
getTargetPosition(): CharacteristicValue {
|
|
||||||
return this.state.Position
|
|
||||||
}
|
|
||||||
|
|
||||||
getPosition(): CharacteristicValue {
|
|
||||||
return this.state.Position
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
getContactSensorState(): CharacteristicValue {
|
getContactSensorState(): CharacteristicValue {
|
||||||
return this.state.Position
|
return this.state.ContactSensorState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ export class environmentSensorAccessory extends accessory {
|
|||||||
this.state.Temperature = value / 100
|
this.state.Temperature = value / 100
|
||||||
this.serviceTemperature.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.state.Temperature)
|
this.serviceTemperature.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.state.Temperature)
|
||||||
}
|
}
|
||||||
if (key == "humidity" && value != "") {
|
else if (key == "humidity" && value != "") {
|
||||||
this.state.Humidity = value / 100
|
this.state.Humidity = value / 100
|
||||||
this.serviceHumidity.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.state.Humidity)
|
this.serviceHumidity.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.state.Humidity)
|
||||||
}
|
}
|
||||||
@@ -93,15 +93,19 @@ export class environmentSensorAccessory extends accessory {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const devices = JSON.parse(response.body)
|
const devices = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if (devices.hasOwnProperty('environment')) {
|
||||||
for (const device of devices.environment) {
|
for (const device of devices.environment) {
|
||||||
if (device.id == this.accessory.context.device.typeId) {
|
if (device.id == this.accessory.context.device.typeId) {
|
||||||
this.state.Temperature = device.temperature
|
this.state.Temperature = device.temperature
|
||||||
this.state.Humidity = device.humidity
|
this.state.Humidity = device.humidity
|
||||||
|
|
||||||
this.serviceTemperature.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.state.Temperature)
|
this.serviceTemperature.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.state.Temperature)
|
||||||
this.serviceHumidity.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.state.Humidity)
|
this.serviceHumidity.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.state.Humidity)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('environmentSensorAccessory::getTemperature Error ->' + error)
|
this.platform.log.debug('environmentSensorAccessory::getTemperature Error ->' + error)
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export class klikAanKlikUitAccessory extends accessory {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const devices = JSON.parse(response.body)
|
const devices = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if (devices.hasOwnProperty('klikaanklikuit')) {
|
||||||
for (const device of devices.klikaanklikuit) {
|
for (const device of devices.klikaanklikuit) {
|
||||||
if (device.id == this.accessory.context.device.typeId) {
|
if (device.id == this.accessory.context.device.typeId) {
|
||||||
if (device.state == 'on') {
|
if (device.state == 'on') {
|
||||||
@@ -111,6 +112,7 @@ export class klikAanKlikUitAccessory extends accessory {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('klikAanKlikUitAccessory::update Error ->' + error)
|
this.platform.log.debug('klikAanKlikUitAccessory::update Error ->' + error)
|
||||||
@@ -121,7 +123,7 @@ export class klikAanKlikUitAccessory extends accessory {
|
|||||||
this.state.On = value as boolean
|
this.state.On = value as boolean
|
||||||
|
|
||||||
// http://$domoticaIP/external/WebUpdate.php?data=KlikAanKlikUit/$id/$state/
|
// 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) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('klikAanKlikUitAccessory::setOn Error ->' + error)
|
this.platform.log.debug('klikAanKlikUitAccessory::setOn Error ->' + error)
|
||||||
})
|
})
|
||||||
@@ -135,7 +137,7 @@ export class klikAanKlikUitAccessory extends accessory {
|
|||||||
this.state.Brightness = value as number
|
this.state.Brightness = value as number
|
||||||
|
|
||||||
// http://$domoticaIP/external/WebUpdate.php?data=KlikAanKlikUit/$id/$state/$dimLevel
|
// 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) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('klikAanKlikUitAccessory::setBrightness Error ->' + error)
|
this.platform.log.debug('klikAanKlikUitAccessory::setBrightness Error ->' + error)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export class motionSensorAccessory extends accessory {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const devices = JSON.parse(response.body)
|
const devices = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if (devices.hasOwnProperty('motion')) {
|
||||||
for (const device of devices.motion) {
|
for (const device of devices.motion) {
|
||||||
if (device.id == this.accessory.context.device.typeId) {
|
if (device.id == this.accessory.context.device.typeId) {
|
||||||
if (device.state == 'absent') {
|
if (device.state == 'absent') {
|
||||||
@@ -94,11 +95,13 @@ export class motionSensorAccessory extends accessory {
|
|||||||
} else { // present
|
} else { // present
|
||||||
this.state.Motion = true
|
this.state.Motion = true
|
||||||
}
|
}
|
||||||
return this.state.Motion
|
|
||||||
this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.state.Motion)
|
this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.state.Motion)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('motionSensorAccessory::update Error ->' + error)
|
this.platform.log.debug('motionSensorAccessory::update Error ->' + error)
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export class powerSocketAccessory extends accessory {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const devices = JSON.parse(response.body)
|
const devices = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if (devices.hasOwnProperty('powersocket')) {
|
||||||
for (const device of devices.powersocket) {
|
for (const device of devices.powersocket) {
|
||||||
if (device.id == this.accessory.context.device.typeId) {
|
if (device.id == this.accessory.context.device.typeId) {
|
||||||
if (device.state == 'on') {
|
if (device.state == 'on') {
|
||||||
@@ -105,6 +106,7 @@ export class powerSocketAccessory extends accessory {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('powerSocketAccessory::update Error ->' + error)
|
this.platform.log.debug('powerSocketAccessory::update Error ->' + error)
|
||||||
@@ -115,7 +117,7 @@ export class powerSocketAccessory extends accessory {
|
|||||||
this.state.On = value as boolean
|
this.state.On = value as boolean
|
||||||
|
|
||||||
// http://$domoticaIP/external/WebUpdate.php?data=PowerSocket/$id/$state/
|
// 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) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('powerSocketAccessory::setOn Error ->' + error)
|
this.platform.log.debug('powerSocketAccessory::setOn Error ->' + error)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export class powerSwitchAccessory extends accessory {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
const devices = JSON.parse(response.body)
|
const devices = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if (devices.hasOwnProperty('powerswitch')) {
|
||||||
for (const device of devices.powerswitch) {
|
for (const device of devices.powerswitch) {
|
||||||
if (device.id == this.accessory.context.device.typeId) {
|
if (device.id == this.accessory.context.device.typeId) {
|
||||||
if (device.state == 'on') {
|
if (device.state == 'on') {
|
||||||
@@ -116,6 +117,7 @@ export class powerSwitchAccessory extends accessory {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('powerSwitchAccessory::update Error ->' + error)
|
this.platform.log.debug('powerSwitchAccessory::update Error ->' + error)
|
||||||
@@ -126,7 +128,7 @@ export class powerSwitchAccessory extends accessory {
|
|||||||
this.state.On = value as boolean
|
this.state.On = value as boolean
|
||||||
|
|
||||||
// http://$domoticaIP/external/WebUpdate.php?data=PowerSwitch/$id/$state/
|
// http://$domoticaIP/external/WebUpdate.php?data=PowerSwitch/$id/$state/
|
||||||
httpRequest("http://" + this.platform.config.hostname + '/external/WebUpdate.php?data=PowerSwitch/' + this.accessory.context.device.typeId + '/' + (this.state.On? '1': '0') + '/')
|
httpRequest("http://" + 'administration-container:8080' + '/external/WebUpdate.php?data=PowerSwitch/' + this.accessory.context.device.typeId + '/' + (this.state.On? '1': '0') + '/')
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('powerSwitchAccessory::setOn Error ->' + error)
|
this.platform.log.debug('powerSwitchAccessory::setOn Error ->' + error)
|
||||||
})
|
})
|
||||||
@@ -140,7 +142,7 @@ export class powerSwitchAccessory extends accessory {
|
|||||||
this.state.Brightness = value as number
|
this.state.Brightness = value as number
|
||||||
|
|
||||||
// http://$domoticaIP/external/WebUpdate.php?data=PowerSwitch/$id/$state/$dimLevel
|
// http://$domoticaIP/external/WebUpdate.php?data=PowerSwitch/$id/$state/$dimLevel
|
||||||
httpRequest("http://" + this.platform.config.hostname + '/external/WebUpdate.php?data=PowerSwitch/' + this.accessory.context.device.typeId + '//' + this.state.Brightness)
|
httpRequest("http://" + 'administration-container:8080' + '/external/WebUpdate.php?data=PowerSwitch/' + this.accessory.context.device.typeId + '///' + this.state.Brightness)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.platform.log.debug('powerSwitchAccessory::setBrightness Error ->' + error)
|
this.platform.log.debug('powerSwitchAccessory::setBrightness Error ->' + error)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user