diff --git a/config.schema.json b/config.schema.json index 73179e5..a3f5822 100644 --- a/config.schema.json +++ b/config.schema.json @@ -69,6 +69,8 @@ "sensors": { "type": "array", "title": "Sensors", + "default": [], + "minItems": 0, "description": "Create contact, motion, occupancy, smoke, temperature, humidity, airquality, light, or leak sensors.", "items": { "title": "Sensors", @@ -84,7 +86,7 @@ "title": "Name", "type": "string", "placeholder": "Sensor 1", - "required": false + "required": true }, "type": { "title": "Type", @@ -119,6 +121,8 @@ "switches": { "type": "array", "title": "Switches", + "default": [], + "minItems": 0, "description": "Turn on and off switches by triggering a URL from any system.", "items": { "title": "Switches", @@ -134,7 +138,7 @@ "title": "Name", "type": "string", "placeholder": "Switch 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -196,6 +200,8 @@ "pushbuttons": { "type": "array", "title": "Sensors", + "default": [], + "minItems": 0, "description": "Push Buttons by triggerring a URL from any system. The button will be released automatically.", "items": { "title": "Sensors", @@ -211,7 +217,7 @@ "title": "Name", "type": "string", "placeholder": "Push Button 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -249,6 +255,8 @@ "doorbells": { "type": "array", "title": "Doorbells", + "default": [], + "minItems": 0, "description": "Ring doorbells via a URL from any system.", "items": { "title": "Doorbells", @@ -264,7 +272,7 @@ "title": "Name", "type": "string", "placeholder": "Doorbell 1", - "required": false + "required": true }, "double_press": { "title": "Enable Double Press", @@ -282,6 +290,8 @@ "lights": { "type": "array", "title": "Lights", + "default": [], + "minItems": 0, "description": "Turn on and off Lights by triggering a URL from any system.", "items": { "title": "Lights", @@ -297,7 +307,7 @@ "title": "Name", "type": "string", "placeholder": "Light 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -394,6 +404,8 @@ "co2sensors": { "type": "array", "title": "CO2 Sensor", + "default": [], + "minItems": 0, "description": "Control a CO2 sensor by updating the PPM value.", "items": { "title": "CO2 Sensors", @@ -409,7 +421,7 @@ "title": "Name", "type": "string", "placeholder": "CO2 sensor 1", - "required": false + "required": true }, "co2_peak_level": { "title": "CO2 peak level", @@ -422,6 +434,8 @@ "thermostats": { "type": "array", "title": "Thermostats", + "default": [], + "minItems": 0, "description": "Control a thermostat by updating four different values.", "items": { "title": "Thermostats", @@ -437,7 +451,7 @@ "title": "Name", "type": "string", "placeholder": "Thermostat 1", - "required": false + "required": true }, "minTemp": { "title": "Lower bound for the temperature selector in the Home app", @@ -517,6 +531,8 @@ "outlets": { "type": "array", "title": "Outlets", + "default": [], + "minItems": 0, "description": "Turn on and off Outlets by triggering a URL from any system.", "items": { "title": "Outlets", @@ -532,7 +548,7 @@ "title": "Name", "type": "string", "placeholder": "Outlet 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -594,6 +610,8 @@ "security": { "type": "array", "title": "Security", + "default": [], + "minItems": 0, "description": "Control a security system by updating two different values.", "items": { "title": "Security", @@ -609,7 +627,7 @@ "title": "Name", "type": "string", "placeholder": "Security 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -647,6 +665,8 @@ "garagedooropeners": { "type": "array", "title": "Garage Door Openers", + "default": [], + "minItems": 0, "description": "Control a garage door opener by updating three different values.", "items": { "title": "Garage Door Openers", @@ -662,7 +682,7 @@ "title": "Name", "type": "string", "placeholder": "Garage Door Opener 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -724,6 +744,8 @@ "statelessswitches": { "type": "array", "title": "Stateless Switches", + "default": [], + "minItems": 0, "description": "Stateless switches requires 3 parameters accessoryId, buttonName and the event to trigger: Single press = 0, Double press = 1, Long press = 2.", "items": { "title": "Stateless Switches", @@ -739,7 +761,7 @@ "title": "Name", "type": "string", "placeholder": "Stateless Switch 1", - "required": false + "required": true }, "buttons": { "type": "array", @@ -773,6 +795,8 @@ "windowcoverings": { "type": "array", "title": "Window Coverings", + "default": [], + "minItems": 0, "description": "Control a window coverings by updating three different values.", "items": { "title": "Window Coverings", @@ -788,7 +812,7 @@ "title": "Name", "type": "string", "placeholder": "Window Covering 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -952,6 +976,8 @@ "lockmechanisms": { "type": "array", "title": "Lock Mechanisms", + "default": [], + "minItems": 0, "description": "Control a lock mechanism by updating two different values.", "items": { "title": "Lock Mechanisms", @@ -967,7 +993,7 @@ "title": "Name", "type": "string", "placeholder": "Lock 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -1029,6 +1055,8 @@ "fanv2s": { "type": "array", "title": "Fanv2", + "default": [], + "minItems": 0, "description": "Turn on and off Fanv2s by triggering a URL from any system.", "items": { "title": "Fanv2s", @@ -1044,7 +1072,7 @@ "title": "Name", "type": "string", "placeholder": "Fanv2 1", - "required": false + "required": true }, "rejectUnauthorized": { "title": "Reject Unauthorized SSL Certificate", @@ -1276,6 +1304,8 @@ "valves": { "type": "array", "title": "Valves", + "default": [], + "minItems": 0, "description": "Turn on and off valves by triggering a URL from any system.", "items": { "title": "Valves", @@ -1291,7 +1321,7 @@ "title": "Name", "type": "string", "placeholder": "Valve 1", - "required": false + "required": true }, "type": { "title": "Type", diff --git a/src/homekit/HttpWebHooksPlatform.js b/src/homekit/HttpWebHooksPlatform.js index d0f6bdb..a2935a0 100644 --- a/src/homekit/HttpWebHooksPlatform.js +++ b/src/homekit/HttpWebHooksPlatform.js @@ -30,22 +30,22 @@ function HttpWebHooksPlatform(log, config, homebridge) { dir : this.cacheDirectory }); - this.sensors = config["sensors"] || []; - this.switches = config["switches"] || []; - this.pushButtons = config["pushbuttons"] || []; - this.doorbells = config["doorbells"] || []; - this.lights = config["lights"] || []; - this.thermostats = config["thermostats"] || []; - this.outlets = config["outlets"] || []; - this.security = config["security"] || []; - this.garageDoorOpeners = config["garagedooropeners"] || []; - this.statelessSwitches = config["statelessswitches"] || []; - this.windowCoverings = config["windowcoverings"] || []; - this.lockMechanisms = config["lockmechanisms"] || []; - this.fanv2s = config["fanv2s"] || []; - this.co2sensors = config["co2sensors"] || []; - this.valves = config["valves"] || []; - + this.sensors = (config["sensors"] || []).filter(x => x && x.name); + this.switches = (config["switches"] || []).filter(x => x && x.name); + this.pushButtons = (config["pushbuttons"] || []).filter(x => x && x.name); + this.doorbells = (config["doorbells"] || []).filter(x => x && x.name); + this.lights = (config["lights"] || []).filter(x => x && x.name); + this.thermostats = (config["thermostats"] || []).filter(x => x && x.name); + this.outlets = (config["outlets"] || []).filter(x => x && x.name); + this.security = (config["security"] || []).filter(x => x && x.name); + this.garageDoorOpeners = (config["garagedooropeners"] || []).filter(x => x && x.name); + this.statelessSwitches = (config["statelessswitches"] || []).filter(x => x && x.name); + this.windowCoverings = (config["windowcoverings"] || []).filter(x => x && x.name); + this.lockMechanisms = (config["lockmechanisms"] || []).filter(x => x && x.name); + this.fanv2s = (config["fanv2s"] || []).filter(x => x && x.name); + this.co2sensors = (config["co2sensors"] || []).filter(x => x && x.name); + this.valves = (config["valves"] || []).filter(x => x && x.name); + this.server = new Server(Service, Characteristic, this, config); };