Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SonosModule.search({timeout: this.searchTimeout}, function(zp, model) {
const deviceProperties = new SonosModule.Services.DeviceProperties(zp.host, zp.port);
const zoneGroupTopology = new SonosModule.Services.ZoneGroupTopology(zp.host, zp.port);
const alarmClock = new SonosModule.Services.AlarmClock(zp.host, zp.port);
zp.model = model;
deviceProperties.GetZoneAttributes({}, function(err, attrs) {
if (err) {
this.log.error('%s:%s: error %s', zp.host, zp.port, err);
} else {
zp.zone = attrs.CurrentZoneName;
// this.log.debug('%s: zone attrs %j', zp.zone, attrs);
deviceProperties.GetZoneInfo({}, function(err, info) {
if (err) {
this.log.error('%s: error %s', zp.zone, err);
} else {
// this.log.debug('%s: info %j', zp.zone, info);
zp.id = 'RINCON_' + info.MACAddress.replace(/:/g, '') +
('00000' + zp.port).substr(-5, 5);
SonosModule.search({timeout: this.searchTimeout}, function(zp, model) {
const deviceProperties = new SonosModule.Services.DeviceProperties(zp.host, zp.port);
const zoneGroupTopology = new SonosModule.Services.ZoneGroupTopology(zp.host, zp.port);
const alarmClock = new SonosModule.Services.AlarmClock(zp.host, zp.port);
zp.model = model;
deviceProperties.GetZoneAttributes({}, function(err, attrs) {
if (err) {
this.log.error('%s:%s: error %s', zp.host, zp.port, err);
} else {
zp.zone = attrs.CurrentZoneName;
// this.log.debug('%s: zone attrs %j', zp.zone, attrs);
deviceProperties.GetZoneInfo({}, function(err, info) {
if (err) {
this.log.error('%s: error %s', zp.zone, err);
} else {
// this.log.debug('%s: info %j', zp.zone, info);
zp.id = 'RINCON_' + info.MACAddress.replace(/:/g, '') +
('00000' + zp.port).substr(-5, 5);
zp.version = info.DisplaySoftwareVersion;
this.alarms = {};
if (this.platform.alarms) {
for (let id in zp.alarms) {
const alarm = zp.alarms[id];
if (alarm && alarm.RoomUUID === this.uuid_base) {
this.alarms[alarm.ID] = new ZPAlarm(this, alarm);
this.services.push(this.alarms[alarm.ID].service);
}
}
}
this.avTransport = new SonosModule.Services.AVTransport(this.zp.host, this.zp.port);
this.renderingControl = new SonosModule.Services.RenderingControl(this.zp.host, this.zp.port);
this.groupRenderingControl = new SonosModule.Services.GroupRenderingControl(this.zp.host, this.zp.port);
this.alarmClock = new SonosModule.Services.AlarmClock(this.zp.host, this.zp.port);
this.on('GroupManagement', this.handleGroupManagementEvent);
this.on('AVTransport', this.handleAVTransportEvent);
this.on('RenderingControl', this.handleRenderingControlEvent);
this.on('GroupRenderingControl', this.handleGroupRenderingControlEvent);
this.on('AlarmClock', this.handleAlarmClockEvent);
this.createSubscriptions();
}
if (this.platform.speakers) {
this.services.push(this.zoneService);
}
this.alarms = {};
if (this.platform.alarms) {
for (let id in zp.alarms) {
const alarm = zp.alarms[id];
if (alarm && alarm.RoomUUID === this.uuid_base) {
this.alarms[alarm.ID] = new ZPAlarm(this, alarm);
this.services.push(this.alarms[alarm.ID].service);
}
}
}
this.avTransport = new SonosModule.Services.AVTransport(this.zp.host, this.zp.port);
this.renderingControl = new SonosModule.Services.RenderingControl(this.zp.host, this.zp.port);
this.groupRenderingControl = new SonosModule.Services.GroupRenderingControl(this.zp.host, this.zp.port);
this.alarmClock = new SonosModule.Services.AlarmClock(this.zp.host, this.zp.port);
this.on('GroupManagement', this.handleGroupManagementEvent);
this.on('AVTransport', this.handleAVTransportEvent);
this.on('RenderingControl', this.handleRenderingControlEvent);
this.on('GroupRenderingControl', this.handleGroupRenderingControlEvent);
this.on('AlarmClock', this.handleAlarmClockEvent);
this.createSubscriptions();
}