def add_zone_slave(service):
 master_device_id = service.data.get('master')
 slaves_ids = service.data.get('slaves')
 slaves = [device for device in DEVICES if (device.entity_id in slaves_ids)]
 master = next([device for device in DEVICES if (device.entity_id == master_device_id)].__iter__(), None)
 if (master is None):
  _LOGGER.warning(('Unable to find master with entity_id:' + str(master_device_id)))
 elif (not slaves):
  _LOGGER.warning('Unable to find slaves to add')
 else:
  _LOGGER.info(('Adding slaves to zone with master ' + str(master.device.config.name)))
  master.device.add_zone_slave([slave.device for slave in slaves])

def add_zone_slave ( service ) : master_device_id = service . data . get ( 'master' ) slaves_ids = service . data . get ( 'slaves' ) slaves = [ device for device in DEVICES if ( device . entity_id in slaves_ids ) ] master = next ( [ device for device in DEVICES if ( device . entity_id == master_device_id ) ] . __iter__ ( ) , None ) if ( master is None ) : _LOGGER . warning ( ( 'Unable to find master with entity_id:' + str ( master_device_id ) ) ) elif ( not slaves ) : _LOGGER . warning ( 'Unable to find slaves to add' ) else : _LOGGER . info ( ( 'Adding slaves to zone with master ' + str ( master . device . config . name ) ) ) master . device . add_zone_slave ( [ slave . device for slave in slaves ] )
add slave(s) to and existing zone .