--- controller.js.orig 2020-04-21 18:27:51.710211346 +0200 +++ controller.js 2020-04-22 17:41:12.882337590 +0200 @@ -314,6 +314,8 @@ Controller.prototype.getAccessories = function(api_accessory) { var name; + var props; + var info; var accessories = {}; var service, characteristics, properties; var ack, message; @@ -324,10 +326,23 @@ name = "*"; } - if (name !== "*" && name !== "all" && name !== "*_props" && name !== "all_props" && typeof(this.accessories[name]) === "undefined") { + if (typeof api_accessory.props !== "undefined") { + props = api_accessory.props; + } else { + props = 0; + } + + if (typeof api_accessory.info !== "undefined") { + info = api_accessory.info; + } else { + info = 0; + } + + if (name !== "*" && name !== "all" && name !== "*_props" && name !== "all_props" && name !== "*_info" && name !== "all_info" && typeof(this.accessories[name]) === "undefined") { ack = false; message = "name '" + name + "' undefined."; } else { + if( name === "*_props" || name === "all_props" ) { props = 1; name = "*"; } switch (name) { case "*": case "all": @@ -335,24 +350,56 @@ //this.log.debug("Controller.getAccessories %s", JSON.stringify(this.accessories[k], null, 2)); service = this.accessories[k].service_types; characteristics = this.accessories[k].i_value; + accessories[k] = {"services": service, "characteristics": characteristics}; - } - break; - case "*_props": - case "all_props": - for (var k in this.accessories) { - //this.log.debug("Controller.getAccessories %s", JSON.stringify(this.accessories[k], null, 2)); - service = this.accessories[k].service_types; - characteristics = this.accessories[k].i_value; - properties = this.accessories[k].i_props; - accessories[k] = {"services": service, "characteristics": characteristics, "properties": properties}; + + if( props === 1 ) + { + properties = this.accessories[k].i_props; + accessories[k].properties = properties; + } + + if( info === 1 ) + { + var aservice = this.hap_accessories[k].getService(Service.AccessoryInformation); + var accessoryinformation = { + "manufacturer" : aservice.getCharacteristic("Manufacturer").value, + "model" : aservice.getCharacteristic("Model").value, + "name" : aservice.getCharacteristic("Name").value, + "serialnumber" : aservice.getCharacteristic("Serial Number").value, + "firmwarerevision" : aservice.getCharacteristic("Firmware Revision").value + } + accessories[k].accessoryinformation = accessoryinformation; + } + } break; default: service = this.accessories[name].service_types; characteristics = this.accessories[name].i_value; - accessories[name] = {"services": service, "characteristics": characteristics}; + + accessories[name] = {"services": service, "characteristics": characteristics }; + + if( props === 1 ) + { + properties = this.accessories[name].i_props; + accessories[name].properties = properties; + } + + if( info === 1 ) + { + var aservice = this.hap_accessories[name].getService(Service.AccessoryInformation); + var accessoryinformation = { + "manufacturer" : aservice.getCharacteristic("Manufacturer").value, + "model" : aservice.getCharacteristic("Model").value, + "name" : aservice.getCharacteristic("Name").value, + "serialnumber" : aservice.getCharacteristic("Serial Number").value, + "firmwarerevision" : aservice.getCharacteristic("Firmware Revision").value + } + accessories[name].accessoryinformation = accessoryinformation; + } + } ack = true; message = "name '" + name + "' valid."; }