Skip to content

Commit

Permalink
Merge pull request #109 from zswuwing/main
Browse files Browse the repository at this point in the history
Correction From zswuwing
  • Loading branch information
jfarmer08 authored Jun 29, 2023
2 parents eebc2c1 + 4f01808 commit e41f5db
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-wyze-smart-home",
"version": "0.5.26",
"version": "0.5.28",
"description": "Wyze Smart Home plugin for Homebridge",
"license": "MIT",
"main": "src/index.js",
Expand Down
46 changes: 24 additions & 22 deletions src/accessories/WyzeAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,28 +419,30 @@ module.exports = class WyzeAccessory {
}
}
let lockKeypadProperties = propertyList.device.keypad
const prop_keypad = Object.keys(lockKeypadProperties)
for (const element of prop_keypad) {
const prop = element
switch (prop ) {
case "power":
this.homeKitAccessory.context.device_params.keypadPower = lockKeypadProperties[prop]
continue
case "onoff_line":
this.homeKitAccessory.context.device_params.keypadOnoff_line = lockKeypadProperties[prop]
continue
}
}
let lockKeypadProp = propertyList.device.keypad.hardware_info
const prop_keypadProp = Object.keys(lockKeypadProp)
for (const element of prop_keypadProp) {
const prop = element
switch (prop ) {
case "mac":
this.homeKitAccessory.context.device_params.keypadMac = lockKeypadProp[prop]
continue
}
}
if (lockKeypadProperties != null) {
const prop_keypad = Object.keys(lockKeypadProperties)
for (const element of prop_keypad) {
const prop = element
switch (prop ) {
case "power":
this.homeKitAccessory.context.device_params.keypadPower = lockKeypadProperties[prop]
continue
case "onoff_line":
this.homeKitAccessory.context.device_params.keypadOnoff_line = lockKeypadProperties[prop]
continue
}
}
let lockKeypadProp = propertyList.device.keypad.hardware_info
const prop_keypadProp = Object.keys(lockKeypadProp)
for (const element of prop_keypadProp) {
const prop = element
switch (prop ) {
case "mac":
this.homeKitAccessory.context.device_params.keypadMac = lockKeypadProp[prop]
continue
}
}
}
this.updating = false
}
// Wall Switch Can we move this to its own class - wallSwitch
Expand Down
19 changes: 18 additions & 1 deletion src/accessories/WyzeHMS.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const { Service, Characteristic } = require('../types')
const WyzeAccessory = require('./WyzeAccessory')

const noResponse = new Error('No Response')
noResponse.toString = () => { return noResponse.message }

module.exports = class WyzeHMS extends WyzeAccessory {
constructor (plugin, homeKitAccessory) {
super(plugin, homeKitAccessory)
Expand Down Expand Up @@ -34,6 +37,20 @@ module.exports = class WyzeHMS extends WyzeAccessory {
}
}

getService () {
let service = this.homeKitAccessory.getService(Service.SecuritySystem)

if (!service) {
service = this.homeKitAccessory.addService(Service.SecuritySystem)
}

return service
}

getCharacteristic (characteristic) {
return this.getService().getCharacteristic(characteristic)
}

/**
* Handle requests to get the current value of the "Security System Current State" characteristic
*/
Expand Down Expand Up @@ -106,4 +123,4 @@ module.exports = class WyzeHMS extends WyzeAccessory {
sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms * 1000))
}
}
}
6 changes: 3 additions & 3 deletions src/accessories/WyzeLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const HOMEBRIDGE_BATTERY_CHARACTERISTIC = Characteristic.BatteryLevel
const HOMEBRIDGE_CONTACT_SENSOR_SERVICE = Service.ContactSensor
const HOMEBRIDGE_CONTACT_SENSOR_CHARACTERISTIC = Characteristic.ContactSensorState.CurrentDoorState

//const noResponse = new Error('No Response')
//noResponse.toString = () => { return noResponse.message }
const noResponse = new Error('No Response')
noResponse.toString = () => { return noResponse.message }

module.exports = class WyzeLock extends WyzeAccessory {
constructor (plugin, homeKitAccessory) {
Expand Down Expand Up @@ -124,4 +124,4 @@ module.exports = class WyzeLock extends WyzeAccessory {

checkBatteryVoltage (deviceVoltage) {
if (deviceVoltage >= 100) { return 100 } else if ( deviceVoltage == "undefined") { return 100 } else { return deviceVoltage }}
}
}

0 comments on commit e41f5db

Please sign in to comment.