homey-lib
Advanced tools
Comparing version 1.0.25 to 1.0.30
@@ -182,2 +182,28 @@ "use strict"; | ||
// check tags | ||
if( lvl_publish && typeof json.tags !== 'undefined' ) { | ||
if( typeof json.tags === 'object' ) { | ||
for( let language in json.tags ) { | ||
if( Array.isArray(json.tags[language]) ) { | ||
json.tags[language].forEach(function(tag, i){ | ||
if( typeof tag !== 'string' ) { | ||
error('tags[' + language + '][' + i + '] is not a string'); | ||
} | ||
}) | ||
} else { | ||
error('tags[' + language + '] is not an array'); | ||
} | ||
} | ||
} else { | ||
error('tags is not an object'); | ||
} | ||
} | ||
// check images | ||
@@ -323,5 +349,24 @@ if( lvl_publish && typeof json.images == 'object' ) { | ||
} else if( lvl_publish ) { | ||
error("missing `drivers[" + i + "].images` in app.json"); | ||
error("missing `drivers[" + i + "].images` in app.json"); | ||
} | ||
if( lvl_publish && typeof driver.gtin !== 'undefined' ) { | ||
if( Array.isArray(driver.gtin) ) { | ||
driver.gtin.forEach(function(gtin, j){ | ||
if( typeof gtin === 'string' ) { | ||
if( !(gtin.length === 8 || gtin.length === 12 || gtin.length === 13 || gtin.length === 14) ) | ||
error("invalid `drivers[" + i + "].gtin[" + j + "]` length in app.json"); | ||
if( !isNumeric(gtin) ) | ||
error("invalid `drivers[" + i + "].gtin[" + j + "]` (non-numeric) in app.json"); | ||
} else { | ||
error("invalid `drivers[" + i + "].gtin[" + j + "]` type in app.json"); | ||
} | ||
}); | ||
} else { | ||
error("invalid `drivers[" + i + "].gtin` in app.json"); | ||
} | ||
} | ||
}.bind(this)) | ||
@@ -399,2 +444,33 @@ } | ||
if( lvl_publish && typeof json.speechExamples !== 'undefined' ) { | ||
if( typeof json.speechExamples === 'object' ) { | ||
var hasEnglish = false; | ||
for( var language in json.speechExamples ) { | ||
var speechExamplesArray = json.speechExamples[ language ]; | ||
if( Array.isArray(speechExamplesArray) ) { | ||
speechExamplesArray.forEach(function(speechExample, i){ | ||
if( typeof speechExample !== 'string' ) { | ||
error("invalid type `speechExamples." + language + "[" + i + "]` in app.json, expected string"); | ||
} | ||
}) | ||
if( language === 'en' ) | ||
hasEnglish = true; | ||
} else { | ||
error("invalid type `speechExamples." + language + "` in app.json, expected array"); | ||
} | ||
} | ||
if( !hasEnglish ) | ||
error('missing speechExamples.en in app.json'); | ||
} else { | ||
error("invalid type `speechExamples` in app.json, expected object") | ||
} | ||
} | ||
// validate permissions | ||
@@ -533,2 +609,7 @@ if( Array.isArray(json.permissions) ) { | ||
module.exports = App; | ||
function isNumeric(n) { | ||
return !isNaN(parseFloat(n)) && isFinite(n); | ||
} | ||
module.exports = App; | ||
{ | ||
"devices": { | ||
"other": { | ||
@@ -10,3 +9,2 @@ "name": { | ||
}, | ||
"socket": { | ||
@@ -17,5 +15,9 @@ "name": { | ||
}, | ||
"capabilities": [ "onoff", "dim", "measure_power", "meter_power" ] | ||
"capabilities": [ | ||
"onoff", | ||
"dim", | ||
"measure_power", | ||
"meter_power" | ||
] | ||
}, | ||
"light": { | ||
@@ -26,5 +28,11 @@ "name": { | ||
}, | ||
"capabilities": [ "onoff", "dim", "light_hue", "light_saturation", "light_temperature", "light_mode" ] | ||
"capabilities": [ | ||
"onoff", | ||
"dim", | ||
"light_hue", | ||
"light_saturation", | ||
"light_temperature", | ||
"light_mode" | ||
] | ||
}, | ||
"vacuumcleaner": { | ||
@@ -35,5 +43,6 @@ "name": { | ||
}, | ||
"capabilities": [ "vacuumcleaner_state" ] | ||
"capabilities": [ | ||
"vacuumcleaner_state" | ||
] | ||
}, | ||
"fan": { | ||
@@ -44,5 +53,7 @@ "name": { | ||
}, | ||
"capabilities": [ "onoff", "dim" ] | ||
"capabilities": [ | ||
"onoff", | ||
"dim" | ||
] | ||
}, | ||
"heater": { | ||
@@ -53,5 +64,7 @@ "name": { | ||
}, | ||
"capabilities": [ "onoff", "dim" ] | ||
"capabilities": [ | ||
"onoff", | ||
"dim" | ||
] | ||
}, | ||
"thermostat": { | ||
@@ -62,5 +75,8 @@ "name": { | ||
}, | ||
"capabilities": [ "measure_temperature", "target_temperature", "thermostat_mode" ] | ||
"capabilities": [ | ||
"measure_temperature", | ||
"target_temperature", | ||
"thermostat_mode" | ||
] | ||
}, | ||
"sensor": { | ||
@@ -71,5 +87,37 @@ "name": { | ||
}, | ||
"capabilities": [ "measure_temperature", "measure_co", "measure_co2", "measure_humidity", "measure_pressure", "measure_noise", "measure_rain", "measure_wind_strength", "measure_wind_angle", "measure_gust_strength", "measure_gust_angle", "measure_battery", "measure_power", "measure_luminance", "measure_ultraviolet", "alarm_generic", "alarm_motion", "alarm_contact", "alarm_co", "alarm_co2", "alarm_tamper", "alarm_smoke", "alarm_fire", "alarm_heat", "alarm_water", "alarm_battery", "alarm_night", "meter_power", "meter_water", "meter_gas" ] | ||
"capabilities": [ | ||
"measure_temperature", | ||
"measure_co", | ||
"measure_co2", | ||
"measure_humidity", | ||
"measure_pressure", | ||
"measure_noise", | ||
"measure_rain", | ||
"measure_wind_strength", | ||
"measure_wind_angle", | ||
"measure_gust_strength", | ||
"measure_gust_angle", | ||
"measure_battery", | ||
"measure_power", | ||
"measure_voltage", | ||
"measure_current", | ||
"measure_luminance", | ||
"measure_ultraviolet", | ||
"alarm_generic", | ||
"alarm_motion", | ||
"alarm_contact", | ||
"alarm_co", | ||
"alarm_co2", | ||
"alarm_tamper", | ||
"alarm_smoke", | ||
"alarm_fire", | ||
"alarm_heat", | ||
"alarm_water", | ||
"alarm_battery", | ||
"alarm_night", | ||
"meter_power", | ||
"meter_water", | ||
"meter_gas" | ||
] | ||
}, | ||
"kettle": { | ||
@@ -80,5 +128,8 @@ "name": { | ||
}, | ||
"capabilities": [ "onoff", "target_temperature", "measure_temperature" ] | ||
"capabilities": [ | ||
"onoff", | ||
"target_temperature", | ||
"measure_temperature" | ||
] | ||
}, | ||
"coffeemachine": { | ||
@@ -89,5 +140,8 @@ "name": { | ||
}, | ||
"capabilities": [ "onoff", "target_temperature", "measure_temperature" ] | ||
"capabilities": [ | ||
"onoff", | ||
"target_temperature", | ||
"measure_temperature" | ||
] | ||
}, | ||
"homealarm": { | ||
@@ -98,5 +152,7 @@ "name": { | ||
}, | ||
"capabilities": [ "homealarm_state", "alarm_tamper" ] | ||
"capabilities": [ | ||
"homealarm_state", | ||
"alarm_tamper" | ||
] | ||
}, | ||
"speaker": { | ||
@@ -107,5 +163,12 @@ "name": { | ||
}, | ||
"capabilities": [ "speaker_playing", "speaker_next", "speaker_prev", "volume_set", "volume_up", "volume_down", "volume_mute" ] | ||
"capabilities": [ | ||
"speaker_playing", | ||
"speaker_next", | ||
"speaker_prev", | ||
"volume_set", | ||
"volume_up", | ||
"volume_down", | ||
"volume_mute" | ||
] | ||
}, | ||
"button": { | ||
@@ -116,5 +179,6 @@ "name": { | ||
}, | ||
"capabilities": [ "button" ] | ||
"capabilities": [ | ||
"button" | ||
] | ||
}, | ||
"doorbell": { | ||
@@ -125,5 +189,6 @@ "name": { | ||
}, | ||
"capabilities": [ "alarm_generic" ] | ||
"capabilities": [ | ||
"alarm_generic" | ||
] | ||
}, | ||
"zwavecontroller": { | ||
@@ -135,3 +200,2 @@ "name": { | ||
}, | ||
"lock": { | ||
@@ -142,5 +206,8 @@ "name": { | ||
}, | ||
"capabilities": [ "locked", "lock_mode", "measure_battery" ] | ||
"capabilities": [ | ||
"locked", | ||
"lock_mode", | ||
"measure_battery" | ||
] | ||
}, | ||
"windowcoverings": { | ||
@@ -151,7 +218,9 @@ "name": { | ||
}, | ||
"capabilities": [ "onoff", "dim", "windowcoverings_state" ] | ||
"capabilities": [ | ||
"onoff", | ||
"dim", | ||
"windowcoverings_state" | ||
] | ||
} | ||
}, | ||
"capabilities": { | ||
@@ -165,3 +234,19 @@ "onoff": { | ||
"getable": true, | ||
"setable": true | ||
"setable": true, | ||
"options": { | ||
"setOnDim": { | ||
"type": "boolean", | ||
"default": true, | ||
"desc": { | ||
"en": "When a device has both an `onoff` and `dim` capability, and Homey wants to turn the device on AND to a specific dim value, set this capability to `false` to prevent Homey from sending a set command." | ||
} | ||
}, | ||
"greyout": { | ||
"type": "boolean", | ||
"default": false, | ||
"desc": { | ||
"en": "When this capability is false, give a visual hint to greyout the device." | ||
} | ||
} | ||
} | ||
}, | ||
@@ -249,3 +334,2 @@ "dim": { | ||
}, | ||
"vacuumcleaner_state": { | ||
@@ -296,3 +380,2 @@ "type": "enum", | ||
}, | ||
"thermostat_mode": { | ||
@@ -329,2 +412,9 @@ "type": "enum", | ||
} | ||
}, | ||
{ | ||
"id": "off", | ||
"title": { | ||
"en": "Off", | ||
"nl": "Uit" | ||
} | ||
} | ||
@@ -335,3 +425,2 @@ ], | ||
}, | ||
"target_temperature": { | ||
@@ -353,3 +442,2 @@ "type": "number", | ||
}, | ||
"measure_temperature": { | ||
@@ -591,2 +679,38 @@ "type": "number", | ||
}, | ||
"measure_voltage": { | ||
"type": "number", | ||
"title": { | ||
"en": "Voltage", | ||
"nl": "Voltage" | ||
}, | ||
"units": { | ||
"en": "V" | ||
}, | ||
"desc": { | ||
"en": "Voltage (V)", | ||
"nl": "Voltage (V)" | ||
}, | ||
"chartType": "stepLine", | ||
"decimals": 2, | ||
"getable": true, | ||
"setable": false | ||
}, | ||
"measure_current": { | ||
"type": "number", | ||
"title": { | ||
"en": "Current", | ||
"nl": "Stroom" | ||
}, | ||
"units": { | ||
"en": "A" | ||
}, | ||
"desc": { | ||
"en": "Electric current (A)", | ||
"nl": "Elektrische stroom (A)" | ||
}, | ||
"chartType": "stepLine", | ||
"decimals": 2, | ||
"getable": true, | ||
"setable": false | ||
}, | ||
"measure_luminance": { | ||
@@ -865,3 +989,2 @@ "type": "number", | ||
"values": [ | ||
{ | ||
@@ -868,0 +991,0 @@ "id": "armed", |
{ | ||
"name": "homey-lib", | ||
"version": "1.0.25", | ||
"version": "1.0.30", | ||
"description": "Library for Homey", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
103536
1784