Skip to content

Commit

Permalink
Allow all sub models.
Browse files Browse the repository at this point in the history
Allow all sub models.
  • Loading branch information
jfarmer08 committed Jul 18, 2023
1 parent e4de96b commit 4a1bf18
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ After you have done that if you feel like my work has been valuable to you I wel

## Releases

### v0.5.34
- Allow all sub models.

### v0.5.33
- Updated Thermostat behavior for single mode usage (heat/cool) (Thanks https://github.com/carTloyal123) - https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/111
### v0.5.32
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "homebridge-wyze-smart-home",
"version": "0.5.33",
"version": "0.5.34",
"description": "Wyze Smart Home plugin for Homebridge",
"license": "MIT",
"main": "src/index.js",
"scripts": {
"lint": "eslint src/**.js --max-warnings=0",
"start": "homebridge -I -D -P . -U testing"
"lint": "eslint src/**.js --max-warnings=0"
},
"keywords": [
"homebridge-plugin",
Expand Down
58 changes: 43 additions & 15 deletions src/WyzeSmartHome.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const { homebridge, Accessory, UUIDGen } = require('./types')
const { cameraModel } = require('./enums')
const { OutdoorPlugModels, PlugModels, CommonModels, CameraModels, NotSupportedModels ,LeakSensorModels,
TemperatureHumidityModels, LockModels, MotionSensorModels, ContactSensorModels, LightModels,
LightStripModels, MeshLightModels, ThermostatModels, S1GatewayModels } = require('./enums')

const WyzeAPI = require('./wyz-api')
const WyzePlug = require('./accessories/WyzePlug')
const WyzeLight = require('./accessories/WyzeLight')
Expand Down Expand Up @@ -154,34 +157,59 @@ module.exports = class WyzeSmartHome {
getAccessoryClass(type, model) {
switch (type) {
case 'OutdoorPlug':
if (model == 'WLPPO') return; // Discard entry for main unit. Only include the 2 electrical outlets.
if(Object.values(OutdoorPlugModels).includes(model)){ return WyzePlug } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzePlug }
case 'Plug':
return WyzePlug
if(Object.values(PlugModels).includes(model)){ return WyzePlug } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzePlug }
case 'Light':
return WyzeLight
if(Object.values(LightModels).includes(model)){ return WyzeLight } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeLight}
case 'MeshLight':
return WyzeMeshLight
if(Object.values(MeshLightModels).includes(model)){ return WyzeMeshLight } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeMeshLight}
case 'LightStrip':
return WyzeMeshLight
if(Object.values(LightStripModels).includes(model)){ return WyzeMeshLight } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeMeshLight}
case 'ContactSensor':
return WyzeContactSensor
if(Object.values(ContactSensorModels).includes(model)){ return WyzeContactSensor } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeContactSensor}
case 'MotionSensor':
return WyzeMotionSensor
if(Object.values(MotionSensorModels).includes(model)){ return WyzeMotionSensor } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeMotionSensor}
case 'Lock':
return WyzeLock
if(Object.values(LockModels).includes(model)){ return WyzeLock } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeLock}
case 'TemperatureHumidity':
return WyzeTemperatureHumidity
if(Object.values(TemperatureHumidityModels).includes(model)){ return WyzeTemperatureHumidity } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeTemperatureHumidity}
case 'LeakSensor':
return WyzeLeakSensor
if(Object.values(LeakSensorModels).includes(model)){ return WyzeLeakSensor } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeLeakSensor}
case 'Camera':
if(Object.values(cameraModel).includes(model)){return WyzeCamera} else return
if(Object.values(CameraModels).includes(model)){ return WyzeCamera } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeCamera}
case 'Common':
if (model === 'JA_HP') return
return WyzeSwitch
if(Object.values(CommonModels).includes(model)){ return WyzeSwitch } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added. If no issues are found`)
return WyzeSwitch}
case 'S1Gateway':
return WyzeHMS
case 'Thermostat':
return WyzeThermostat
if(Object.values(ThermostatModels).includes(model)){ return WyzeThermostat } else if (Object.values(NotSupportedModels).includes(model)){return}
else { this.log.error(`${type} (Model: ${model}) not supported submit a request to https://github.com/jfarmer08/homebridge-wyze-smart-home/issues to have it added.`)
return WyzeThermostat}
}
}

Expand Down
24 changes: 0 additions & 24 deletions src/accessories/WyzeAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module.exports = class WyzeAccessory {

switch (productType) {
case "OutdoorPlug":
if(productModel == "WLPPO-SUB") {
this.homeKitAccessory.context = {
mac: device.mac,
product_type: device.product_type,
Expand All @@ -106,9 +105,7 @@ module.exports = class WyzeAccessory {
},
}
break
}
case "Plug":
if(productModel == "WLPP1") {
this.homeKitAccessory.context = {
mac: device.mac,
product_type: device.product_type,
Expand All @@ -124,9 +121,7 @@ module.exports = class WyzeAccessory {
},
}
break
}
case "Common":
if(productModel == "LD_SS1") {
this.homeKitAccessory.context = {
mac: device.mac,
product_type: device.product_type,
Expand All @@ -144,8 +139,6 @@ module.exports = class WyzeAccessory {
},
}
break
}

case "Camera":
this.homeKitAccessory.context = {
mac: device.mac,
Expand Down Expand Up @@ -183,23 +176,6 @@ module.exports = class WyzeAccessory {
}
}
break
case "OutdoorPlug":
this.homeKitAccessory.context = {
mac: device.mac,
product_type: device.product_type,
product_model: device.product_model,
nickname: device.nickname,
conn_state: device.conn_state,
push_switch: device.push_switch,
device_params: device.device_params = {
switch_state : device.device_params.switch_state,
photosensitive_switch: device.device_params.photosensitive_switch,
ssid : device.device_params.ssid,
ip : device.device_params.ip,
rssi : device.device_params.rssi,
},
}
break
case "TemperatureHumidity":
this.homeKitAccessory.context = {
mac: device.mac,
Expand Down
67 changes: 61 additions & 6 deletions src/enums.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const cameraModel = {
//WyzeCamv1Hd: "WYZEC1"
const CameraModels = {
WyzeCamv1Hd: "WYZEC1",
WyzeCamV2: "WYZEC1-JZ",
WyzeCamV3: "WYZE_CAKP2JFUS",
//WyzeCamV3Pro: "HL_CAM3P"
Expand All @@ -8,14 +8,69 @@ const cameraModel = {
WyzeCamPanv2: "HL_PAN2",
WyzeCamPanv3: "HL_PAN3",
//WyzeCamPanPro: "HL_PANP",
//WyzeCamOutdoor: "WVOD1",
WyzeCamOutdoor: "WVOD1",
//WyzeCamOutdoov2: "HL_WCO2",
//WyzeCamDoorbell: "WYZEDB3",
WyzeCamDoorbell: "WYZEDB3",
//WyzeBatteryCamPro: "AN_RSCW",
//WyzeCamDoorbellPro2: "AN_RDB1",
//WyzeCamFloodLightPro: "LD_CFP",
//WyzeCamDoorbellPro: "GW_BE1",
//WyzeCamOG: "GW_GC1",
//WyzeCamOGTelephoto3x: "GW_GC"
};
exports.cameraModel = cameraModel;
}
exports.CameraModels = CameraModels;

const OutdoorPlugModels = {
WLPPOSUB: "WLPPO-SUB"
}
exports.OutdoorPlugModels = OutdoorPlugModels

const PlugModels = { WLPP1: "WLPP1", WLPP1CFH:"WLPP1CFH"}
exports.PlugModels = PlugModels

const LightModels = {BULB_WHITE:"WLPA19", BULB_WHITE_V2:"HL_HWB2"}
exports.LightModels = LightModels

const MeshLightModels = {MESH_BULB:"WLPA19C"}
exports.MeshLightModels = MeshLightModels

const LightStripModels = {LIGHT_STRIP:"HL_LSL", LIGHT_STRIP_PRO:"HL_LSLP"}
exports.LightStripModels = LightStripModels

const ContactSensorModels = {"V1": "DWS2U","V2":"DWS3U"}
exports.ContactSensorModels = ContactSensorModels

const MotionSensorModels = {V1:"PIR2U", V2:"PIR3U"}
exports.MotionSensorModels = MotionSensorModels

const LockModels = {YDLO1:"YD.LO1"}
exports.LockModels = LockModels

const TemperatureHumidityModels = {TH3U:"TH3U"}
exports.TemperatureHumidityModels = TemperatureHumidityModels

const LeakSensorModels = {WS3U:"WS3U"}
exports.LeakSensorModels = LeakSensorModels

const CommonModels = { "LightSwitch": "LD_SS1" }
exports.CommonModels = CommonModels

const S1GatewayModels = {}
exports.S1GatewayModels = S1GatewayModels

const ThermostatModels = {CO_EA1:"CO_EA1"}
exports.ThermostatModels = ThermostatModels

const ThermostatRoomSensor = {CO_TH1:"CO_TH1"}
exports.ThermostatRoomSensor = ThermostatRoomSensor

const NotSupportedModels = {"OutdoorPlugMain" : "WLPPO", "CHIME" : "CHIME", "HeadPhones":"JA_HP","YDGW1":"YD.GW1"}
exports.NotSupportedModels = NotSupportedModels


//VACUUM = ['JA_RO2']
//SCALE_ = ['JA.SC', 'JA.SC2']
//SCALE_S = ['WL_SC2']
//SCALE_X = ['WL_SC22135']
//WATCH = ['RA.WP1', 'RY.WA1']
//BAND = ['RY.HP1']

0 comments on commit 4a1bf18

Please sign in to comment.